public class TimeAnnotator extends Object implements Annotator
SUTime.
The expressions recognized by SUTime are loosely based on GUTIME.
After annotation, the TimeAnnotations.TimexAnnotations annotation
will be populated with a List<CoreMap>, each of which
will represent one temporal expression.
If a reference time is set (via CoreAnnotations.DocDateAnnotation),
then temporal expressions are resolved with respect to the document date. You set it on an
Annotation as follows:
annotation.set(CoreAnnotations.DocDateAnnotation.class, "2013-07-14");
Input annotations
| Annotation | Type | Description | Required? |
|---|---|---|---|
CoreAnnotations.DocDateAnnotation |
String |
If present, then the string is interpreted as a date/time and used as the reference document date with respect to which other temporal expressions are resolved | Optional |
CoreAnnotations.SentencesAnnotation |
List<CoreMap> |
If present, time expressions will be extracted from each sentence and each sentence will be annotated individually. | Optional (good to have) |
CoreAnnotations.TokensAnnotation |
List<CoreLabel> |
Tokens (for each sentence or for entire annotation if no sentences) | Required |
CoreAnnotations.TextAnnotation |
String |
Text (for each sentence or for entire annotation if no sentences) | Optional |
CoreAnnotations.TextAnnotation |
String |
Token text (normalized) | Required |
CoreAnnotations.OriginalTextAnnotation |
String |
Token text (original) | Required |
CoreAnnotations.CharacterOffsetBeginAnnotation |
Integer |
The index of the first character of this token (0-based wrt to TextAnnotation of the annotation containing the TokensAnnotation). | Required |
CoreAnnotations.CharacterOffsetEndAnnotation |
Integer |
The index of the first character after this token (0-based wrt to TextAnnotation of the annotation containing the TokensAnnotation). | Required |
CoreAnnotations.PartOfSpeechAnnotation |
String |
Token part of speech | Optional |
Output annotations
| Annotation | Type | Description |
|---|---|---|
TimeAnnotations.TimexAnnotations |
List<CoreMap> |
List of temporal expressions (on the entire annotation and also for each sentence) |
TimeAnnotations.TimexAnnotation |
Timex |
Timex object with TIMEX3 XML attributes, use for exporting TIMEX3 information |
TimeExpression.Annotation |
TimeExpression |
TimeExpression object. Use getTemporal() to get internal temporal representation. |
TimeExpression.ChildrenAnnotation |
List<CoreMap> |
List of chunks forming this time expression (inner chunks can be tokens, nested time expressions, numeric expressions, etc) |
CoreAnnotations.TextAnnotation |
String |
Text of this time expression |
CoreAnnotations.TokensAnnotation |
List<CoreLabel> |
Tokens that make up this time expression |
CoreAnnotations.CharacterOffsetBeginAnnotation |
Integer |
The index of the first character of this token (0-based). |
CoreAnnotations.CharacterOffsetEndAnnotation |
Integer |
The index of the first character after this token (0-based). |
CoreAnnotations.TokenBeginAnnotation |
Integer |
The index of the first token of this time expression (0-based). |
CoreAnnotations.TokenEndAnnotation |
Integer |
The index of the first token after this time expression (0-based). |
Annotator.RequirementBINARIZED_TREES_REQUIREMENT, CLEAN_XML_REQUIREMENT, DETERMINISTIC_COREF_REQUIREMENT, GENDER_REQUIREMENT, GUTIME_REQUIREMENT, HEIDELTIME_REQUIREMENT, LEMMA_REQUIREMENT, NER_REQUIREMENT, NUMBER_REQUIREMENT, PARSE_AND_TAG, PARSE_REQUIREMENT, PARSE_TAG_BINARIZED_TREES, POS_REQUIREMENT, QUANTIFIABLE_ENTITY_NORMALIZATION_REQUIREMENT, RELATION_EXTRACTOR_REQUIREMENT, SSPLIT_REQUIREMENT, STANFORD_CLEAN_XML, STANFORD_DETERMINISTIC_COREF, STANFORD_GENDER, STANFORD_LEMMA, STANFORD_NER, STANFORD_PARSE, STANFORD_POS, STANFORD_REGEXNER, STANFORD_RELATION, STANFORD_SENTIMENT, STANFORD_SSPLIT, STANFORD_TOKENIZE, STANFORD_TRUECASE, STEM_REQUIREMENT, SUTIME_REQUIREMENT, TIME_WORDS_REQUIREMENT, TOKENIZE_AND_SSPLIT, TOKENIZE_REQUIREMENT, TOKENIZE_SSPLIT_NER, TOKENIZE_SSPLIT_PARSE, TOKENIZE_SSPLIT_PARSE_NER, TOKENIZE_SSPLIT_POS, TOKENIZE_SSPLIT_POS_LEMMA, TRUECASE_REQUIREMENT| Constructor and Description |
|---|
TimeAnnotator() |
TimeAnnotator(boolean quiet) |
TimeAnnotator(String name,
Properties props) |
| Modifier and Type | Method and Description |
|---|---|
void |
annotate(Annotation annotation)
Given an Annotation, perform a task on this Annotation.
|
List<CoreMap> |
annotateSingleSentence(CoreMap sentence,
String docDate,
SUTime.TimeIndex timeIndex)
Helper method for people not working from a complete Annotation.
|
Set<Annotator.Requirement> |
requirementsSatisfied()
Returns a set of requirements for which tasks this annotator can
provide.
|
Set<Annotator.Requirement> |
requires()
Returns the set of tasks which this annotator requires in order
to perform.
|
public TimeAnnotator()
public TimeAnnotator(boolean quiet)
public TimeAnnotator(String name, Properties props)
public void annotate(Annotation annotation)
Annotatorpublic List<CoreMap> annotateSingleSentence(CoreMap sentence, String docDate, SUTime.TimeIndex timeIndex)
public Set<Annotator.Requirement> requires()
Annotatorpublic Set<Annotator.Requirement> requirementsSatisfied()
AnnotatorrequirementsSatisfied in interface Annotator