org.apache.ctakes.typesystem.type.textsem.IdentifiedAnnotation.getOntologyConceptArr()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(11.1k)|赞(0)|评价(0)|浏览(68)

本文整理了Java中org.apache.ctakes.typesystem.type.textsem.IdentifiedAnnotation.getOntologyConceptArr()方法的一些代码示例,展示了IdentifiedAnnotation.getOntologyConceptArr()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IdentifiedAnnotation.getOntologyConceptArr()方法的具体详情如下:
包路径:org.apache.ctakes.typesystem.type.textsem.IdentifiedAnnotation
类名称:IdentifiedAnnotation
方法名:getOntologyConceptArr

IdentifiedAnnotation.getOntologyConceptArr介绍

[英]getter for ontologyConceptArr - gets
[中]

代码示例

代码示例来源:origin: apache/tika

value = Integer.toString(annotation.getId());
} else if (property == CTAKESAnnotationProperty.ONTOLOGY_CONCEPT_ARR) {
  FSArray mentions = annotation.getOntologyConceptArr();
  StringBuilder sb = new StringBuilder();
  if (mentions != null) {

代码示例来源:origin: org.apache.ctakes/ctakes-ytex-uima

@Override
public boolean filter(Annotation anno) {
  if (!(anno instanceof IdentifiedAnnotation))
    return false;
  IdentifiedAnnotation ia = (IdentifiedAnnotation) anno;
  return ia.getOntologyConceptArr() != null
      && ia.getOntologyConceptArr().size() > 0;
}

代码示例来源:origin: apache/ctakes

@Override
public boolean filter(Annotation anno) {
  if (!(anno instanceof IdentifiedAnnotation))
    return false;
  IdentifiedAnnotation ia = (IdentifiedAnnotation) anno;
  return ia.getOntologyConceptArr() != null
      && ia.getOntologyConceptArr().size() > 0;
}

代码示例来源:origin: org.apache.ctakes/ctakes-coreference

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;
 }

代码示例来源:origin: apache/ctakes

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;
 }

代码示例来源:origin: org.apache.ctakes/ctakes-core

/**
* @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();
}

代码示例来源:origin: apache/ctakes

/**
* @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();
}

代码示例来源:origin: org.apache.ctakes/ctakes-clinical-pipeline

/**
* @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;
}

代码示例来源:origin: org.apache.ctakes/ctakes-clinical-pipeline

@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);
}
/**

代码示例来源:origin: apache/ctakes

/**
* @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;
}

代码示例来源:origin: apache/ctakes

@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);
}
/**

代码示例来源:origin: apache/ctakes

/**
 * 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;
}

代码示例来源:origin: org.apache.ctakes/ctakes-relation-extractor

/**
 * 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;
}

代码示例来源:origin: apache/ctakes

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){

代码示例来源:origin: apache/ctakes

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;
  }

代码示例来源:origin: org.apache.ctakes/ctakes-coreference

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){

代码示例来源:origin: apache/ctakes

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){

代码示例来源:origin: org.apache.ctakes/ctakes-coreference

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;
  }

代码示例来源:origin: org.apache.ctakes/ctakes-coreference

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;
}

代码示例来源:origin: apache/ctakes

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;
}

相关文章

微信公众号

最新文章

更多