Package org.apache.ctakes.smokingstatus.type.libsvm

Examples of org.apache.ctakes.smokingstatus.type.libsvm.NominalAttributeValue


    String navName = null;
       
        List<NominalAttributeValue> removalList = new ArrayList<NominalAttributeValue>();
        while (navItr.hasNext())
        {
            NominalAttributeValue nav = (NominalAttributeValue) navItr.next();

            String nVal = nav.getNominalValue();

            if (nVal.equals(Const.CLASS_KNOWN)
                    || nVal.equals(Const.CLASS_UNKNOWN))
            {
                kuClassification = nVal;
                navName = nav.getAttributeName();
            } else if (nVal.equals(Const.CLASS_CURR_SMOKER)
                    || nVal.equals(Const.CLASS_PAST_SMOKER)
                    || nVal.equals(Const.CLASS_SMOKER))
            {
                pcsClassification = nVal;
                navName = nav.getAttributeName();
            } else
            {
                throw new AnnotatorProcessException(new Exception(
                        "Nominal value not part of " + Const.class + ": "
                                + nVal));
            }
            removalList.add(nav);
        }

        // remove old NominalAttributeValue objects from CAS
        Iterator<NominalAttributeValue> removalItr = removalList.iterator();
        while (removalItr.hasNext())
        {
            TOP top = (TOP) removalItr.next();
            top.removeFromIndexes();
        }
     
        /**
         *
         * This is to deal with cases like "nonsmoker" and "non-smoker"
         * There are two dictionaries: smoker.dictionary and nonsmoker.dictionary
         * and two NameEntities: SmokerNamedEntityAnnotation and NonSmokerNamedEntityAnnotation
         * Each includes smoker or nonsmoker keywords respectively
         * Configuration file and dictionary are set up in Resources in DitionaryLookupAnnotator.xml
         */
      //Smoker or Nonsmoker NamedEntityAnnotation are created only if the sentence include
      //smoker or nonsmoker keywords
      int negCnt = getSmokerNegatedCount(jcas);     
      int nonsmokerCnt = getNonSmokerNegatedCount(jcas);
      int negConCnt = getNegConCount(jcas);
      String finalClassification = null;
                                 
      /**
        * 12/04/08
        * Originally each roundtrip would have processed just one sentence
        * Now, we process the complete doc
        *
        * 1/22/09 REVERTING TO ORIGINAL CODE as classifier need to just one sentence in the cas
        */

        if (kuClassification.equals(Const.CLASS_UNKNOWN))
        {
            finalClassification = kuClassification;
        } else
        {
          if ( (negCnt>0 && negConCnt==0) || nonsmokerCnt>0 )
            {
                finalClassification = Const.CLASS_NON_SMOKER;
            } else
            {
                finalClassification = pcsClassification;
            }
        }

        //---check sentence-level classification
    if (iv_logger.isInfoEnabled())
     if(finalClassification!=Const.CLASS_UNKNOWN) {
          Iterator senIter = jcas.getJFSIndexRepository().getAnnotationIndex(Sentence.type).iterator();   
          while(senIter.hasNext()) {
            Sentence sen = (Sentence) senIter.next();
            iv_logger.info("|"+sen.getCoveredText() + "|" + finalClassification + "|" + negCnt);
          }
        }
        //---
     
        // add final classification as a new NominalAttributeValue object
        NominalAttributeValue finalNav = new NominalAttributeValue(jcas);
        finalNav.setAttributeName(navName);
        finalNav.setNominalValue(finalClassification);
        finalNav.addToIndexes();
    }
View Full Code Here


    // ---

    // System.out.println("***" + classVal + " for " + classAttributeName +
    // "***");

    NominalAttributeValue nominalAttributeValue = new NominalAttributeValue(
        jcas);
    nominalAttributeValue.setAttributeName(classAttributeName);
    nominalAttributeValue.setNominalValue(classVal);
    nominalAttributeValue.addToIndexes();
  }
View Full Code Here

    boolean known = true;
    Iterator<?> nominalAttrItr = jcas_local.getJFSIndexRepository()
        .getAnnotationIndex(NominalAttributeValue.type).iterator();

    while (nominalAttrItr.hasNext()) {
      NominalAttributeValue nav = (NominalAttributeValue) nominalAttrItr
          .next();

      if (nav.getAttributeName().equalsIgnoreCase("smoking_status")
          && nav.getNominalValue().equalsIgnoreCase("UNKNOWN"))
        known = false;
      // System.err.println("attr name:"+nav.getAttributeName()+" val:"+nav.getNominalValue());

    }
View Full Code Here

        // the ResolutionAnnotator.
        Iterator<?> navItr = jcas_local.getJFSIndexRepository()
            .getAnnotationIndex(NominalAttributeValue.type)
            .iterator();
        while (navItr.hasNext()) {
          NominalAttributeValue nav = (NominalAttributeValue) navItr
              .next();
          String classification = nav.getNominalValue();

          storeAssignedClasses(classification);
        }

      }
View Full Code Here

    else
      clsVal = null;

    // System.out.println("clsLabel="+clsLabel+" clsVal="+clsVal);

    NominalAttributeValue nominalAttributeValue = new NominalAttributeValue(
        jcas);
    nominalAttributeValue.setAttributeName("smoking_status");
    nominalAttributeValue.setNominalValue(clsVal);
    nominalAttributeValue.addToIndexes();
  }
View Full Code Here

TOP

Related Classes of org.apache.ctakes.smokingstatus.type.libsvm.NominalAttributeValue

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.