Liking cljdoc? Tell your friends :D

dk.simongray.datalinguist.dependency

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!

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!
raw docstring

acyclic?clj

(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.
raw docstring

ancestor?clj

(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`.
raw docstring

childrenclj

(children g vertex)

The children of vertex in dependency graph g.

The children of `vertex` in dependency graph `g`.
raw docstring

common-ancestorclj

(common-ancestor g vertex1 vertex2)

contains-edge?clj

(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`.
raw docstring

contains-vertex?clj

(contains-vertex? g vertex)

True if dependency graph g contains vertex.

True if dependency graph `g` contains `vertex`.
raw docstring

dependentclj

(dependent edge)

The dependent (= target) of the relation represented by edge.

The dependent (= target) of the relation represented by `edge`.
raw docstring

descendantsclj

(descendants g vertex)

The descendants of the vertex in dependency graph g.

The descendants of the `vertex` in dependency graph `g`.
raw docstring

edgesclj

(edges g)

The edges of dependency graph g.

The edges of dependency graph `g`.
raw docstring

extra?clj

(extra? edge)

Whether or not the dependency that this edge represents was 'extra'.

Whether or not the dependency that this `edge` represents was 'extra'.
raw docstring

formatted-stringclj

(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.
raw docstring

governorclj

(governor edge)

The governor (= source) of the relation represented by edge.

The governor (= source) of the relation represented by `edge`.
raw docstring

in-degreeclj

(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`.
raw docstring

incoming-edgesclj

(incoming-edges g vertex)

The incoming edges of vertex in dependency graph g.

The incoming edges of `vertex` in dependency graph `g`.
raw docstring

loom-digraphclj

(loom-digraph g)

Create a loom Digraph from dependency graph g.

Create a loom Digraph from dependency graph `g`.
raw docstring

nth-vertexclj

(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.
raw docstring

out-degreeclj

(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`.
raw docstring

outgoing-edgesclj

(outgoing-edges g vertex)

The outgoing edges of vertex in dependency graph g.

The outgoing edges of `vertex` in dependency graph `g`.
raw docstring

parentclj

(parent g vertex)

The syntactic parent of vertex in dependency graph g.

The syntactic parent of `vertex` in dependency graph `g`.
raw docstring

parentsclj

(parents g vertex)

The parents of vertex in dependency graph g.

The parents of `vertex` in dependency graph `g`.
raw docstring

parseclj

(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]]
raw docstring

pathclj

(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.
raw docstring

path-to-rootclj

(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`.
raw docstring

relationclj

(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).
raw docstring

rootclj

(root g)

The root vertex of a dependency dependency graph g.

The root vertex of a dependency dependency graph `g`.
raw docstring

sem-findclj

(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().
raw docstring

sem-matcherclj

(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.
raw docstring

sem-matchesclj

(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".
raw docstring

sem-patternclj

(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.
raw docstring

sem-resultclj

(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.
raw docstring

sem-seqclj

(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`.
raw docstring

siblingsclj

(siblings g vertex)

The siblings of the vertex in dependency graph g.

The siblings of the `vertex` in dependency graph `g`.
raw docstring

spanclj

(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.
raw docstring

subgraphclj

(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`.
raw docstring

topological-sortclj

(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`.
raw docstring

tree?clj

(tree? g)

True if the dependency graph g is a tree.

True if the dependency graph `g` is a tree.
raw docstring

verticesclj

(vertices g)

The vertices of dependency graph g.

The vertices of dependency graph `g`.
raw docstring

weightclj

(weight edge)

A score or weight attached to the edge (not often used).

A score or weight attached to the `edge` (not often used).
raw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close