Examples of AnnotationFS


Examples of org.apache.uima.cas.text.AnnotationFS

          public boolean hasNext() {
            return mAnnotations.hasNext();
          }

          public Object next() {
            AnnotationFS annotation = (AnnotationFS) mAnnotations.next();

            EclipseAnnotationPeer peer = new EclipseAnnotationPeer(annotation.getType().getName(), false, "");
            peer.setAnnotation(annotation);
            return peer;
          }

          public void remove() {
          }};
      }

      public Position getPosition(Annotation annotation) {
        EclipseAnnotationPeer peer = (EclipseAnnotationPeer) annotation;
        AnnotationFS annotationFS = peer.getAnnotationFS();
        return new Position(annotationFS.getBegin(),
            annotationFS.getEnd() - annotationFS.getBegin());
      }

      public void removeAnnotation(Annotation annotation) {
      }
View Full Code Here

Examples of org.apache.uima.cas.text.AnnotationFS

    Map<Integer, AnnotationFS> view = getView(type);

    LinkedList<AnnotationFS> annotations = new LinkedList<AnnotationFS>();

    for (int i = span.getStart(); i < span.getEnd(); i++) {
      AnnotationFS annotation = view.get(i);

      if (annotation == null) {
        continue;
      }

      if (!annotation.getType().equals(type)) {
        continue;
      }

      annotations.addLast(annotation);
View Full Code Here

Examples of org.apache.uima.cas.text.AnnotationFS

  public boolean match(FeatureStructure featureStructure) {
    if (!(featureStructure instanceof AnnotationFS)) {
      return false;
    }

    AnnotationFS annotation = (AnnotationFS) featureStructure;

    for (AnnotationFS containingAnnotation : mContainingAnnotations) {
      if (isContaining(annotation, containingAnnotation)) {
        return true;
      }
View Full Code Here

Examples of org.apache.uima.cas.text.AnnotationFS

        allTokens.iterator(), containingConstraint);

    List<Span> openNLPSpans = new LinkedList<Span>();

    while (containingTokens.hasNext()) {
      AnnotationFS tokenAnnotation = containingTokens.next();

      openNLPSpans.add(new Span(tokenAnnotation.getBegin()
          - sentence.getBegin(), tokenAnnotation.getEnd()
          - sentence.getBegin()));
    }

    Span[] spans = openNLPSpans.toArray(new Span[openNLPSpans.size()]);
   
View Full Code Here

Examples of org.apache.uima.cas.text.AnnotationFS

    Iterator<AnnotationFS> containingTokens = tcas.createFilteredIterator(
        allTokens.iterator(), containingConstraint);
   
    while (containingTokens.hasNext()) {
     
      AnnotationFS tokenAnnotation = (AnnotationFS) containingTokens.next();
     
      String tag = tokenAnnotation.getFeatureValueAsString(mPOSFeature);
     
      tokens.add(tokenAnnotation.getCoveredText().trim());
      tags.add(tag);
    }
   
    mPOSSamples.add(new POSSample(tokens, tags));
  }
View Full Code Here

Examples of org.apache.uima.cas.text.AnnotationFS

      final Iterator<AnnotationFS> sentenceTokenIterator = sentenceTokenAnnotationList.iterator();

      int index = 0;
      while (posTagIterator.hasNext() && sentenceTokenIterator.hasNext()) {
        final String posTag = posTagIterator.next();
        final AnnotationFS tokenAnnotation = sentenceTokenIterator.next();

        tokenAnnotation.setStringValue(this.posFeature, posTag);

        if (posProbabilities != null) {
          tokenAnnotation.setDoubleValue(this.posFeature, posProbabilities[index]);
        }

        index++;
      }
View Full Code Here

Examples of org.apache.uima.cas.text.AnnotationFS

   */
  private static Span[] createNames(List<AnnotationFS> tokenList, List<AnnotationFS> entityAnnotations) {

    List<Span> nameList = new LinkedList<Span>();

    AnnotationFS currentEntity = null;

    int startIndex = -1;
    int index = 0;
    for (AnnotationFS token : tokenList) {
      for (AnnotationFS entity : entityAnnotations) {
View Full Code Here

Examples of org.apache.uima.cas.text.AnnotationFS

  public void processCas(CAS cas) throws ResourceProcessException {
   
    FSIndex categoryIndex = cas.getAnnotationIndex(mCategoryType);
   
    if (categoryIndex.size() > 0) {
      AnnotationFS categoryAnnotation  =
          (AnnotationFS) categoryIndex.iterator().next();
     
      // add to event collection
     
      DocumentSample sample = new DocumentSample(
        categoryAnnotation.getStringValue(mCategoryFeature),
        cas.getDocumentText());
     
      documentSamples.add(sample);
    }
  }
View Full Code Here

Examples of org.apache.uima.cas.text.AnnotationFS

 
  @Override
  protected void setBestCategory(CAS tcas, String bestCategory) {
    FSIndex<AnnotationFS> categoryIndex = tcas.getAnnotationIndex(mCategoryType);
   
    AnnotationFS categoryAnnotation = (AnnotationFS) (categoryIndex.size() > 0 ?
        categoryIndex.iterator().next() : null);
   
    if (categoryIndex.size() > 0) {
      categoryAnnotation = (AnnotationFS) categoryIndex.iterator().next();
    }
    else {
      categoryAnnotation = tcas.createAnnotation(mCategoryType, 0,
          tcas.getDocumentText().length());
     
      tcas.getIndexRepository().addFS(categoryAnnotation);
    }   
   
    categoryAnnotation.setStringValue(mCategoryFeature, bestCategory);
  }
View Full Code Here

Examples of org.apache.uima.cas.text.AnnotationFS

      }
     
      Span[] names  = find(cas,
          (String[]) sentenceTokenList.toArray(new String[sentenceTokenList.size()]));
   
      AnnotationFS nameAnnotations[] = new AnnotationFS[names.length];
     
      for (int i = 0; i < names.length; i++) {
       
        int startIndex = ((AnnotationFS) sentenceTokenAnnotationList.get(
            names[i].getStart())).getBegin();
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.