Package org.apache.ctakes.typesystem.type.textsem

Examples of org.apache.ctakes.typesystem.type.textsem.IdentifiedAnnotation


      return "N";
  }

  public String calcmWnClass () {
    if (m.getContent() instanceof IdentifiedAnnotation) {
      IdentifiedAnnotation ne = (IdentifiedAnnotation) m.getContent();
      return String.valueOf(ne.getTypeID());
    } else
      return "0";
  }
View Full Code Here


  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)
View Full Code Here

       
       
//        ppt.union(m2q.get(anaphor), m2q.get(bestAnte.m));
        if(anaphor instanceof PronounMarkable){
          // if the anaphor is a pronoun then it won't be in the cas as an identifiedannotation so we need to add it.
          IdentifiedAnnotation ia = new IdentifiedAnnotation(jcas);
          // TODO
        }
      }else{
//        indexNegativeExample(jcas, bestAnte.m, anaphor, bestAnte.prob);
      }
View Full Code Here

  //  }

  public boolean calcWnClassC () {
    if (m1.getContent() instanceof IdentifiedAnnotation &&
        m2.getContent() instanceof IdentifiedAnnotation) {
      IdentifiedAnnotation ne1 = (IdentifiedAnnotation) m1.getContent();
      IdentifiedAnnotation ne2 = (IdentifiedAnnotation) m2.getContent();
      if (ne1.getTypeID() == ne2.getTypeID()){
        return true;
      }
      return false;
    }
    return false;
View Full Code Here

      } catch (CASException e) {
        throw new AnalysisEngineProcessException(e);
      }  
     
      for(BinaryTextRelation binaryTextRelation : JCasUtil.select(systemView, BinaryTextRelation.class)) {
        IdentifiedAnnotation entity1; // entity whose role is "Argument"
        IdentifiedAnnotation entity2; // entity whose role is "Related_to"
       
        if(binaryTextRelation.getArg1().getRole().equals("Argument")) {
          entity1 = (IdentifiedAnnotation) binaryTextRelation.getArg1().getArgument();
          entity2 = (IdentifiedAnnotation) binaryTextRelation.getArg2().getArgument();
        } else {
          entity1 = (IdentifiedAnnotation) binaryTextRelation.getArg2().getArgument();
          entity2 = (IdentifiedAnnotation) binaryTextRelation.getArg1().getArgument();
        }
       
        String category = binaryTextRelation.getCategory();
        String arg1 = entity1.getCoveredText().toLowerCase();
        String arg2 = entity2.getCoveredText().toLowerCase();
        int type1 = entity1.getTypeID();
        int type2 = entity2.getTypeID();
       
        // first argument has to be an anatomical site
        if(type1 != CONST.NE_TYPE_ID_ANATOMICAL_SITE) {
          continue;
        }
View Full Code Here

  }

  public boolean calcWnClassI () {
    if (m1.getContent() instanceof IdentifiedAnnotation &&
        m2.getContent() instanceof IdentifiedAnnotation) {
      IdentifiedAnnotation ne1 = (IdentifiedAnnotation) m1.getContent();
      IdentifiedAnnotation ne2 = (IdentifiedAnnotation) m2.getContent();
      if (ne1.getTypeID() != ne2.getTypeID()){
        return true;
      }
      return false;
    }
    return false;
View Full Code Here

  }

  public boolean calcWnClass () {
    if (m1.getContent() instanceof IdentifiedAnnotation &&
        m2.getContent() instanceof IdentifiedAnnotation) {
      IdentifiedAnnotation ne1 = (IdentifiedAnnotation) m1.getContent();
      IdentifiedAnnotation ne2 = (IdentifiedAnnotation) m2.getContent();
      if (ne1.getTypeID() == ne2.getTypeID()){
        return true;
      }
    }
    return false;
  }
View Full Code Here

 
  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;
    }
View Full Code Here

      List<IdentifiedAnnotationPair> candidatePairs =
          this.getCandidateRelationArgumentPairs(jCas, coveringAnnotation);

      // walk through the pairs of annotations
      for (IdentifiedAnnotationPair pair : candidatePairs) {
        IdentifiedAnnotation arg1 = pair.getArg1();
        IdentifiedAnnotation arg2 = pair.getArg2();
        // apply all the feature extractors to extract the list of features
        List<Feature> features = new ArrayList<Feature>();
        for (RelationFeaturesExtractor extractor : this.featureExtractors) {
          features.addAll(extractor.extract(jCas, arg1, arg2));
        }

        // sanity check on feature values
        for (Feature feature : features) {
          if (feature.getValue() == null) {
            String message = "Null value found in %s from %s";
            throw new IllegalArgumentException(String.format(message, feature, features));
          }
        }

        // during training, feed the features to the data writer
        if (this.isTraining()) {
          String category = this.getRelationCategory(relationLookup, arg1, arg2);
          if (category == null) {
            continue;
          }

          // create a classification instance and write it to the training data
          this.dataWriter.write(new Instance<String>(category, features));
        }

        // during classification feed the features to the classifier and create
        // annotations
        else {
          String predictedCategory = this.classify(features);

          // add a relation annotation if a true relation was predicted
          if (!predictedCategory.equals(NO_RELATION_CATEGORY)) {

            // if we predict an inverted relation, reverse the order of the
            // arguments
            if (predictedCategory.endsWith("-1")) {
              predictedCategory = predictedCategory.substring(0, predictedCategory.length() - 2);
              IdentifiedAnnotation temp = arg1;
              arg1 = arg2;
              arg2 = temp;
            }

            createRelation(jCas, arg1, arg2, predictedCategory);
View Full Code Here

  private void countDistanceBetweenArguments(JCas systemView, JCas goldView) {

    for(BinaryTextRelation binaryTextRelation : JCasUtil.select(goldView, BinaryTextRelation.class)) {
      if(binaryTextRelation.getCategory().equals(targetRelationType)) {
        IdentifiedAnnotation arg1 = (IdentifiedAnnotation) binaryTextRelation.getArg1().getArgument();
        IdentifiedAnnotation arg2 = (IdentifiedAnnotation) binaryTextRelation.getArg2().getArgument();
        relationArgumentDistance += getTokenDistance(systemView, arg1, arg2);
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.ctakes.typesystem.type.textsem.IdentifiedAnnotation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.