public final class IOHelpers
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
annotationsRegExp
Regexpr matching all annotations attached to node
|
private static java.lang.String |
idRegExp
Regexpr matching id
|
private static java.lang.String |
simpleValueRegExp
Regexpr matching annotation value
|
Modifier | Constructor and Description |
---|---|
private |
IOHelpers() |
Modifier and Type | Method and Description |
---|---|
private static java.lang.String[] |
find(java.lang.String regExp,
java.lang.String negativeRegExp,
java.lang.String... annotations)
Find
|
private static java.util.List<java.lang.String> |
findAnnotationValues(java.lang.String annotationName,
java.lang.String... annotations)
Find annotation values
|
private static int |
indexLeaves(edu.stanford.nlp.trees.TreeGraphNode node,
int startIndex0)
Helper (private function) Assign sequential integer indices to the leaves of the subtree rooted at this
TreeGraphNode , beginning with
startIndex , and traversing the leaves from left to right. |
private static int |
indexLeaves(edu.stanford.nlp.trees.Tree node,
int startIndex0,
java.util.Map<edu.stanford.nlp.trees.Tree,java.lang.Integer> indices)
Helper (private function) Assign sequential integer indices to the leaves of the subtree rooted at this
Tree , beginning with
startIndex , and traversing the leaves from left to right. |
static void |
indexNodes(edu.stanford.nlp.trees.TreeGraphNode node)
Assign sequential integer indices (starting with 0) to all nodes of the subtree rooted at this
TreeGraphNode . |
private static int |
indexNodes(edu.stanford.nlp.trees.TreeGraphNode node,
int startIndex0)
Assign sequential integer indices to all nodes of the subtree rooted at this
TreeGraphNode , beginning with startIndex , and
doing a pre-order tree traversal. |
private static int |
indexNodes(edu.stanford.nlp.trees.Tree node,
int startIndex0,
java.util.Map<edu.stanford.nlp.trees.Tree,java.lang.Integer> indices)
Assign sequential integer indices to all nodes of the subtree rooted at this
TreeGraphNode , beginning with startIndex , and
doing a pre-order tree traversal. |
static void |
indexNodes(edu.stanford.nlp.trees.Tree node,
java.util.Map<edu.stanford.nlp.trees.Tree,java.lang.Integer> indices)
Assign sequential integer indices (starting with 0) to all nodes of the subtree rooted at this
TreeGraphNode . |
static void |
main(java.lang.String[] args)
Test
|
(package private) static java.lang.String[] |
makeAllAnnotations(java.lang.String... annotations)
Extract all annotations
|
static java.util.Map<java.lang.String,java.lang.String> |
makeNodeAnnotations(java.lang.String... annotations)
Extract node annotations
|
private static java.util.List<java.lang.String> |
makePoses(java.lang.String... annotations)
Make parts-of-speech
|
static java.util.List<edu.stanford.nlp.trees.TypedDependency> |
makeProjectiveDependencies(java.lang.String str)
Make projective dependencies
|
private static java.util.List<java.lang.String> |
makeTokens(java.lang.String... annotations)
Make tokens
|
private static java.lang.String[] |
makeWordAnnotations(java.lang.String... annotations)
Extract words
|
(package private) static java.lang.String |
nameValuesToString(java.lang.String[][] nameValues)
Array of name values to String
|
static java.lang.String |
stripAnnotations(java.lang.String annotationString)
Strip annotation string
|
private static final java.lang.String idRegExp
private static final java.lang.String simpleValueRegExp
private static final java.lang.String annotationsRegExp
private static java.lang.String[] find(java.lang.String regExp, java.lang.String negativeRegExp, java.lang.String... annotations)
regExp
- positive regexprnegativeRegExp
- negative regexprannotations
- annotation source stringsprivate static java.util.List<java.lang.String> findAnnotationValues(java.lang.String annotationName, java.lang.String... annotations)
annotationName
- annotation nameannotations
- annotation source stringspublic static java.util.Map<java.lang.String,java.lang.String> makeNodeAnnotations(java.lang.String... annotations)
annotations
- annotation source stringstatic java.lang.String[] makeAllAnnotations(java.lang.String... annotations)
annotations
- annotation source stringsprivate static java.lang.String[] makeWordAnnotations(java.lang.String... annotations)
annotations
- annotation source stringprivate static java.util.List<java.lang.String> makeTokens(java.lang.String... annotations)
annotations
- annotation stringprivate static java.util.List<java.lang.String> makePoses(java.lang.String... annotations)
annotations
- annotation stringpublic static java.util.List<edu.stanford.nlp.trees.TypedDependency> makeProjectiveDependencies(java.lang.String str)
str
- source string for typed dependenciesprivate static int indexLeaves(edu.stanford.nlp.trees.Tree node, int startIndex0, java.util.Map<edu.stanford.nlp.trees.Tree,java.lang.Integer> indices)
Tree
, beginning with
startIndex
, and traversing the leaves from left to right. If node is already indexed, then it uses the existing index.node
- nodestartIndex0
- index for this nodeindices
- index mapprivate static int indexNodes(edu.stanford.nlp.trees.Tree node, int startIndex0, java.util.Map<edu.stanford.nlp.trees.Tree,java.lang.Integer> indices)
TreeGraphNode
, beginning with startIndex
, and
doing a pre-order tree traversal. Any node which already has an index will not be re-indexed — this is so that we can index the leaves first, and
then index the rest.node
- nodestartIndex0
- index for this nodeindices
- index mappublic static void indexNodes(edu.stanford.nlp.trees.Tree node, java.util.Map<edu.stanford.nlp.trees.Tree,java.lang.Integer> indices)
TreeGraphNode
. The leaves are indexed first,
from left to right. Then the internal nodes are indexed, using a pre-order tree traversal.node
- nodeindices
- index mapprivate static int indexLeaves(edu.stanford.nlp.trees.TreeGraphNode node, int startIndex0)
TreeGraphNode
, beginning with
startIndex
, and traversing the leaves from left to right. If node is already indexed, then it uses the existing index.node
- nodestartIndex0
- index for this nodepublic static void indexNodes(edu.stanford.nlp.trees.TreeGraphNode node)
TreeGraphNode
. The leaves are indexed first,
from left to right. Then the internal nodes are indexed, using a pre-order tree traversal.node
- nodeprivate static int indexNodes(edu.stanford.nlp.trees.TreeGraphNode node, int startIndex0)
TreeGraphNode
, beginning with startIndex
, and
doing a pre-order tree traversal. Any node which already has an index will not be re-indexed — this is so that we can index the leaves first, and
then index the rest.node
- nodestartIndex0
- index for this nodepublic static java.lang.String stripAnnotations(java.lang.String annotationString)
annotationString
- annotation stringstatic java.lang.String nameValuesToString(java.lang.String[][] nameValues)
nameValues
- name-value arraypublic static void main(java.lang.String[] args)
args
- unused