|Modifier and Type||Class and Description|
Enum to identify the different TokenizerTypes.
|Modifier and Type||Method and Description|
Given sentences or trees, output the typed dependencies.
Returns a dependency tree in CoNNL-X format.
Calls dependenciesToCoNLLXString with the basic dependencies from a grammatical structure.
Print typed dependencies in either the Stanford dependency representation or in the conllx format.
public static void printDependencies(GrammaticalStructure gs, Collection<TypedDependency> deps, Tree tree, boolean conllx, boolean extraSep, boolean convertToUPOS)
deps- Typed dependencies to print
tree- Tree corresponding to typed dependencies (only necessary if conllx == true)
conllx- If true use conllx format, otherwise use Stanford representation
extraSep- If true, in the Stanford representation, the extra dependencies (which do not preserve the tree structure) are printed after the basic dependencies
convertToUPOS- If true convert the POS tags to universal POS tags and output them along the original POS tags.
public static String dependenciesToCoNLLXString(GrammaticalStructure gs, CoreMap sentence)
public static String dependenciesToCoNLLXString(Collection<TypedDependency> deps, CoreMap sentence)
deps- The list of TypedDependency relations.
sentence- The corresponding CoreMap for the sentence.
public static String dependenciesToString(GrammaticalStructure gs, Collection<TypedDependency> deps, Tree tree, boolean conllx, boolean extraSep, boolean convertToUPOS)
By default, the method outputs the collapsed typed dependencies with processing of conjuncts. The input can be given as plain text (one sentence by line) using the option -sentFile, or as trees using the option -treeFile. For -sentFile, the input has to be strictly one sentence per line. You can specify where to find a parser with -parserFile serializedParserPath. See LexicalizedParser for more flexible processing of text files (including with Stanford Dependencies output). The above options assume a file as input. You can also feed trees (only) via stdin by using the option -filter. If one does not specify a -parserFile, one can specify which language pack to use with -tLPP, This option specifies a class which determines which GrammaticalStructure to use, which HeadFinder to use, etc. It will default to edu.stanford.nlp.parser.lexparser.EnglishTreebankParserParams, but any TreebankLangParserParams can be specified.
If no method of producing trees is given other than to use the LexicalizedParser, but no parser is specified, a default parser is used, the English parser. You can specify options to load with the parser using the -parserOpts flag. If the default parser is used, and no options are provided, the option -retainTmpSubcategories is used.
The following options can be used to specify the types of dependencies wanted:
-conllx option will output the dependencies in the CoNLL format,
instead of in the standard Stanford format (relation(governor,dependent))
and will retain punctuation by default.
When used in the "collapsed" format, words such as prepositions, conjunctions
which get collapsed into the grammatical relations and are not part of the
sentence per se anymore will be annotated with "erased" as grammatical relation
and attached to the fake "ROOT" node with index 0.
There is also an option to retain dependencies involving punctuation:
-extraSep option used with -nonCollapsed will print the basic
dependencies first, then a separator ======, and then the extra
dependencies that do not preserve the tree structure. The -test option is
used for debugging: it prints the grammatical structure, as well as the
basic, collapsed and CCprocessed dependencies. It also checks the
connectivity of the collapsed dependencies. If the collapsed dependencies
list doesn't constitute a connected graph, it prints the possible offending
nodes (one of them is the real root of the graph).
Using the -conllxFile, you can pass a file containing Stanford dependencies in the CoNLL format (e.g., the basic dependencies), and obtain another representation using one of the representation options.
java edu.stanford.nlp.trees.GrammaticalStructure [-treeFile FILE | -sentFile FILE | -conllxFile FILE | -filter]
[-collapsed -basic -CCprocessed -test -generateOriginalDependencies]
args- Command-line arguments, as above
Stanford NLP Group