use of org.apache.stanbol.enhancer.nlp.model.SpanTypeEnum in project stanbol by apache.
the class CorefFeatureSupport method parse.
@Override
public CorefFeature parse(ObjectNode jCoref, AnalysedText at) {
JsonNode jIsRepresentative = jCoref.path(IS_REPRESENTATIVE_TAG);
if (!jIsRepresentative.isBoolean()) {
throw new IllegalStateException("Field 'isRepresentative' must have a true/false format");
}
JsonNode node = jCoref.path(MENTIONS_TAG);
Set<Span> mentions = new HashSet<Span>();
if (node.isArray()) {
ArrayNode jMentions = (ArrayNode) node;
for (int i = 0; i < jMentions.size(); i++) {
JsonNode member = jMentions.get(i);
if (member.isObject()) {
ObjectNode jMention = (ObjectNode) member;
SpanTypeEnum spanType = SpanTypeEnum.valueOf(jMention.path(MENTION_TYPE_TAG).getTextValue());
int spanStart = jMention.path(MENTION_START_TAG).asInt();
int spanEnd = jMention.path(MENTION_END_TAG).asInt();
Span mentionedSpan = null;
switch(spanType) {
case Chunk:
mentionedSpan = at.addChunk(spanStart, spanEnd);
break;
case Sentence:
case Text:
case TextSection:
break;
case Token:
mentionedSpan = at.addToken(spanStart, spanEnd);
break;
}
mentions.add(mentionedSpan);
}
}
}
return new CorefFeature(jIsRepresentative.asBoolean(), mentions);
}
Aggregations