public class SemanticGraphFactory
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
SemanticGraphFactory.Mode |
Modifier and Type | Method and Description |
---|---|
static SemanticGraph |
allTypedDependencies(Tree tree,
boolean collapse)
Returns a new SemanticGraph constructed from the given tree.
|
static SemanticGraph |
deepCopyFromGraphs(java.util.List<SemanticGraph> graphs,
java.util.List<java.lang.Integer> lengths)
Like makeFromGraphs, but it makes a deep copy of the graphs and
renumbers the index words.
|
static SemanticGraph |
duplicateKeepNodes(SemanticGraph sg)
This creates a new graph based off the given, but uses the existing nodes objects.
|
static SemanticGraph |
generateCCProcessedDependencies(GrammaticalStructure gs,
java.lang.String docID,
int index)
Produces a CCProcessed SemanticGraph with no extras.
|
static SemanticGraph |
generateCCProcessedDependencies(Tree tree)
Produces a CCProcessed SemanticGraph with no extras.
|
static SemanticGraph |
generateCollapsedDependencies(GrammaticalStructure gs,
java.lang.String docID,
int index)
Produces a Collapsed SemanticGraph with no extras.
|
static SemanticGraph |
generateCollapsedDependencies(Tree tree)
Produces a Collapsed SemanticGraph with no extras.
|
static SemanticGraph |
generateUncollapsedDependencies(GrammaticalStructure gs,
java.lang.String docID,
int index)
Produces an Uncollapsed SemanticGraph with no extras.
|
static SemanticGraph |
generateUncollapsedDependencies(Tree tree)
Produces an Uncollapsed SemanticGraph with no extras.
|
static java.util.Set<IndexedWord> |
getVerticesFromEdgeSet(java.lang.Iterable<SemanticGraphEdge> edges)
Given an iterable set of edges, returns the set of vertices covered by these edges.
|
static SemanticGraph |
makeFromEdges(java.lang.Iterable<SemanticGraphEdge> edges)
Given a list of edges, attempts to create and return a rooted SemanticGraph.
|
static SemanticGraph |
makeFromGraphs(java.util.Collection<SemanticGraph> sgList)
Given a list of graphs, constructs a new graph combined from the
collection of graphs.
|
static SemanticGraph |
makeFromTree(GrammaticalStructure gs,
SemanticGraphFactory.Mode mode,
boolean includeExtras,
boolean lemmatize,
boolean threadSafe) |
static SemanticGraph |
makeFromTree(GrammaticalStructure gs,
SemanticGraphFactory.Mode mode,
boolean includeExtras,
boolean lemmatize,
boolean threadSafe,
Filter<TypedDependency> filter,
java.lang.String docID,
int sentIndex) |
static SemanticGraph |
makeFromTree(GrammaticalStructure structure,
java.lang.String docID,
int sentIndex) |
static SemanticGraph |
makeFromTree(Tree tree)
Returns a new SemanticGraph constructed from the given tree.
|
static SemanticGraph |
makeFromTree(Tree tree,
boolean collapse)
Returns a new SemanticGraph constructed from the given tree.
|
static SemanticGraph |
makeFromTree(Tree tree,
SemanticGraphFactory.Mode mode,
boolean includeExtras,
boolean lemmatize,
boolean threadSafe) |
static SemanticGraph |
makeFromTree(Tree tree,
SemanticGraphFactory.Mode mode,
boolean includeExtras,
boolean lemmatize,
boolean threadSafe,
Filter<TypedDependency> filter)
Returns a new
SemanticGraph constructed from a given Tree with given options. |
static SemanticGraph |
makeFromTree(Tree tree,
SemanticGraphFactory.Mode mode,
boolean includeExtras,
boolean lemmatize,
boolean threadSafe,
Filter<TypedDependency> filter,
java.lang.String docID,
int sentIndex)
Returns a new
SemanticGraph constructed from a given Tree with given options. |
static SemanticGraph |
makeFromTree(Tree tree,
SemanticGraphFactory.Mode mode,
boolean includeExtras,
Filter<TypedDependency> filter) |
static SemanticGraph |
makeFromVertices(SemanticGraph sg,
java.util.Collection<IndexedWord> nodes)
Given a set of vertices, and the source graph they are drawn from, create a path composed
of the minimum paths between the vertices.
|
public static SemanticGraph generateUncollapsedDependencies(Tree tree)
public static SemanticGraph generateCollapsedDependencies(Tree tree)
public static SemanticGraph generateCCProcessedDependencies(Tree tree)
public static SemanticGraph generateUncollapsedDependencies(GrammaticalStructure gs, java.lang.String docID, int index)
public static SemanticGraph generateCollapsedDependencies(GrammaticalStructure gs, java.lang.String docID, int index)
public static SemanticGraph generateCCProcessedDependencies(GrammaticalStructure gs, java.lang.String docID, int index)
public static SemanticGraph makeFromTree(Tree tree, SemanticGraphFactory.Mode mode, boolean includeExtras, boolean lemmatize, boolean threadSafe, Filter<TypedDependency> filter)
SemanticGraph
constructed from a given Tree
with given options.
This factory method is intended to replace a profusion of highly similar
factory methods, such as
typedDependencies()
,
typedDependenciesCollapsed()
,
allTypedDependencies()
,
allTypedDependenciesCollapsed()
, etc.
For a fuller explanation of the meaning of the boolean arguments, see
GrammaticalStructure
. tree
- A tree representing a phrase structure parsecollapse
- Whether to do "collapsing" of pairs of dependencies into
single dependencies, e.g., for prepositions and conjunctionsccProcess
- Whether to do processing of CC complements resulting from
collapsing. This argument is ignored unless collapse
is
true
includeExtras
- Whether to include extra dependencies, which may
result in a non-treelemmatize
- Whether to compute lemma for each nodethreadSafe
- Whether to make sure processing is thread-safefilter
- A filter to exclude certain dependencies; ignored if nullpublic static SemanticGraph makeFromTree(Tree tree, SemanticGraphFactory.Mode mode, boolean includeExtras, boolean lemmatize, boolean threadSafe, Filter<TypedDependency> filter, java.lang.String docID, int sentIndex)
SemanticGraph
constructed from a given Tree
with given options.
This factory method is intended to replace a profusion of highly similar
factory methods, such as
typedDependencies()
,
typedDependenciesCollapsed()
,
allTypedDependencies()
,
allTypedDependenciesCollapsed()
, etc.
For a fuller explanation of the meaning of the boolean arguments, see
GrammaticalStructure
. tree
- A tree representing a phrase structure parsecollapse
- Whether to do "collapsing" of pairs of dependencies into
single dependencies, e.g., for prepositions and conjunctionsccProcess
- Whether to do processing of CC complements resulting from
collapsing. This argument is ignored unless collapse
is
true
includeExtras
- Whether to include extra dependencies, which may
result in a non-treelemmatize
- Whether to compute lemma for each nodethreadSafe
- Whether to make sure processing is thread-safefilter
- A filter to exclude certain dependencies; ignored if nulldocID
- The docID that the tree came fromsentIndex
- The sentence number of the tree in the documentpublic static SemanticGraph makeFromTree(GrammaticalStructure gs, SemanticGraphFactory.Mode mode, boolean includeExtras, boolean lemmatize, boolean threadSafe, Filter<TypedDependency> filter, java.lang.String docID, int sentIndex)
public static SemanticGraph makeFromTree(GrammaticalStructure structure, java.lang.String docID, int sentIndex)
public static SemanticGraph makeFromTree(Tree tree, SemanticGraphFactory.Mode mode, boolean includeExtras, Filter<TypedDependency> filter)
public static SemanticGraph makeFromTree(Tree tree, SemanticGraphFactory.Mode mode, boolean includeExtras, boolean lemmatize, boolean threadSafe)
public static SemanticGraph makeFromTree(GrammaticalStructure gs, SemanticGraphFactory.Mode mode, boolean includeExtras, boolean lemmatize, boolean threadSafe)
public static SemanticGraph makeFromTree(Tree tree, boolean collapse)
tree
- tree from which to make new semantic graphcollapse
- collapse dependencies iff this parameter is truepublic static SemanticGraph makeFromTree(Tree tree)
public static SemanticGraph allTypedDependencies(Tree tree, boolean collapse)
tree
- tree from which to make new semantic graphcollapse
- collapse dependencies iff this parameter is truepublic static SemanticGraph makeFromEdges(java.lang.Iterable<SemanticGraphEdge> edges)
TODO: throw Exceptions, or flag warnings on conditions for concern (no root, etc)
public static java.util.Set<IndexedWord> getVerticesFromEdgeSet(java.lang.Iterable<SemanticGraphEdge> edges)
Note: CDM changed the return of this from a List to a Set in 2011. This seemed more sensible. Hopefully it doesn't break anything....
public static SemanticGraph makeFromVertices(SemanticGraph sg, java.util.Collection<IndexedWord> nodes)
public static SemanticGraph duplicateKeepNodes(SemanticGraph sg)
public static SemanticGraph makeFromGraphs(java.util.Collection<SemanticGraph> sgList)
public static SemanticGraph deepCopyFromGraphs(java.util.List<SemanticGraph> graphs, java.util.List<java.lang.Integer> lengths)
lengths
must be a vector containing the number of
tokens in each sentence. This is used to reindex the tokens.