public class UniversalEnglishGrammaticalStructure extends GrammaticalStructure
Modifier and Type | Class and Description |
---|---|
static class |
UniversalEnglishGrammaticalStructure.FromDependenciesFactory |
GrammaticalStructure.Extras
allTypedDependencies, CoNLLX_FieldCount, CoNLLX_GovField, CoNLLX_POSField, CoNLLX_RelnField, CoNLLX_WordField, DEFAULT_PARSER_FILE, puncFilter, root, tagFilter, typedDependencies
Constructor and Description |
---|
UniversalEnglishGrammaticalStructure(java.util.List<TypedDependency> projectiveDependencies,
TreeGraphNode root)
Used for postprocessing CoNLL X dependencies
|
UniversalEnglishGrammaticalStructure(Tree t)
Construct a new
EnglishGrammaticalStructure from an existing parse
tree. |
UniversalEnglishGrammaticalStructure(Tree t,
java.util.function.Predicate<java.lang.String> tagFilter)
This gets used by GrammaticalStructureFactory (by reflection).
|
UniversalEnglishGrammaticalStructure(Tree t,
java.util.function.Predicate<java.lang.String> tagFilter,
HeadFinder hf)
This gets used by GrammaticalStructureFactory (by reflection).
|
UniversalEnglishGrammaticalStructure(Tree t,
java.util.function.Predicate<java.lang.String> tagFilter,
HeadFinder hf,
boolean threadSafe)
Construct a new
GrammaticalStructure from an existing parse
tree. |
Modifier and Type | Method and Description |
---|---|
static UniversalEnglishGrammaticalStructure |
buildCoNLLXGrammaticalStructure(java.util.List<java.util.List<java.lang.String>> tokenFields) |
protected void |
collapseDependencies(java.util.List<TypedDependency> list,
boolean CCprocess,
GrammaticalStructure.Extras includeExtras)
Destructively modifies this
Collection<TypedDependency>
by collapsing several types of transitive pairs of dependencies or
by adding additional information from the dependents to the relation
of the governor. |
protected void |
collapseDependenciesTree(java.util.List<TypedDependency> list)
Destructively modify the
Collection<TypedDependency> to collapse
language-dependent transitive dependencies but keeping a tree structure. |
protected void |
correctDependencies(java.util.List<TypedDependency> list)
Destructively modify the
TypedDependencyGraph to correct
language-dependent dependencies. |
protected void |
correctDependencies(SemanticGraph sg) |
protected java.util.function.Predicate<TypedDependency> |
extraTreeDepFilter()
Returns a Filter which checks dependencies for usefulness as
extra tree-based dependencies.
|
protected void |
getExtras(java.util.List<TypedDependency> list)
Get extra dependencies that do not depend on the tree structure,
but rather only depend on the existing dependency structure.
|
protected void |
getTreeDeps(java.util.List<TypedDependency> deps,
DirectedMultiGraph<TreeGraphNode,GrammaticalRelation> completeGraph,
java.util.function.Predicate<TypedDependency> puncTypedDepFilter,
java.util.function.Predicate<TypedDependency> extraTreeDepFilter)
Look through the tree t and adds to the List basicDep
additional dependencies which aren't
in the List but which satisfy the filter puncTypedDepFilter.
|
protected void |
postProcessDependencies(java.util.List<TypedDependency> list)
Post process the dependencies in whatever way this language
requires.
|
static java.util.List<GrammaticalStructure> |
readCoNLLXGrammaticalStructureCollection(java.lang.String fileName) |
allTypedDependencies, buildCoNLLXGrammaticalStructure, dependenciesToCoNLLXString, dependenciesToCoNLLXString, dependenciesToString, fromStringReps, getGrammaticalRelation, getGrammaticalRelation, getRoots, isConnected, main, printDependencies, readCoNLLXGrammaticalStructureCollection, root, toString, typedDependencies, typedDependencies, typedDependencies, typedDependenciesCCprocessed, typedDependenciesCCprocessed, typedDependenciesCCprocessed, typedDependenciesCollapsed, typedDependenciesCollapsed, typedDependenciesCollapsed, typedDependenciesCollapsedTree
public UniversalEnglishGrammaticalStructure(Tree t)
EnglishGrammaticalStructure
from an existing parse
tree. The new GrammaticalStructure
has the same tree structure
and label values as the given tree (but no shared storage). As part of
construction, the parse tree is analyzed using definitions from
GrammaticalRelation
to populate
the new GrammaticalStructure
with as many labeled grammatical
relations as it can.t
- Parse tree to make grammatical structure frompublic UniversalEnglishGrammaticalStructure(Tree t, java.util.function.Predicate<java.lang.String> tagFilter)
t
- Parse tree to make grammatical structure fromtagFilter
- Filter to remove punctuation dependenciespublic UniversalEnglishGrammaticalStructure(Tree t, java.util.function.Predicate<java.lang.String> tagFilter, HeadFinder hf)
t
- Parse tree to make grammatical structure fromtagFilter
- Tag filter to remove punctuation dependencieshf
- HeadFinder to use when building itpublic UniversalEnglishGrammaticalStructure(Tree t, java.util.function.Predicate<java.lang.String> tagFilter, HeadFinder hf, boolean threadSafe)
GrammaticalStructure
from an existing parse
tree. The new GrammaticalStructure
has the same tree structure
and label values as the given tree (but no shared storage). As part of
construction, the parse tree is analyzed using definitions from
GrammaticalRelation
to populate
the new GrammaticalStructure
with as many labeled grammatical
relations as it can.t
- Parse tree to make grammatical structure fromtagFilter
- Filter for punctuation tagshf
- HeadFinder to use when building itthreadSafe
- Whether or not to support simultaneous instances among multiple
threadspublic UniversalEnglishGrammaticalStructure(java.util.List<TypedDependency> projectiveDependencies, TreeGraphNode root)
protected java.util.function.Predicate<TypedDependency> extraTreeDepFilter()
extraTreeDepFilter
in class GrammaticalStructure
protected void getTreeDeps(java.util.List<TypedDependency> deps, DirectedMultiGraph<TreeGraphNode,GrammaticalRelation> completeGraph, java.util.function.Predicate<TypedDependency> puncTypedDepFilter, java.util.function.Predicate<TypedDependency> extraTreeDepFilter)
GrammaticalStructure
getTreeDeps
in class GrammaticalStructure
deps
- The list of dependencies which may be augmentedcompleteGraph
- a graph of all the tree dependencies found earlierpuncTypedDepFilter
- The filter that may skip punctuation dependenciesextraTreeDepFilter
- Additional dependencies are added only if they pass this filterprotected void correctDependencies(java.util.List<TypedDependency> list)
GrammaticalStructure
TypedDependencyGraph
to correct
language-dependent dependencies. (e.g., nsubjpass in a relative clause)
Default is no-op; to be over-ridden in subclasses.correctDependencies
in class GrammaticalStructure
protected void correctDependencies(SemanticGraph sg)
protected void postProcessDependencies(java.util.List<TypedDependency> list)
GrammaticalStructure
postProcessDependencies
in class GrammaticalStructure
protected void getExtras(java.util.List<TypedDependency> list)
GrammaticalStructure
getExtras
in class GrammaticalStructure
protected void collapseDependencies(java.util.List<TypedDependency> list, boolean CCprocess, GrammaticalStructure.Extras includeExtras)
Collection<TypedDependency>
by collapsing several types of transitive pairs of dependencies or
by adding additional information from the dependents to the relation
of the governor.
If called with a tree of dependencies and both CCprocess and
includeExtras set to false, then the tree structure is preserved.
case(hat, in)
and nmod(in, hat)
then
the nmod
relation is enhanced to nmod:in(cat, hat)
.
The case(hat, in)
relation is preserved.case(attacking, of)
and advcl(heard, attacking)
then
the nmod
relation is enhanced to nmod:of(heard, attacking)
.
The case(attacking, of)
relation is preserved.cc(investors, and)
and
conj(investors, regulators)
, then the conj
relation is
enhanced to
conj:and(investors, regulators)
ref(man, that)
and dobj(love, that)
are collapsed
to dobj(love, man)
collapseDependencies
in class GrammaticalStructure
list
- A list of dependencies to process for possible collapsingCCprocess
- apply CC process?protected void collapseDependenciesTree(java.util.List<TypedDependency> list)
GrammaticalStructure
Collection<TypedDependency>
to collapse
language-dependent transitive dependencies but keeping a tree structure.
Default is no-op; to be over-ridden in subclasses.collapseDependenciesTree
in class GrammaticalStructure
list
- A list of dependencies to process for possible collapsingpublic static java.util.List<GrammaticalStructure> readCoNLLXGrammaticalStructureCollection(java.lang.String fileName) throws java.io.IOException
java.io.IOException
public static UniversalEnglishGrammaticalStructure buildCoNLLXGrammaticalStructure(java.util.List<java.util.List<java.lang.String>> tokenFields)