You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ctakes.apache.org by Alaa al Barari <al...@gmail.com> on 2017/02/06 09:26:39 UTC

jcas work with a list of schemas

Hi,

I have my own dictionary and it has a lot of schemas which takes a lot of
time. please see code below

 jcas = pipeline.newJCas();
jcas.setDocumentText(sentence.getCoveredText());
pipeline.process(jcas);
String previousEntity = "";
for ( IdentifiedAnnotation entity : JCasUtil.select( jcas,
IdentifiedAnnotation.class ) ) {

final FSArray fsArray = entity.getOntologyConceptArr();
if ( fsArray == null ) {
continue;
}
String entityString = entity.getCoveredText();
// if (!previousEntity.equals("") && previousEntity.contains(entityString)
&& !previousEntity.equals(entityString)) {
// continue;
// }
if (skipEntity(filters, entity)) {
continue;
}
System.out.println( "Entity: " + entity.getCoveredText()
+ " === Polarity: " + entity.getPolarity()
+ " === Subject: " + entity.getSubject()
+ " === History? " + (entity.getHistoryOf() ==
CONST.NE_HISTORY_OF_PRESENT));

final FeatureStructure[] featureStructures = fsArray.toArray();
final Collection<String> entityCodes = new ArrayList<>(
featureStructures.length );
previousEntity = entityString;
for ( FeatureStructure featureStructure : featureStructures ) {
if ( featureStructure instanceof UmlsConcept ) {
final UmlsConcept umlsConcept = (UmlsConcept)featureStructure;
String entityCode = umlsConcept.getCode();
String entityScheme = umlsConcept.getCodingScheme();
String description = umlsConcept.getCodeDescription();
if (entityCode == null || entityScheme == null) {
continue;
}
if (schemes.contains(entityScheme) || schemes.contains("all")) {
System.out.println(entityScheme + "_" + entityCode + "_" + description);
}
}
}

}
}

-- 
Eng Alaa Al-Barari
phone 0599297470