Functions dealing with dependency grammar graphs, AKA Semantic Graphs.
CoreNLP contains some duplicate field and method names, e.g. governor is the same as source. This namespace only retains a single name for these terms.
Some easily replicated convenience function cruft has also not been retained:
Nor have any useless utility functions that are easily replicated:
The methods in SemanticGraphUtils are mostly meant for internal consumption, though a few are useful enough to warrant wrapping here, e.g. subgraph.
Functions dealing with semgrex in CoreNLP (dependency grammar patterns) have
been wrapped so as to mimic the existing Clojure Core regex functions. The
sem-result
function also mimics re-groups and serves a similar purpose,
although rather than returning groups it returns named nodes/relations defined
in the pattern.
Additionally, any mutating functions have deliberately not been wrapped!
Functions dealing with dependency grammar graphs, AKA Semantic Graphs. CoreNLP contains some duplicate field and method names, e.g. governor is the same as source. This namespace only retains a single name for these terms. Some easily replicated convenience function cruft has also not been retained: - matchPatternToVertex - variations on basic graph functionality, e.g. getChildList - isNegatedVerb, isNegatedVertex, isInConditionalContext, etc. - getSubgraphVertices, yield seem equal in functionality to descendants Nor have any useless utility functions that are easily replicated: - toRecoveredSentenceString and the like - empty, size - sorting methods; just use Clojure sort, e.g. (sort (vertices g)) The methods in SemanticGraphUtils are mostly meant for internal consumption, though a few are useful enough to warrant wrapping here, e.g. subgraph. Functions dealing with semgrex in CoreNLP (dependency grammar patterns) have been wrapped so as to mimic the existing Clojure Core regex functions. The `sem-result` function also mimics re-groups and serves a similar purpose, although rather than returning groups it returns named nodes/relations defined in the pattern. Additionally, any mutating functions have deliberately not been wrapped!
(acyclic? g)
(acyclic? g vertex)
True if the dependency graph g
or subgraph at vertex
contains no cycles.
True if the dependency graph `g` or subgraph at `vertex` contains no cycles.
(ancestor? g child vertex)
True if vertex
is the ancestor of child
in dependency graph g
.
True if `vertex` is the ancestor of `child` in dependency graph `g`.
(children g vertex)
The children of vertex
in dependency graph g
.
The children of `vertex` in dependency graph `g`.
(common-ancestor g vertex1 vertex2)
(contains-edge? g edge)
(contains-edge? g governor dependent)
True if dependency graph g
contains edge
, or governor
+ dependent
.
True if dependency graph `g` contains `edge`, or `governor` + `dependent`.
(contains-vertex? g vertex)
True if dependency graph g
contains vertex
.
True if dependency graph `g` contains `vertex`.
(dependent edge)
The dependent (= target) of the relation represented by edge
.
The dependent (= target) of the relation represented by `edge`.
(descendants g vertex)
The descendants of the vertex
in dependency graph g
.
The descendants of the `vertex` in dependency graph `g`.
(extra? edge)
Whether or not the dependency that this edge
represents was 'extra'.
Whether or not the dependency that this `edge` represents was 'extra'.
(formatted-string g)
(formatted-string style
g
&
{:keys [graph-name label-format]
:or {graph-name "" label-format :value-tag-index}})
Format dependency graph g
, optionally according to a specified style
.
The style can be a SemanticGraphFormatter or one of: :xml, :list, :readable, :recursive, :pos, :compact, :compact-pos, or :dot.
Format dependency graph `g`, optionally according to a specified `style`. The style can be a SemanticGraphFormatter or one of: :xml, :list, :readable, :recursive, :pos, :compact, :compact-pos, or :dot.
(governor edge)
The governor (= source) of the relation represented by edge
.
The governor (= source) of the relation represented by `edge`.
(in-degree g vertex)
The number of incoming edges of vertex
in dependency graph g
.
The number of incoming edges of `vertex` in dependency graph `g`.
(incoming-edges g vertex)
The incoming edges of vertex
in dependency graph g
.
The incoming edges of `vertex` in dependency graph `g`.
(loom-digraph g)
Create a loom Digraph from dependency graph g
.
Create a loom Digraph from dependency graph `g`.
(nth-vertex g n)
(nth-vertex g n not-found)
The vertex at index n
in dependency graph g
; not-found
is optional.
Note: indexes start at 1 in the SemanticGraph class, but this function respects the regular Clojure semantics and starts counting at 0.
The vertex at index `n` in dependency graph `g`; `not-found` is optional. Note: indexes start at 1 in the SemanticGraph class, but this function respects the regular Clojure semantics and starts counting at 0.
(out-degree g vertex)
The number of outgoing edges of vertex
in dependency graph g
.
The number of outgoing edges of `vertex` in dependency graph `g`.
(outgoing-edges g vertex)
The outgoing edges of vertex
in dependency graph g
.
The outgoing edges of `vertex` in dependency graph `g`.
(parent g vertex)
The syntactic parent of vertex
in dependency graph g
.
The syntactic parent of `vertex` in dependency graph `g`.
(parents g vertex)
The parents of vertex
in dependency graph g
.
The parents of `vertex` in dependency graph `g`.
(parse s)
(parse s language)
Create a dependency graph from a string s
using the compact string format.
Assumes English by default, but another supported language
may be specified
as either a keyword/string or using the CoreNLP Language enum.
Example string: [ate subj>Bill dobj>[muffins compound>blueberry]]
Create a dependency graph from a string `s` using the compact string format. Assumes English by default, but another supported `language` may be specified as either a keyword/string or using the CoreNLP Language enum. Example string: [ate subj>Bill dobj>[muffins compound>blueberry]]
(path g from to)
(path style g from to)
The shortest path from
vertex and to
vertex in dependency graph g
;
style
can optionally be :directed (default) or :undirected.
The shortest path `from` vertex and `to` vertex in dependency graph `g`; `style` can optionally be :directed (default) or :undirected.
(path-to-root g vertex)
Find the path from the given vertex
to the root of dependency graph g
.
Find the path from the given `vertex` to the root of dependency graph `g`.
(relation edge)
(relation style edge)
The grammatical relation labeling an edge
in a dependency graph.
The optional style
can be either :long or :short (default).
The grammatical relation labeling an `edge` in a dependency graph. The optional `style` can be either :long or :short (default).
(root g)
The root vertex of a dependency dependency graph g
.
The root vertex of a dependency dependency graph `g`.
(sem-find m)
(sem-find p g)
Return the next semgrex match, if any, of string to pattern, using SemgrexMatcher.find().
Return the next semgrex match, if any, of string to pattern, using SemgrexMatcher.find().
(sem-matcher p g)
Create a SemgrexMatcher from p
and dependency graph g
; use in sem-find.
Create a SemgrexMatcher from `p` and dependency graph `g`; use in sem-find.
(sem-matches p g)
Returns the match, if any, of dependency graph g
to pattern p
using
edu.stanford.nlp.semgraph.semgrex.SemgrexMatcher.matches(). Uses sem-result to
return any named nodes or relations.
It's actually closer to java.util.regex's "lookingAt" in that the root of the graph has to match the root of the pattern but the whole tree does not have to be "accounted for".
Returns the match, if any, of dependency graph `g` to pattern `p` using edu.stanford.nlp.semgraph.semgrex.SemgrexMatcher.matches(). Uses sem-result to return any named nodes or relations. It's actually closer to java.util.regex's "lookingAt" in that the root of the graph has to match the root of the pattern but the whole tree does not have to be "accounted for".
(sem-pattern s)
Return an instance of SemgrexPattern, for use, e.g. in sem-matcher.
Return an instance of SemgrexPattern, for use, e.g. in sem-matcher.
(sem-result m)
Returns the named nodes and relations from the most recent match/find. If there are no named nodes/relations, returns the match itself. If there are named nodes/relations, returns a vector with the first element being the match itself and the second a map of names -> nodes/relations.
Returns the named nodes and relations from the most recent match/find. If there are no named nodes/relations, returns the match itself. If there are named nodes/relations, returns a vector with the first element being the match itself and the second a map of names -> nodes/relations.
(sem-seq p g)
Return a lazy list of matches of SemgrexPattern p
in SemanticGraph g
.
Return a lazy list of matches of SemgrexPattern `p` in SemanticGraph `g`.
(siblings g vertex)
The siblings of the vertex
in dependency graph g
.
The siblings of the `vertex` in dependency graph `g`.
(span g vertex)
The span of the subtree yield of this vertex
in dependency graph g
.
Returns a zero-indexed pair of integers where end is exclusive.
The span of the subtree yield of this `vertex` in dependency graph `g`. Returns a zero-indexed pair of integers where end is exclusive.
(subgraph g root)
Create a subgraph of dependency graph g
from the chosen root
.
Create a subgraph of dependency graph `g` from the chosen `root`.
(topological-sort g)
The topologically sorted list of all vertices in dependency graph g
.
The topologically sorted list of all vertices in dependency graph `g`.
(tree? g)
True if the dependency graph g
is a tree.
True if the dependency graph `g` is a tree.
(vertices g)
The vertices of dependency graph g
.
The vertices of dependency graph `g`.
(weight edge)
A score or weight attached to the edge
(not often used).
A score or weight attached to the `edge` (not often used).
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close