Skip to content

Commit b36d9eb

Browse files
committed
Add MWT fields to AnnotationLookup, which necessitates parsing Boolean in CoreLabel
1 parent b265c16 commit b36d9eb

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/edu/stanford/nlp/ling/AnnotationLookup.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,12 @@ private enum KeyLookup {
9393
POS_TAG_KEY(CoreAnnotations.PartOfSpeechAnnotation.class, "pos"),
9494
CPOS_TAG_KEY(CoreAnnotations.CoarseTagAnnotation.class, "cpos"),
9595
DEPREL_KEY(CoreAnnotations.CoNLLDepTypeAnnotation.class, "deprel"),
96-
HEADIDX_KEY(CoreAnnotations.CoNLLDepParentIndexAnnotation.class, "headidx");
96+
HEADIDX_KEY(CoreAnnotations.CoNLLDepParentIndexAnnotation.class, "headidx"),
9797

98+
// MWT specific annotations
99+
MWT_TEXT_KEY(CoreAnnotations.MWTTokenTextAnnotation.class, "mwt_text"),
100+
IS_MWT_KEY(CoreAnnotations.IsMultiWordTokenAnnotation.class, "is_mwt"),
101+
IS_FIRST_MWT_KEY(CoreAnnotations.IsFirstWordOfMWTAnnotation.class, "is_first_mwt");
98102

99103
private final Class<? extends CoreAnnotation<?>> coreKey;
100104
private final String oldKey;

src/edu/stanford/nlp/ling/CoreLabel.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,8 @@ private void initFromStrings(String[] keys, String[] values) {
198198
this.set(coreKeyClass, Double.parseDouble(values[i]));
199199
} else if(valueClass == Long.class) {
200200
this.set(coreKeyClass, Long.parseLong(values[i]));
201+
} else if (valueClass == Boolean.class) {
202+
this.set(coreKeyClass, Boolean.parseBoolean(values[i]));
201203
} else if (coreKeyClass == CoreAnnotations.CoNLLUFeats.class) {
202204
this.set(coreKeyClass, CoNLLUUtils.parseFeatures(values[i]));
203205
} else {
@@ -249,6 +251,8 @@ private void initFromStrings(Class[] keys, String[] values) {
249251
this.set(coreKeyClass, Double.parseDouble(values[i]));
250252
} else if (valueClass == Long.class) {
251253
this.set(coreKeyClass, Long.parseLong(values[i]));
254+
} else if (valueClass == Boolean.class) {
255+
this.set(coreKeyClass, Boolean.parseBoolean(values[i]));
252256
} else if (coreKeyClass == CoreAnnotations.CoNLLUFeats.class) {
253257
this.set(coreKeyClass, CoNLLUUtils.parseFeatures(values[i]));
254258
} else {

0 commit comments

Comments
 (0)