You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ctakes.apache.org by cl...@apache.org on 2018/02/22 20:34:30 UTC
svn commit: r1825098 -
/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/THYMEQAAnaforaXMLReader.java
Author: clin
Date: Thu Feb 22 20:34:29 2018
New Revision: 1825098
URL: http://svn.apache.org/viewvc?rev=1825098&view=rev
Log:
Fix a bug in THYME QA xml reader
Modified:
ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/THYMEQAAnaforaXMLReader.java
Modified: ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/THYMEQAAnaforaXMLReader.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/THYMEQAAnaforaXMLReader.java?rev=1825098&r1=1825097&r2=1825098&view=diff
==============================================================================
--- ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/THYMEQAAnaforaXMLReader.java (original)
+++ ctakes/trunk/ctakes-temporal/src/main/java/org/apache/ctakes/temporal/ae/THYMEQAAnaforaXMLReader.java Thu Feb 22 20:34:29 2018
@@ -111,6 +111,7 @@ public class THYMEQAAnaforaXMLReader ext
// TODO -- need mapping from id to relation
Map<String, Annotation> idToAnnotation = Maps.newHashMap();
+ Map<String, BinaryTextRelation> idToRelation = Maps.newHashMap();
for (Element entityElem : annotationsElem.getChildren("entity")) {
String id = removeSingleChildText(entityElem, "id", null);
Element spanElem = removeSingleChild(entityElem, "span", id);
@@ -214,6 +215,7 @@ public class THYMEQAAnaforaXMLReader ext
TemporalTextRelation relation = new TemporalTextRelation(jCas);
relation.setId(curRelId++);
addRelation(jCas, relation, sourceID, targetID, tlinkType, idToAnnotation, id);
+ idToRelation.put(id, relation);
} else if (type.equals("ALINK")) {
String sourceID = removeSingleChildText(propertiesElem, "Source", id);
@@ -221,6 +223,7 @@ public class THYMEQAAnaforaXMLReader ext
String alinkType = removeSingleChildText(propertiesElem, "Type", id);
AspectualTextRelation relation = new AspectualTextRelation(jCas);
addRelation(jCas, relation, sourceID, targetID, alinkType, idToAnnotation, id);
+ idToRelation.put(id, relation);
} else if (type.equals("Question")){
String questionText = removeSingleChildText(propertiesElem, "Question", id);
@@ -260,6 +263,12 @@ public class THYMEQAAnaforaXMLReader ext
List<TOP> answerList = new ArrayList<>();
for(String id : questionRelations.get(question)){
TOP answer = idToAnnotation.get(id);
+ if(answer == null){
+ answer = idToRelation.get(id);
+ if(answer == null){
+ LOGGER.error("cannot find answer for id: " + id);
+ }
+ }
answerList.add(answer);
}
qaRel.setMembers(ListFactory.buildList(jCas, answerList));