public class OpenIE extends java.lang.Object implements Annotator
java -mx1g -cp stanford-openie.jar:stanford-openie-models.jar edu.stanford.nlp.naturalli.OpenIE
Note that this class serves both as an entry point for the OpenIE system, but also as a CoreNLP annotator
which can be plugged into the CoreNLP pipeline (or any other annotation pipeline).annotate(Annotation)
,
main(String[])
Modifier and Type | Field and Description |
---|---|
java.util.Optional<ClauseSplitter> |
clauseSplitter
The clause splitter model, if one is to be used.
|
ForwardEntailer |
forwardEntailer
The forward entailer model, running a search from clauses to maximally shortened clauses.
|
RelationTripleSegmenter |
segmenter
The relation triple segmenter, which converts a maximally shortened clause into an OpenIE
extraction triple.
|
DEFAULT_REQUIREMENTS, STANFORD_CDC_TOKENIZE, STANFORD_CLEAN_XML, STANFORD_COLUMN_DATA_CLASSIFIER, STANFORD_COREF, STANFORD_COREF_MENTION, STANFORD_DEPENDENCIES, STANFORD_DETERMINISTIC_COREF, STANFORD_DOCDATE, STANFORD_ENTITY_MENTIONS, STANFORD_GENDER, STANFORD_KBP, STANFORD_LEMMA, STANFORD_LINK, STANFORD_MWT, STANFORD_NATLOG, STANFORD_NER, STANFORD_OPENIE, STANFORD_PARSE, STANFORD_POS, STANFORD_QUOTE, STANFORD_QUOTE_ATTRIBUTION, STANFORD_REGEXNER, STANFORD_RELATION, STANFORD_SENTIMENT, STANFORD_SSPLIT, STANFORD_TOKENIZE, STANFORD_TOKENSREGEX, STANFORD_TRUECASE, STANFORD_UD_FEATURES
Constructor and Description |
---|
OpenIE()
Create a new OpenIE system, with default properties
|
OpenIE(java.util.Properties props)
Create a ne OpenIE system, based on the given properties.
|
Modifier and Type | Method and Description |
---|---|
void |
annotate(Annotation annotation)
Given an Annotation, perform a task on this Annotation.
|
void |
annotateSentence(CoreMap sentence,
java.util.Map<CoreLabel,java.util.List<CoreLabel>> canonicalMentionMap)
Annotate a single sentence.
|
java.util.List<SentenceFragment> |
clausesInSentence(CoreMap sentence)
Find the clauses in a sentence.
|
java.util.List<SentenceFragment> |
clausesInSentence(SemanticGraph tree,
boolean assumedTruth)
Find the clauses in a sentence, where the sentence is expressed as a dependency tree.
|
java.util.List<SentenceFragment> |
entailmentsFromClause(SentenceFragment clause)
Returns all of the entailed shortened clauses (as per natural logic) from the given clause.
|
java.util.Set<SentenceFragment> |
entailmentsFromClauses(java.util.Collection<SentenceFragment> clauses)
Returns all the maximally shortened entailed fragments (as per natural logic)
from the given collection of clauses.
|
static void |
main(java.lang.String[] args)
An entry method for annotating standard in with OpenIE extractions.
|
java.util.Optional<RelationTriple> |
relationInFragment(SentenceFragment fragment)
Returns the possible relation triple in this sentence fragment.
|
java.util.List<RelationTriple> |
relationsInClause(SentenceFragment clause)
Extract the relations in this clause.
|
java.util.List<RelationTriple> |
relationsInFragments(java.util.Collection<SentenceFragment> fragments)
Returns the possible relation triple in this set of sentence fragments.
|
java.util.List<RelationTriple> |
relationsInSentence(CoreMap sentence)
Extract the relations in this sentence.
|
java.util.Set<java.lang.Class<? extends CoreAnnotation>> |
requirementsSatisfied()
Returns a set of requirements for which tasks this annotator can
provide.
|
java.util.Set<java.lang.Class<? extends CoreAnnotation>> |
requires()
Returns the set of tasks which this annotator requires in order
to perform.
|
static java.lang.String |
tripleToString(RelationTriple extraction,
java.lang.String docid,
CoreMap sentence)
Prints an OpenIE triple to a String, according to the output format requested in
the annotator.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
exactRequirements, unmount
public final java.util.Optional<ClauseSplitter> clauseSplitter
public final ForwardEntailer forwardEntailer
public RelationTripleSegmenter segmenter
public OpenIE()
public OpenIE(java.util.Properties props)
props
- The properties to parametrize the system with.public java.util.List<SentenceFragment> clausesInSentence(SemanticGraph tree, boolean assumedTruth)
tree
- The dependency tree representation of the sentence.assumedTruth
- The assumed truth of the sentence. This is almost always true, unless you are
doing some more nuanced reasoning.public java.util.List<SentenceFragment> clausesInSentence(CoreMap sentence)
sentence
- The raw sentence to extract clauses from.clausesInSentence(SemanticGraph, boolean)
public java.util.List<SentenceFragment> entailmentsFromClause(SentenceFragment clause)
clausesInSentence(CoreMap)
.clause
- The premise clause, as a sentence fragment in itself.public java.util.Set<SentenceFragment> entailmentsFromClauses(java.util.Collection<SentenceFragment> clauses)
clauses
- The clauses to shorten further.public java.util.Optional<RelationTriple> relationInFragment(SentenceFragment fragment)
public java.util.List<RelationTriple> relationsInFragments(java.util.Collection<SentenceFragment> fragments)
public java.util.List<RelationTriple> relationsInClause(SentenceFragment clause)
public java.util.List<RelationTriple> relationsInSentence(CoreMap sentence)
public void annotateSentence(CoreMap sentence, java.util.Map<CoreLabel,java.util.List<CoreLabel>> canonicalMentionMap)
NaturalLogicAnnotations.EntailedSentencesAnnotation
and
NaturalLogicAnnotations.RelationTriplesAnnotation
annotations.
public void annotate(Annotation annotation)
NaturalLogicAnnotations.EntailedSentencesAnnotation
and NaturalLogicAnnotations.RelationTriplesAnnotation
annotations.public java.util.Set<java.lang.Class<? extends CoreAnnotation>> requirementsSatisfied()
requirementsSatisfied
in interface Annotator
public java.util.Set<java.lang.Class<? extends CoreAnnotation>> requires()
public static java.lang.String tripleToString(RelationTriple extraction, java.lang.String docid, CoreMap sentence)
extraction
- The triple to write.docid
- The document ID (for the ReVerb format)sentence
- The sentence the triple was extracted from (for the ReVerb format)public static void main(java.lang.String[] args) throws java.io.IOException, java.lang.InterruptedException
java.io.IOException
java.lang.InterruptedException