Examples of AnnotationFS


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

        CAS.TYPE_NAME_STRING);
  }

  private void addChunkAnnotation(CAS tcas, AnnotationFS tokenAnnotations[],
      String tag, int start, int end) {
    AnnotationFS chunk = tcas.createAnnotation(mChunkType,
        tokenAnnotations[start].getBegin(), tokenAnnotations[end - 1].getEnd());

    chunk.setStringValue(mChunkFeature, tag);

    tcas.getIndexRepository().addFS(chunk);
  }
View Full Code Here

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

   
    FSIndex<AnnotationFS> tokenAnnotationIndex = tcas.getAnnotationIndex(mTokenType);

    String tokens[] = new String[tokenAnnotationIndex.size()];
    String pos[] = new String[tokenAnnotationIndex.size()];
    AnnotationFS tokenAnnotations[] = new AnnotationFS[tokenAnnotationIndex
        .size()];

    int index = 0;

    for (AnnotationFS tokenAnnotation : tokenAnnotationIndex) {
View Full Code Here

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

    Iterator<AnnotationFS> chunkIterator = tcas.createFilteredIterator(
        chunkIndex.iterator(), containingConstraint);
   
    while (chunkIterator.hasNext()) {
      AnnotationFS chunkAnnotation = (AnnotationFS) chunkIterator.next();
      processChunk(tcas, (chunkAnnotation));
    }
  }
View Full Code Here

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

    List<String> tokens = new ArrayList<String>();
    List<String> tags = new ArrayList<String>();;
    List<String> chunkTags = new ArrayList<String>();;
   
    while (tokenIterator.hasNext()) {
      AnnotationFS tokenAnnotation = tokenIterator.next();
     
      tokens.add(tokenAnnotation.getCoveredText().trim());
      tags.add(tokenAnnotation.getFeatureValueAsString(mPOSFeature));
      chunkTags.add(chunkTag);
    }
   
    mChunkSamples.add(new ChunkSample(tokens, tags, chunkTags));
  }
View Full Code Here

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

      int sentenceOffset = sentence.getBegin();

      StringBuilder tokeninzedSentenceLog = new StringBuilder();

      AnnotationFS tokenAnnotations[] = new AnnotationFS[tokenSpans.length];

      for (int i = 0; i < tokenSpans.length; i++) {
        tokenAnnotations[i] = cas
            .createAnnotation(tokenType,
                sentenceOffset + tokenSpans[i].getStart(), sentenceOffset
View Full Code Here

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

        UimaUtil.removeAnnotations(cas, containerAnnotation, sentenceType);
      }

      Span[] sentPositions = detectSentences(text);

      AnnotationFS sentences[] = new AnnotationFS[sentPositions.length];

      for (int i = 0; i < sentPositions.length; i++) {

        sentences[i] = cas.createAnnotation(sentenceType,
            sentPositions[i].getStart() + containerAnnotation.getBegin(),
View Full Code Here

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

          ComposedRuleElementMatch containerMatch, int nextDepth, RutaRuleElement sideStepOrigin,
          RuleElement entryPoint, RutaStream stream, InferenceCrowd crowd) {
    List<RuleMatch> result = new ArrayList<RuleMatch>();
    // what is the next stuff that should match?
    if (nextElement == null) {
      AnnotationFS afs = getCoveredByWildCard(after, annotation, null, stream);
      doMatch(afs, ruleMatch, containerMatch, annotation == null, stream, crowd);
      ComposedRuleElement composed = (ComposedRuleElement) getContainer();
      result = composed.fallbackContinue(after, ruleMatch.matched(), afs, ruleMatch, ruleApply,
              containerMatch, sideStepOrigin, entryPoint, stream, crowd);
    } else if (nextElement instanceof RutaRuleElement) {
View Full Code Here

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

  private List<RuleMatch> tryWithNextComposed(boolean after, AnnotationFS annotation,
          ComposedRuleElement cre, RuleMatch ruleMatch, RuleApply ruleApply,
          ComposedRuleElementMatch containerMatch, int nextDepth, RutaRuleElement sideStepOrigin,
          RutaStream stream, InferenceCrowd crowd) {
    List<RuleMatch> result = new ArrayList<RuleMatch>();
    AnnotationFS nextOne = annotation;
    boolean doneHere = false;
    while (!doneHere && (nextOne = getNextPositionForComposed(cre, after, nextOne, stream)) != null) {
      RutaBasic endAnchor = stream.getEndAnchor(nextOne.getBegin());
      ComposedRuleElementMatch extendedContainerMatch = containerMatch.copy();
      RuleMatch extendedMatch = ruleMatch.copy(extendedContainerMatch);
      AnnotationFS coveredByWildCard = getCoveredByWildCard(after, annotation, nextOne, stream);

      doMatch(coveredByWildCard, extendedMatch, extendedContainerMatch, annotation == null, stream,
              crowd);
      if (extendedMatch.matched()) {
        ComposedRuleElementMatch nextContainerMatch = getContainerMatchOfNextElement(
View Full Code Here

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

  }

  private AnnotationFS getNextPositionForComposed(ComposedRuleElement cre, boolean after,
          AnnotationFS annotation, RutaStream stream) {
    RuleElement element = getNextAtomicRuleElement(cre, after);
    AnnotationFS result = null;
    Boolean conjunct = cre.getConjunct();
    if (element instanceof WildCardRuleElement) {
      if (after) {
        return stream.getAnchor(after, annotation.getEnd());
      } else {
        return stream.getAnchor(after, annotation.getBegin());
      }
    } else if(conjunct != null && !conjunct){
      // disjunctive
      List<RuleElement> ruleElements = cre.getRuleElements();
      List<AnnotationFS> nextPostions = new ArrayList<AnnotationFS>();
      for (RuleElement ruleElement : ruleElements) {
        if(ruleElement instanceof ComposedRuleElement) {
          AnnotationFS nextPositionForComposed = getNextPositionForComposed((ComposedRuleElement) ruleElement, after, annotation, stream);
          if(nextPositionForComposed != null) {
            nextPostions.add(nextPositionForComposed);
          }
        } else if(ruleElement instanceof RutaRuleElement) {
          AnnotationFS nextPositionForAtomic = getNextPositionForAtomic(after, annotation, stream, ruleElement, result);
          if(nextPositionForAtomic != null) {
            nextPostions.add(nextPositionForAtomic);
          }
        }
      }
View Full Code Here

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

      }
    } else if (matcher instanceof RutaLiteralMatcher) {
      RutaLiteralMatcher lm = (RutaLiteralMatcher) matcher;
      IStringExpression expression = lm.getExpression();
      String stringValue = expression.getStringValue(parent, annotation, stream);
      AnnotationFS documentAnnotation = stream.getDocumentAnnotation();
      int delta = documentAnnotation.getBegin();
      String document = documentAnnotation.getCoveredText();
      int pointer = annotation.getEnd() - delta;
      int indexOf = document.indexOf(stringValue, pointer);
      if (indexOf < 0) {
        return null;
      } else {
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.