Examples of FSArray


Examples of org.apache.uima.jcas.cas.FSArray

   * @param validCodeCol
   * @return
   */
  private FSArray createOntologyConceptArr(JCas jcas, Collection validCodeCol)
  {
    FSArray ocArr = new FSArray(jcas, validCodeCol.size());
    int ocArrIdx = 0;
    Iterator validCodeItr = validCodeCol.iterator();
    while (validCodeItr.hasNext())
    {
      String validCode = (String) validCodeItr.next();
      OntologyConcept oc = new OntologyConcept(jcas);
      oc.setCode(validCode);
      oc.setCodingScheme(iv_props.getProperty(CODING_SCHEME_PRP_KEY));

      ocArr.set(ocArrIdx, oc);
      ocArrIdx++;
    }
    return ocArr;
  }
View Full Code Here

Examples of org.apache.uima.jcas.cas.FSArray

    while (hitsByOffsetItr.hasNext())
    {
      Collection hitsAtOffsetCol = (Collection) hitsByOffsetItr.next();

     
      FSArray ocArr = new FSArray(jcas, countUniqueCodes(hitsAtOffsetCol));
     
      int ocArrIdx = 0;

      // iterate over the LookupHit objects and create
      // a corresponding JCas OntologyConcept object that will
      // be placed in a FSArray
      Iterator lhAtOffsetItr = hitsAtOffsetCol.iterator();
      int neBegin = -1;
      int neEnd = -1;
      Set<String> codes = new HashSet<String>();
      while (lhAtOffsetItr.hasNext())
      {
        LookupHit lh = (LookupHit) lhAtOffsetItr.next();
        neBegin = lh.getStartOffset();
        neEnd = lh.getEndOffset();

        MetaDataHit mdh = lh.getDictMetaDataHit();

        String code = mdh.getMetaFieldValue(iv_props.getProperty(CODE_MF_PRP_KEY));
        if (codes.contains(code)) {
          // don't create a second entry in the array for a code already seen, including null
        } else {
         
          OntologyConcept oc = new OntologyConcept(jcas);
          oc.setCode(code);
          oc.setCodingScheme(iv_props.getProperty(CODING_SCHEME_PRP_KEY));

          if(iv_props.getProperty(TYPE_ID_FIELD) != null) {
            typeId = iv_props.getProperty(TYPE_ID_FIELD);//mdh.getMetaFieldValue(iv_props.getProperty(TYPE_ID_FIELD));
          }
         
          ocArr.set(ocArrIdx, oc);
          ocArrIdx++;

          codes.add(code);

        }
View Full Code Here

Examples of org.apache.uima.jcas.cas.FSArray

        TreebankNode vp = findP(tn, "VP", 0);
        while (vp!=null) vp = findP(par = vp, "VP", 0);
        vp = par;
        par = vp.getParent();

        FSArray c = vp.getChildren();
        TreebankNode firstChild = (TreebankNode) c.get(0);
        if (isBe(firstChild)) {
          TreebankNode adjP = findP(vp, "ADJP", 1);
          if (adjP!=null && modalAdj.contains(adjP.getCoveredText()) &&
              (findP(vp, "SBAR", 1)!=null ||
              findP(vp, "S", 1)!=null ||
View Full Code Here

Examples of org.apache.uima.jcas.cas.FSArray

    }
    return false;
  }

  private static TreebankNode findP (TreebankNode n, String phraseTag, int startingChild) {
    FSArray c = n.getChildren();
    int i = startingChild;
    while (i < c.size()) {
      TreebankNode tn = (TreebankNode) c.get(i++);
      if (tn.getNodeType().equals(phraseTag) ||
          tn.getNodeType().startsWith(phraseTag+"-"))
        return tn;
    }
    return null;
View Full Code Here

Examples of org.apache.uima.jcas.cas.FSArray

      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 "C";
    }
    }catch(Exception e){
      System.err.println("Error here!");
    }
View Full Code Here

Examples of org.apache.uima.jcas.cas.FSArray

      r1.setArrayFloat(1, (float) 2.5);
      assertTrue(3.0 == r1.getArrayFloat(0));
      assertTrue(2.5 == r1.getArrayFloat(1));

      Root r2 = new Root(jcas);
      r2.setArrayRef(new FSArray(jcas, 3));
      EndOfSentence eos1 = new EndOfSentence(jcas);
      EndOfSentence eos2 = new EndOfSentence(jcas);

      r2.setArrayRef(0, eos1);
      r2.setArrayRef(1, eos2);
View Full Code Here

Examples of org.apache.uima.jcas.cas.FSArray

   *
   * @see org.apache.uima.jcas.JCas#getFSArray0L()
   */
  public FSArray getFSArray0L() {
    if (null == sharedView.fsArray0L)
      sharedView.fsArray0L = new FSArray(this, 0);
    return sharedView.fsArray0L;
  }
View Full Code Here

Examples of org.apache.uima.jcas.cas.FSArray

      Annotation crossAnnot = gerCrossAnnot.getOtherAnnotation();
      assertTrue((CAS.TYPE_NAME_ANNOTATION).equals(crossAnnot.getType().getName()));
      assertTrue(("this").equals(crossAnnot.getCoveredText()));

      // Test that annotations accessed from a reference in the base CAS work correctly
      FSArray anArray = new FSArray(jcas, 3);
      anArray.set(0, engAnnot);
      anArray.set(1, frAnnot);
      anArray.set(2, gerCrossAnnot);
      Annotation tstAnnot = (Annotation) anArray.get(0);
      assertTrue(("this").equals(tstAnnot.getCoveredText()));
      tstAnnot = (Annotation) anArray.get(1);
      assertTrue(("cette").equals(tstAnnot.getCoveredText()));
      tstAnnot = (Annotation) anArray.get(2);
      assertTrue(("das").equals(tstAnnot.getCoveredText()));
    } catch (Exception e) {
      JUnitExtension.handleException(e);
    }
  }
View Full Code Here

Examples of org.apache.uima.jcas.cas.FSArray

  public void testSelectOnArrays() throws Exception {
    String text = "Rot wood cheeses dew?";
    tokenBuilder.buildTokens(jCas, text);

    Collection<TOP> allFS = select(jCas, TOP.class);
    FSArray allFSArray = new FSArray(jCas, allFS.size());
    int i = 0;
    for (FeatureStructure fs : allFS) {
      allFSArray.set(i, fs);
      i++;
    }

    // Print what is expected
    for (FeatureStructure fs : allFS) {
View Full Code Here

Examples of org.apache.uima.jcas.cas.FSArray

      tgtSemType.setEnd(tgtConcept.getEnd());
      tgtSemType.setTui(sType.getCode());
      tgtSemType.setSty(sType.getName());
      semTypeArray.add(tgtSemType);
    }
    FSArray sTypeArray = new FSArray(jCas, semTypeArray.size());
    FeatureStructure[] semTypeFtrStructArray = new FeatureStructure[semTypeArray
        .size()];
    semTypeArray.toArray(semTypeFtrStructArray);
    sTypeArray.copyFromArray(semTypeFtrStructArray, 0, 0,
        semTypeFtrStructArray.length);
    tgtConcept.setTuis(sTypeArray);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.