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