Package org.apache.uima.jcas.tcas

Examples of org.apache.uima.jcas.tcas.Annotation


    JFSIndexRepository indexes = jcas.getJFSIndexRepository();
    FSIterator<Annotation> srcObjItr = indexes.getAnnotationIndex(
        retainAnnType).iterator();

    while (srcObjItr.hasNext()) {
      Annotation ann = (Annotation) srcObjItr.next();
      if (!isValid(ann))
        removeList.add(ann);
    }

    for (int i = 0; i < removeList.size(); i++)
View Full Code Here


  {
    List list = new ArrayList();

    while (annotItr.hasNext())
    {
      Annotation annot = (Annotation) annotItr.next();

      // only consider if it's within the window
      if ((annot.getBegin() >= begin) && (annot.getEnd() <= end))
      {
        list.add(new LookupAnnotationToJCasAdapter(annot));
      }
    }
    return list;
View Full Code Here

        LookupInitializer lInit = ls.getLookupInitializer();

        Iterator windowItr = lInit.getLookupWindowIterator(jcas);
        while (windowItr.hasNext()) {

          Annotation window = (Annotation) windowItr.next();
          List lookupTokensInWindow = constrainToWindow(
              window,
              lInit.getLookupTokenIterator(jcas));

          Map ctxMap = lInit.getContextMap(
              jcas,
              window.getBegin(),
              window.getEnd());
          performLookup(jcas, ls, lookupTokensInWindow, ctxMap);
        }
      }

    }
View Full Code Here

      return "N";
  }

  // FIXME use parser output instead of LWA
  public String calcmNPHead () {
    Annotation a = m.getContent();
    FSIterator iter = jcas.getJFSIndexRepository().getAnnotationIndex(LookupWindowAnnotation.type).iterator();
    while (iter.hasNext()) {
      LookupWindowAnnotation lwa = (LookupWindowAnnotation) iter.next();
      if (lwa.getBegin()<=a.getBegin() && lwa.getEnd()==a.getEnd())
        return "yes";
    }
    return "no";
  }
View Full Code Here

    }
    return "I";
  }

  public String calcNPHead () {
    Annotation a = m1.getContent();
//    return (a.getEnd()==m1.getEnd() && a.getBegin()>m1.getBegin()) ? "yes" : "no";
    FSIterator iter = jcas.getJFSIndexRepository().getAnnotationIndex(LookupWindowAnnotation.type).iterator();
    while (iter.hasNext()) {
      LookupWindowAnnotation lwa = (LookupWindowAnnotation) iter.next();
      if (lwa.getBegin()<=a.getBegin() && lwa.getEnd()==a.getEnd())
        return "yes";
    }
    return "no";
  }
View Full Code Here

                append(uimaObject.hashCode()).toString()), existingNode.getGraph());
        log.info(new StringBuilder("Node created for Type ").append(uimaObject.getType().toString()).toString());

        // set Annotation specific properties for the node
        if (uimaObject instanceof Annotation) {
          Annotation annotation = (Annotation) uimaObject;
          String coveredText = annotation.getCoveredText();
          annotationNode.addPropertyValue(ENTITY.coveredText, coveredText);
          log.info(new StringBuilder("Node wraps Annotation with coveredText:").append(coveredText).toString());
        }

        //XXX : in OpenCalais the type is an URI so it maybe reasonable to put another node here
View Full Code Here

  @Test
  public void testFailingGetSingletonFS() {
    try {
      JCas cas = getCAS().getJCas();
      cas.setDocumentText(DOCUMENT_TEXT);
      Annotation simpleAnnotation = new Annotation(cas);
      simpleAnnotation.setBegin(10);
      simpleAnnotation.setEnd(24);
      simpleAnnotation.addToIndexes();

      Annotation secondSimpleAnnotation = new Annotation(cas);
      secondSimpleAnnotation.setBegin(32);
      secondSimpleAnnotation.setEnd(44);
      secondSimpleAnnotation.addToIndexes();

      UIMAUtils.getSingletonFeatureStructure(Annotation.type, cas);
      fail("should raise exception since there are 3 annotations of type Annotation");
    } catch (Exception e) {
      // if here, test passed
View Full Code Here

    try {
      JCas cas = getCAS().getJCas();
      cas.setDocumentText(DOCUMENT_TEXT);

      Annotation simpleAnnotation = new Annotation(cas);
      simpleAnnotation.setBegin(10);
      simpleAnnotation.setEnd(24);
      simpleAnnotation.addToIndexes();

      Annotation secondSimpleAnnotation = new Annotation(cas);
      secondSimpleAnnotation.setBegin(32);
      secondSimpleAnnotation.setEnd(44);
      secondSimpleAnnotation.addToIndexes();

      MGraph mGraph = new SimpleMGraph();
      GraphNode node = new GraphNode(new UriRef(cas.toString()), mGraph);

      UIMAUtils.enhanceNode(node, UIMAUtils.getAllAnnotationsOfType(Annotation.type, cas));
View Full Code Here

              if (uimaObject.getType().toString().equals("uima.tcas.DocumentAnnotation")) {
                continue;
              }

              // Get persistent URI for region in document
              Annotation annot = (Annotation) uimaObject;
              log.info("annotation index " + annotCnt);
              annotIndex.put(annot, annotCnt);
              annotCnt++;
          }
      }

      UriRef annotationSetUri = new UriRef(
              new StringBuilder(AO.AnnotationSet.getUnicodeString()).toString());
      log.info("AO: Annotation set uri " + annotationSetUri);

      GraphNode annotationSet = new GraphNode(annotationSetUri, node.getGraph());
      log.info(new StringBuilder("AO: Set created ").toString());
      annotationSet.addProperty(new UriRef("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),
              AO.AnnotationSet);

      for (FeatureStructure uimaObject : UIMAUtils.getAllFSofType(TOP.type, cas.getJCas())) {

        // set Annotation specific properties for the node
        if (uimaObject instanceof Annotation) {

          // If type is DocumentAnnotation I skip it
          if (uimaObject.getType().toString().equals("uima.tcas.DocumentAnnotation")) {
            continue;
          }

          // Get persistent URI for region in document
          Annotation annot = (Annotation) uimaObject;
          UriRef selectorUri = selectorRegistry.get(annot.getBegin(), annot.getEnd());

          // Annotation URI
          int annotId = annotIndex.get((Annotation) uimaObject);
          UriRef annotationUri = new UriRef(new StringBuilder(AO.Annotation.getUnicodeString())
                  .append("/").append(annotId).toString());
View Full Code Here

            externalServicesFacade.setParameterSetting(parameterSettings);
            List<FeatureStructure> entities = externalServicesFacade.getNamedEntities(ANOTHER_ENGLISH_TEXT);
            assertTrue(entities != null);
            assertTrue(!entities.isEmpty());
            for (FeatureStructure fs : entities) {
              Annotation annotation = (Annotation) fs;
              assertTrue(annotation.getType()!=null && annotation.getType().getName()!=null);
              assertTrue(annotation.getBegin()>0);
              assertTrue(annotation.getEnd()>0);
              assertTrue(annotation.getCoveredText()!=null);
            }
        }
        catch (Exception e) {
            e.printStackTrace();
            fail(e.getLocalizedMessage());
View Full Code Here

TOP

Related Classes of org.apache.uima.jcas.tcas.Annotation

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.