value = Integer.toString(annotation.getId()); } else if (property == CTAKESAnnotationProperty.ONTOLOGY_CONCEPT_ARR) { FSArray mentions = annotation.getOntologyConceptArr(); StringBuilder sb = new StringBuilder(); if (mentions != null) {
@Override public boolean filter(Annotation anno) { if (!(anno instanceof IdentifiedAnnotation)) return false; IdentifiedAnnotation ia = (IdentifiedAnnotation) anno; return ia.getOntologyConceptArr() != null && ia.getOntologyConceptArr().size() > 0; }
@Override public boolean filter(Annotation anno) { if (!(anno instanceof IdentifiedAnnotation)) return false; IdentifiedAnnotation ia = (IdentifiedAnnotation) anno; return ia.getOntologyConceptArr() != null && ia.getOntologyConceptArr().size() > 0; }
public static boolean alias(IdentifiedAnnotation a1, IdentifiedAnnotation a2){ if(a1 != null && a2 != null){ for(UmlsConcept concept1 : JCasUtil.select(a1.getOntologyConceptArr(), UmlsConcept.class)){ String cui = concept1.getCui(); for(UmlsConcept concept2 : JCasUtil.select(a2.getOntologyConceptArr(), UmlsConcept.class)){ if(cui.equals(concept2.getCui())){ return true; } } } } return false; }
public static boolean alias(IdentifiedAnnotation a1, IdentifiedAnnotation a2){ if(a1 != null && a2 != null){ for(UmlsConcept concept1 : JCasUtil.select(a1.getOntologyConceptArr(), UmlsConcept.class)){ String cui = concept1.getCui(); for(UmlsConcept concept2 : JCasUtil.select(a2.getOntologyConceptArr(), UmlsConcept.class)){ if(cui.equals(concept2.getCui())){ return true; } } } } return false; }
/** * @param annotation - * @return array of FeatureStructure castable to array of OntologyConcept */ static public FeatureStructure[] getConceptFeatureStructures( final IdentifiedAnnotation annotation ) { if ( annotation == null ) { return EMPTY_FEATURE_ARRAY; } final FSArray ontologyConcepts = annotation.getOntologyConceptArr(); if ( ontologyConcepts == null ) { return EMPTY_FEATURE_ARRAY; } return ontologyConcepts.toArray(); }
/** * @param annotation - * @return array of FeatureStructure castable to array of OntologyConcept */ static public FeatureStructure[] getConceptFeatureStructures( final IdentifiedAnnotation annotation ) { if ( annotation == null ) { return EMPTY_FEATURE_ARRAY; } final FSArray ontologyConcepts = annotation.getOntologyConceptArr(); if ( ontologyConcepts == null ) { return EMPTY_FEATURE_ARRAY; } return ontologyConcepts.toArray(); }
/** * @param identifiedAnnotation - * @return list of all cuis */ static private Collection<String> getCUIs( final IdentifiedAnnotation identifiedAnnotation ) { final FSArray fsArray = identifiedAnnotation.getOntologyConceptArr(); if ( fsArray == null ) { return Collections.emptySet(); } final FeatureStructure[] featureStructures = fsArray.toArray(); final Collection<String> cuis = new ArrayList<>( featureStructures.length ); for ( FeatureStructure featureStructure : featureStructures ) { if ( featureStructure instanceof UmlsConcept ) { final UmlsConcept umlsConcept = (UmlsConcept)featureStructure; final String cui = umlsConcept.getCui(); final String tui = umlsConcept.getTui(); if ( tui != null && !tui.isEmpty() ) { cuis.add( cui + "_" + tui ); } else { cuis.add( cui ); } } } return cuis; }
@Override protected String extractInformation(IdentifiedAnnotation t) { StringBuilder buff = new StringBuilder(); FSArray mentions = t.getOntologyConceptArr(); HashSet<String> uniqueCuis = new HashSet<String>(); if(mentions == null) return null; for(int i = 0; i < mentions.size(); i++){ if(mentions.get(i) instanceof UmlsConcept){ UmlsConcept concept = (UmlsConcept) mentions.get(i); uniqueCuis.add(concept.getCui()); } } for(String cui : uniqueCuis){ if(t.getPolarity() == CONST.NE_POLARITY_NEGATION_PRESENT) buff.append("-"); buff.append(cui); buff.append("\n"); } if(buff.length() == 0) return null; return buff.substring(0,buff.length()-1); } /**
/** * @param identifiedAnnotation - * @return list of all cuis */ static private Collection<String> getCUIs( final IdentifiedAnnotation identifiedAnnotation ) { final FSArray fsArray = identifiedAnnotation.getOntologyConceptArr(); if ( fsArray == null ) { return Collections.emptySet(); } final FeatureStructure[] featureStructures = fsArray.toArray(); final Collection<String> cuis = new ArrayList<>( featureStructures.length ); for ( FeatureStructure featureStructure : featureStructures ) { if ( featureStructure instanceof UmlsConcept ) { final UmlsConcept umlsConcept = (UmlsConcept)featureStructure; final String cui = umlsConcept.getCui(); final String tui = umlsConcept.getTui(); if ( tui != null && !tui.isEmpty() ) { cuis.add( cui + "_" + tui ); } else { cuis.add( cui ); } } } return cuis; }
@Override protected String extractInformation(IdentifiedAnnotation t) { StringBuilder buff = new StringBuilder(); FSArray mentions = t.getOntologyConceptArr(); HashSet<String> uniqueCuis = new HashSet<String>(); if(mentions == null) return null; for(int i = 0; i < mentions.size(); i++){ if(mentions.get(i) instanceof UmlsConcept){ UmlsConcept concept = (UmlsConcept) mentions.get(i); uniqueCuis.add(concept.getCui()); } } for(String cui : uniqueCuis){ if(t.getPolarity() == CONST.NE_POLARITY_NEGATION_PRESENT) buff.append("-"); buff.append(cui); buff.append("\n"); } if(buff.length() == 0) return null; return buff.substring(0,buff.length()-1); } /**
/** * Get the CUIs, RxNorm codes specified for this entity. */ public static HashSet<String> getOntologyConceptCodes(IdentifiedAnnotation identifiedAnnotation) { HashSet<String> codes = new HashSet<String>(); FSArray fsArray = identifiedAnnotation.getOntologyConceptArr(); if(fsArray == null) { return codes; } for(FeatureStructure featureStructure : fsArray.toArray()) { OntologyConcept ontologyConcept = (OntologyConcept) featureStructure; if(ontologyConcept instanceof UmlsConcept) { UmlsConcept umlsConcept = (UmlsConcept) ontologyConcept; String code = umlsConcept.getCui(); codes.add(code); } else { // RxNorm String code = ontologyConcept.getCodingScheme() + ontologyConcept.getCode(); codes.add(code); } } return codes; }
/** * Get the CUIs, RxNorm codes specified for this entity. */ public static HashSet<String> getOntologyConceptCodes(IdentifiedAnnotation identifiedAnnotation) { HashSet<String> codes = new HashSet<String>(); FSArray fsArray = identifiedAnnotation.getOntologyConceptArr(); if(fsArray == null) { return codes; } for(FeatureStructure featureStructure : fsArray.toArray()) { OntologyConcept ontologyConcept = (OntologyConcept) featureStructure; if(ontologyConcept instanceof UmlsConcept) { UmlsConcept umlsConcept = (UmlsConcept) ontologyConcept; String code = umlsConcept.getCui(); codes.add(code); } else { // RxNorm String code = ontologyConcept.getCodingScheme() + ontologyConcept.getCode(); codes.add(code); } } return codes; }
Collection<IdentifiedAnnotation> coveringEnts = nodeEntMap.get(head); for(IdentifiedAnnotation ent : coveringEnts){ if(ent.getOntologyConceptArr() == null) continue; // skip non-umls entities. ConllDependencyNode entHead = DependencyUtility.getNominalHeadNode(jcas, ent); if(entHead == head){
public static ArrayList<Annotation> selectNE (JCas jcas) { ArrayList<Annotation> ret = new ArrayList<Annotation>(); FSIterator<Annotation> iter = jcas.getJFSIndexRepository().getAnnotationIndex(IdentifiedAnnotation.type).iterator(); while (iter.hasNext()) { IdentifiedAnnotation a = (IdentifiedAnnotation) iter.next(); if (a instanceof EntityMention || a instanceof EventMention) { if(a.getOntologyConceptArr() != null) { // int tid = a.getTypeID(); // if (tid == TypeSystemConst.NE_TYPE_ID_ANATOMICAL_SITE || // tid == TypeSystemConst.NE_TYPE_ID_DISORDER || // tid == TypeSystemConst.NE_TYPE_ID_PROCEDURE || // tid == TypeSystemConst.NE_TYPE_ID_FINDING) ret.add(a); } } } java.util.Collections.sort(ret, new AnnotOffsetComparator()); return ret; }
Collection<IdentifiedAnnotation> coveringEnts = nodeEntMap.get(head); for(IdentifiedAnnotation ent : coveringEnts){ if(ent.getOntologyConceptArr() == null) continue; // skip non-umls entities. ConllDependencyNode entHead = DependencyUtility.getNominalHeadNode(jcas, ent); if(entHead == head){
Collection<IdentifiedAnnotation> coveringEnts = nodeEntMap.get(head); for(IdentifiedAnnotation ent : coveringEnts){ if(ent.getOntologyConceptArr() == null) continue; // skip non-umls entities. ConllDependencyNode entHead = DependencyUtility.getNominalHeadNode(jcas, ent); if(entHead == head){
public static ArrayList<Annotation> selectNE (JCas jcas) { ArrayList<Annotation> ret = new ArrayList<Annotation>(); FSIterator<Annotation> iter = jcas.getJFSIndexRepository().getAnnotationIndex(IdentifiedAnnotation.type).iterator(); while (iter.hasNext()) { IdentifiedAnnotation a = (IdentifiedAnnotation) iter.next(); if (a instanceof EntityMention || a instanceof EventMention) { if(a.getOntologyConceptArr() != null) { // int tid = a.getTypeID(); // if (tid == TypeSystemConst.NE_TYPE_ID_ANATOMICAL_SITE || // tid == TypeSystemConst.NE_TYPE_ID_DISORDER || // tid == TypeSystemConst.NE_TYPE_ID_PROCEDURE || // tid == TypeSystemConst.NE_TYPE_ID_FINDING) ret.add(a); } } } java.util.Collections.sort(ret, new AnnotOffsetComparator()); return ret; }
public boolean isAlias(){ try{ if (m1.getContent() instanceof IdentifiedAnnotation && m2.getContent() instanceof IdentifiedAnnotation) { IdentifiedAnnotation ne1 = (IdentifiedAnnotation) m1.getContent(); IdentifiedAnnotation ne2 = (IdentifiedAnnotation) m2.getContent(); ArrayList<String> l = new ArrayList<String>(); FSArray fsa = ne1.getOntologyConceptArr(); for (int i = 0; i < fsa.size(); ++i) if (fsa.get(i) instanceof UmlsConcept) l.add(((UmlsConcept)fsa.get(i)).getCui()); fsa = ne2.getOntologyConceptArr(); for (int i = 0; i < fsa.size(); ++i) if (fsa.get(i) instanceof UmlsConcept && l.contains(((UmlsConcept)fsa.get(i)).getCui())) return true; } }catch(Exception e){ System.err.println("Error here!"); } return false; }
public boolean isAlias(){ try{ if (m1.getContent() instanceof IdentifiedAnnotation && m2.getContent() instanceof IdentifiedAnnotation) { IdentifiedAnnotation ne1 = (IdentifiedAnnotation) m1.getContent(); IdentifiedAnnotation ne2 = (IdentifiedAnnotation) m2.getContent(); ArrayList<String> l = new ArrayList<String>(); FSArray fsa = ne1.getOntologyConceptArr(); for (int i = 0; i < fsa.size(); ++i) if (fsa.get(i) instanceof UmlsConcept) l.add(((UmlsConcept)fsa.get(i)).getCui()); fsa = ne2.getOntologyConceptArr(); for (int i = 0; i < fsa.size(); ++i) if (fsa.get(i) instanceof UmlsConcept && l.contains(((UmlsConcept)fsa.get(i)).getCui())) return true; } }catch(Exception e){ System.err.println("Error here!"); } return false; }