public class AnnotationUtils
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static void |
addEntityMention(CoreMap sentence,
EntityMention arg) |
static void |
addEntityMentions(CoreMap sentence,
java.util.Collection<EntityMention> args) |
static void |
addEventMention(CoreMap sentence,
EventMention arg) |
static void |
addEventMentions(CoreMap sentence,
java.util.Collection<EventMention> args) |
static void |
addRelationMention(CoreMap sentence,
RelationMention arg) |
static void |
addRelationMentions(CoreMap sentence,
java.util.Collection<RelationMention> args) |
static void |
addSentence(CoreMap dataset,
CoreMap sentence) |
static void |
addSentences(CoreMap dataset,
java.util.List<CoreMap> sentences) |
static Annotation |
createDataset(java.util.List<CoreMap> sentences)
Given a list of sentences (as CoreMaps), wrap it in a new Annotation.
|
static java.lang.String |
datasetToString(CoreMap dataset) |
static Annotation |
deepMentionCopy(CoreMap dataset)
Creates a deep copy of the given dataset with new lists for all mentions (entity, relation, event)
|
static java.util.List<java.util.List<CoreLabel>> |
entityMentionsToCoreLabels(CoreMap dataset,
java.util.Set<java.lang.String> annotationsToSkip,
boolean useSubTypes,
boolean useBIO)
Converts the labels of all entity mentions in this dataset to sequences of CoreLabels.
|
static java.lang.String |
excelify(java.lang.String s)
Process string to be a cell in Excel file.
|
static java.util.List<RelationMention> |
getAllRelations(RelationMentionFactory factory,
CoreMap sentence,
boolean createUnrelatedRelations)
Get list of all relations and non-relations between EntityMentions in this sentence
Use with care.
|
static java.util.List<RelationMention> |
getAllUnrelatedRelations(RelationMentionFactory factory,
CoreMap sentence,
boolean checkExisting) |
static java.util.List<EntityMention> |
getEntityMentions(CoreMap sent) |
static java.util.List<EventMention> |
getEventMentions(CoreMap sent) |
static RelationMention |
getRelation(RelationMentionFactory factory,
CoreMap sentence,
ExtractionObject... args)
Return the relation that holds between the given entities.
|
static java.util.List<RelationMention> |
getRelationMentions(CoreMap sent) |
static java.util.List<RelationMention> |
getRelations(RelationMentionFactory factory,
CoreMap sentence,
ExtractionObject... args)
Return all the relations that holds between the given entities.
|
static CoreMap |
getSentence(CoreMap dataset,
int i) |
static java.lang.String |
getTextContent(CoreMap sent,
Span span)
Fetches the sentence text in a given token span
|
static java.lang.String |
prettify(java.lang.String s)
Prepare a string for printing in a spreadsheet for Mechanical Turk input.
|
static java.util.List<CoreMap> |
readSentencesFromFile(java.lang.String path) |
static int |
sentenceCount(CoreMap dataset) |
static Annotation |
sentenceDeepMentionCopy(Annotation sentence)
Deep copy of the sentence: we create new entity/relation/event lists here.
|
static java.util.List<CoreLabel> |
sentenceEntityMentionsToCoreLabels(CoreMap sentence,
boolean addAnswerAnnotation,
java.util.Set<java.lang.String> annotationsToSkip,
java.util.Set<java.lang.String> mentionTypesToUse,
boolean useSubTypes,
boolean useBIO)
Converts the labels of all entity mentions in this sentence to sequences of CoreLabels.
|
static java.lang.String |
sentenceToString(CoreMap sent) |
static void |
shuffleSentences(CoreMap dataset)
Randomized shuffle of all sentences int this dataset
|
static java.lang.String |
tokensAndNELabelsToString(CoreMap sentence) |
static java.lang.String |
tokensToString(java.util.List<CoreLabel> tokens) |
static void |
updateOffsets(java.util.List<Word> tokens,
int offset) |
static void |
updateOffsetsInCoreLabels(java.util.List<CoreLabel> tokens,
int offset) |
public static Annotation createDataset(java.util.List<CoreMap> sentences)
public static void shuffleSentences(CoreMap dataset)
dataset
- public static java.util.List<java.util.List<CoreLabel>> entityMentionsToCoreLabels(CoreMap dataset, java.util.Set<java.lang.String> annotationsToSkip, boolean useSubTypes, boolean useBIO)
dataset
- annotationsToSkip
- useSubTypes
- public static java.util.List<CoreLabel> sentenceEntityMentionsToCoreLabels(CoreMap sentence, boolean addAnswerAnnotation, java.util.Set<java.lang.String> annotationsToSkip, java.util.Set<java.lang.String> mentionTypesToUse, boolean useSubTypes, boolean useBIO)
sentence
- addAnswerAnnotation
- annotationsToSkip
- useSubTypes
- public static int sentenceCount(CoreMap dataset)
public static Annotation deepMentionCopy(CoreMap dataset)
dataset
- public static Annotation sentenceDeepMentionCopy(Annotation sentence)
sentence
- public static RelationMention getRelation(RelationMentionFactory factory, CoreMap sentence, ExtractionObject... args)
public static java.util.List<RelationMention> getRelations(RelationMentionFactory factory, CoreMap sentence, ExtractionObject... args)
public static java.util.List<RelationMention> getAllRelations(RelationMentionFactory factory, CoreMap sentence, boolean createUnrelatedRelations)
public static java.util.List<RelationMention> getAllUnrelatedRelations(RelationMentionFactory factory, CoreMap sentence, boolean checkExisting)
public static void addEntityMention(CoreMap sentence, EntityMention arg)
public static void addEntityMentions(CoreMap sentence, java.util.Collection<EntityMention> args)
public static java.util.List<EntityMention> getEntityMentions(CoreMap sent)
public static void addRelationMention(CoreMap sentence, RelationMention arg)
public static void addRelationMentions(CoreMap sentence, java.util.Collection<RelationMention> args)
public static java.util.List<RelationMention> getRelationMentions(CoreMap sent)
public static void addEventMention(CoreMap sentence, EventMention arg)
public static void addEventMentions(CoreMap sentence, java.util.Collection<EventMention> args)
public static java.util.List<EventMention> getEventMentions(CoreMap sent)
public static java.lang.String prettify(java.lang.String s)
s
- String to be formattedpublic static java.lang.String getTextContent(CoreMap sent, Span span)
span
- public static java.lang.String sentenceToString(CoreMap sent)
public static java.lang.String tokensAndNELabelsToString(CoreMap sentence)
public static java.lang.String datasetToString(CoreMap dataset)
public static java.lang.String tokensToString(java.util.List<CoreLabel> tokens)
public static void updateOffsets(java.util.List<Word> tokens, int offset)
public static void updateOffsetsInCoreLabels(java.util.List<CoreLabel> tokens, int offset)
public static java.lang.String excelify(java.lang.String s)
public static java.util.List<CoreMap> readSentencesFromFile(java.lang.String path) throws java.io.IOException, java.lang.ClassNotFoundException
java.io.IOException
java.lang.ClassNotFoundException