Token next = t.getNAfter(1);
Token prevPrev = t.getNAfter(-2);
if(prev.getValue().equals("(") && next.getValue().endsWith(")")) {
//boolean matched = false;
if(endToNe.containsKey(prevPrev.getEnd())) {
NamedEntity acronymOf = endToNe.get(prevPrev.getEnd());
if(StringTools.testForAcronym(ne.getSurface(), acronymOf.getSurface())) {
//System.out.println(ne.getSurface() + " is " + acronymOf.getSurface());
if(acronymOf.getType().equals(NETypes.ASE) || acronymOf.getType().equals(NETypes.ASES)) {
//System.out.println("Skip ASE acronym");
} else {
//matched = true;
if (acroMap.containsKey(ne.getSurface())) {
String newValue = ne.getType();
String oldValue = acroMap.get(ne.getSurface());
if (newValue == NETypes.POLYMER) acroMap.put(ne.getSurface(), acronymOf.getType());
else if (newValue == NETypes.COMPOUND && !oldValue.equals(NETypes.POLYMER)) acroMap.put(ne.getSurface(), acronymOf.getType());
}
else {
acroMap.put(ne.getSurface(), acronymOf.getType());
}
}
}
}
}
}
/*int index = neList.indexOf(ne);
if(index == 0) continue;
NamedEntity previous = neList.get(index-1);
int prevEnd = previous.getEnd();
String inBetween = text.substring(prevEnd, start);
try {
String afterWards = text.substring(end);
if(afterWards != null && afterWards.length() > 0 &&
inBetween.matches("\\s*\\(\\s*") &&
afterWards.startsWith(")") &&
StringTools.testForAcronym(ne.getSurface(), previous.getSurface())) {
System.out.println(ne.getSurface() + " is " + previous.getSurface());
if(previous.getType(this).equals(NETypes.ASE) || previous.getType(this).equals(NETypes.ASES)) {
System.out.println("Skip ASE acronym");
} else {
acroMap.put(ne.getSurface(), previous.getType(this));
}
}
} catch (Exception ex) {
ex.printStackTrace();
}*/
}
}
stopNeList = new ArrayList<NamedEntity>();
int i = 0;
while(i < neList.size()) {
NamedEntity ne = neList.get(i);
if(ne.getType().equals(NETypes.POTENTIALACRONYM)) {
if(acroMap.containsKey(ne.getSurface())) {
ne.setType(acroMap.get(ne.getSurface()));
i++;
} else {
neList.remove(i);
}
} else if(ne.getType().equals(NETypes.STOP)) {
//System.out.println("STOP: " + neList.get(i).getSurface());
neList.remove(i);
stopNeList.add(ne);
} else {
i++;