Examples of FSIterator


Examples of org.apache.uima.cas.FSIterator

    // TODO: access type with string constant
    Type frameType = cas.getTypeSystem().getType("org.apache.uima.ruta.type.RutaFrame");
    int begin = left.getWordConstraint().getTokenAnnotation().getEnd();
    int end = right.getWordConstraint().getTokenAnnotation().getBegin();
    AnnotationFS pointer = cas.createAnnotation(frameType, begin, end);
    FSIterator iterator = cas.getAnnotationIndex().iterator(pointer);
    while (iterator.isValid()) {
      FeatureStructure fs = iterator.get();
      AnnotationFS a = (AnnotationFS) fs;
      if (a.getBegin() >= begin && a.getEnd() <= end) {
        if (!filterSetWithSlotNames.contains(a.getType().getName())) {
          return false;
        }
      }
      iterator.moveToNext();
    }
    return true;
  }
View Full Code Here

Examples of org.apache.uima.cas.FSIterator

    map.put(" Total", new TypeEvalData("Total", truePositiveCount, falsePositiveCount,
            falseNegativeCount));

    AnnotationIndex<AnnotationFS> index = resultCas.getAnnotationIndex(truePositiveType);

    FSIterator iter = index.iterator();

    if (originalFeature != null) {

      while (iter.isValid()) {
        AnnotationFS a = (AnnotationFS) iter.next();

        FeatureStructure fs = a.getFeatureValue(originalFeature);
        String typeName = fs.getType().getName();

        if (map.containsKey(typeName)) {
          TypeEvalData element = map.get(typeName);
          int oldCount = element.getTruePositives();
          element.setTruePositives(oldCount + 1);
        } else {
          TypeEvalData newData = new TypeEvalData(typeName, 1, 0, 0);
          map.put(typeName, newData);
        }
      }

      index = resultCas.getAnnotationIndex(falsePositiveType);
      iter = index.iterator();

      while (iter.isValid()) {
        AnnotationFS a = (AnnotationFS) iter.next();

        FeatureStructure fs = a.getFeatureValue(originalFeature);
        String typeName = fs.getType().getName();

        if (map.containsKey(typeName)) {
          TypeEvalData element = map.get(typeName);
          int oldCount = element.getFalsePositives();
          element.setFalsePositives(oldCount + 1);
        } else {
          TypeEvalData newData = new TypeEvalData(typeName, 0, 1, 0);
          map.put(typeName, newData);
        }
      }

      index = resultCas.getAnnotationIndex(falseNegativeType);
      iter = index.iterator();

      while (iter.isValid()) {
        AnnotationFS a = (AnnotationFS) iter.next();

        FeatureStructure fs = a.getFeatureValue(originalFeature);
        String typeName = fs.getType().getName();

        if (map.containsKey(typeName)) {
View Full Code Here

Examples of org.apache.uima.cas.FSIterator

      // UIMAFramework.getLogger().log("CAS ACount::" +
      // cas.getAnnotationIndex().size());
      int totalAnnots = 0;
      SofaFS sofa;
      FSIterator sItr = cas.getSofaIterator();
      while (sItr.isValid()) {
        sofa = (SofaFS) sItr.get();
        totalAnnots += cas.getView(sofa).getAnnotationIndex().size();
        sItr.moveToNext();
      }
      UIMAFramework.getLogger().log(Level.FINE, "CAS Annotation Count::" + totalAnnots);

      return responseFrame;
    } catch (Throwable ex) {
View Full Code Here

Examples of org.apache.uima.cas.FSIterator

        annotateRange(aCAS, text, 0);
      } else {
        // Search only within annotations of type mContainingType

        // Get an iterator over the annotations of type mContainingType.
        FSIterator it = aCAS.getAnnotationIndex(mContainingType).iterator();
        // Loop over the iterator.
        while (it.isValid()) {
          // Get the next annotation from the iterator
          AnnotationFS annot = (AnnotationFS) it.get();
          // Get text covered by this annotation
          String coveredText = annot.getCoveredText();
          // Get begin position of this annotation
          int annotBegin = annot.getBegin();
          // search for matches within this
          annotateRange(aCAS, coveredText, annotBegin);
          // Advance the iterator.
          it.moveToNext();
        }
      }
    } catch (Exception e) {
      throw new AnalysisEngineProcessException(e);
    }
View Full Code Here

Examples of org.apache.uima.cas.FSIterator

    } catch (CASException e) {
      throw new ResourceProcessException(e);
    }

    // retreive the filename of the input file from the CAS
    FSIterator it = jcas.getAnnotationIndex(SourceDocumentInformation.type).iterator();
    File outFile = null;
    if (it.hasNext()) {
      SourceDocumentInformation fileLoc = (SourceDocumentInformation) it.next();
      File inFile;
      try {
        inFile = new File(new URL(fileLoc.getUri()).getPath());
        String outFileName = inFile.getName();
        if (fileLoc.getOffsetInSource() > 0) {
View Full Code Here

Examples of org.apache.uima.cas.FSIterator

    } catch (CASException e) {
      throw new ResourceProcessException(e);
    }

    // retreive the filename of the input file from the CAS
    FSIterator it = jcas.getAnnotationIndex(SourceDocumentInformation.type).iterator();
    File outFile = null;
    if (it.hasNext()) {
      SourceDocumentInformation fileLoc = (SourceDocumentInformation) it.next();
      File inFile;
      try {
        inFile = new File(new URL(fileLoc.getUri()).getPath());
        String outFileName = inFile.getName();
        if (fileLoc.getOffsetInSource() > 0) {
View Full Code Here

Examples of org.apache.uima.cas.FSIterator

      // Extract CAS
      // UIMAFramework.getLogger().log("CAS ACount::" +
      // cas.getAnnotationIndex().size());
      int totalAnnots = 0;
      SofaFS sofa;
      FSIterator sItr = cas.getSofaIterator();
      while (sItr.isValid()) {
        sofa = (SofaFS) sItr.get();
        totalAnnots += cas.getView(sofa).getAnnotationIndex().size();
        sItr.moveToNext();
      }
      UIMAFramework.getLogger().log(Level.FINEST, "CAS ACount::" + totalAnnots);
      ct.setCommand(null);
      return ct;
    } catch (Exception ex) {
View Full Code Here

Examples of org.apache.uima.cas.FSIterator

      assertNotNull(cas.getIndexRepository().getIndex("MyIndex"));

      // test that priorities work
      cas.createFS(supertypeHandle);
      cas.createFS(subtypeHandle);
      FSIterator iter = cas.getAnnotationIndex().iterator();
      while (iter.isValid()) {
        if (iter.get().getType() == subtypeHandle) // expected
          break;
        if (iter.get().getType() == supertypeHandle) // unexpected
          fail();
        iter.moveToNext();
      }

      // test that passing an invalid object causes an error
      descList.add(new ConfigurationParameter_impl());
      try {
View Full Code Here

Examples of org.apache.uima.cas.FSIterator

    } catch (CASException e) {
      throw new ResourceProcessException(e);
    }

    // retreive the filename of the input file from the CAS
    FSIterator it = jcas.getAnnotationIndex(SourceDocumentInformation.type).iterator();
    File outFile = null;
    if (it.hasNext()) {
      SourceDocumentInformation fileLoc = (SourceDocumentInformation) it.next();
      File inFile;
      try {
        inFile = new File(new URL(fileLoc.getUri()).getPath());
        String outFileName = inFile.getName();
        if (fileLoc.getOffsetInSource() > 0) {
View Full Code Here

Examples of org.apache.uima.cas.FSIterator

    final int size = index.size();
    this.rootString = "<html><font color=green>" + indexName + "</font> - <font color=blue>"
            + index.getType().getName() + "</font> [" + size + "]</html>";
    this.root = new FSNode(this, FSNode.DISPLAY_NODE, 0, null);
    this.fss = new ArrayList<FSNode>();
    FSIterator it = index.iterator();
    int count = 0;
    for (it.moveToFirst(); it.isValid(); it.moveToNext()) {
      FeatureStructure fs = it.get();
      this.fss.add(new FSNode(this, getNodeType(fs.getType()), fs.hashCode(), count));
      ++count;
    }
    List<FSTreeNode> kids = createArrayChildren(0, size, this.fss, this);
    this.root.setChildren(kids);
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.