public class Util
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.util.Set<java.lang.String> |
PRIVATIVE_ADJECTIVES
The dictionary of privative adjectives, as per http://hci.stanford.edu/cstr/reports/2014-04.pdf
|
Constructor and Description |
---|
Util() |
Modifier and Type | Method and Description |
---|---|
static void |
annotate(CoreMap sentence,
AnnotationPipeline pipeline)
TODO(gabor) JavaDoc
|
static java.util.List<SemanticGraphEdge> |
cleanTree(SemanticGraph tree,
SemanticGraph originalTree)
Fix some bizarre peculiarities with certain trees.
|
static void |
dumpAccuracy(Classifier<ClauseSplitter.ClauseClassifierLabel,java.lang.String> classifier,
GeneralDataset<ClauseSplitter.ClauseClassifierLabel,java.lang.String> dataset)
A helper function for dumping the accuracy of the trained classifier.
|
static Span |
extractNER(java.util.List<CoreLabel> tokens,
Span seed)
Returns a coherent NER span from a list of tokens.
|
static java.lang.String |
guessNER(java.util.List<CoreLabel> tokens)
TODO(gabor) JavaDoc
|
static java.lang.String |
guessNER(java.util.List<CoreLabel> tokens,
Span span)
TODO(gabor) JavaDoc
|
static boolean |
isCyclic(SemanticGraph tree)
Determine if a tree is cyclic.
|
static boolean |
isTree(SemanticGraph tree)
A little utility function to make sure a SemanticGraph is a tree.
|
static boolean |
nerOverlap(java.util.List<CoreLabel> tokens,
Span a,
Span b) |
static boolean |
nerOverlap(java.util.List<CoreLabel> tokens,
Span a,
Span b,
java.util.Optional<SemanticGraph> parse)
Returns true if the given two spans denote the same consistent NER chunk.
|
static void |
stripPrepCases(SemanticGraph tree,
SemanticGraph originalTree)
Strip away case edges, if the incoming edge is a preposition.
|
static Span |
tokensToSpan(java.util.List<? extends HasIndex> tokens)
Construct the spanning span of the given list of tokens.
|
static boolean |
verifyRemoval(SemanticGraph tree,
java.util.Collection<SemanticGraphEdge> removeEdges,
SemanticGraphEdge toKeep,
IndexedWord dependent)
Verify that when removing edges from the graph, the graph is not disconnected after the removal.
|
public static final java.util.Set<java.lang.String> PRIVATIVE_ADJECTIVES
public static java.lang.String guessNER(java.util.List<CoreLabel> tokens, Span span)
tokens
- span
- public static java.lang.String guessNER(java.util.List<CoreLabel> tokens)
tokens
- public static Span extractNER(java.util.List<CoreLabel> tokens, Span seed)
tokens
- The tokens of the entire sentence.seed
- The seed span of the intended NER span that should be expanded.public static void annotate(CoreMap sentence, AnnotationPipeline pipeline)
sentence
- pipeline
- public static boolean verifyRemoval(SemanticGraph tree, java.util.Collection<SemanticGraphEdge> removeEdges, SemanticGraphEdge toKeep, IndexedWord dependent)
public static java.util.List<SemanticGraphEdge> cleanTree(SemanticGraph tree, SemanticGraph originalTree)
tree
- The tree to clean (in place!).public static void stripPrepCases(SemanticGraph tree, SemanticGraph originalTree)
tree
- The tree to modify in place.public static boolean isCyclic(SemanticGraph tree)
tree
- The tree to check.public static boolean isTree(SemanticGraph tree)
tree
- The tree to check.SemanticGraph
is a tree (versus a DAG, or Graph).public static boolean nerOverlap(java.util.List<CoreLabel> tokens, Span a, Span b, java.util.Optional<SemanticGraph> parse)
extractNER(List, Span)
on these two spans, they would return the same span.tokens
- The tokens in the sentence.a
- The first span.b
- The second span.parse
- The parse tree to traverse looking for coreference chains to exploit.public static boolean nerOverlap(java.util.List<CoreLabel> tokens, Span a, Span b)
nerOverlap(List, Span, Span, Optional)
public static void dumpAccuracy(Classifier<ClauseSplitter.ClauseClassifierLabel,java.lang.String> classifier, GeneralDataset<ClauseSplitter.ClauseClassifierLabel,java.lang.String> dataset)
classifier
- The classifier to evaluate.dataset
- The dataset to evaluate the classifier on.