Examples of AnnotationFS


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

    }
    for (int i = 0; i < list.size(); i++) {
      getIndexRepository().removeFS((FeatureStructure) list.get(i));
    }
    // Create a new document annotation.
    AnnotationFS doc = createAnnotation(ts.docType, 0, length);
    getIndexRepository().addFS(doc);
    // Set the language feature to the default value.
    doc.setStringValue(ts.langFeat, CAS.DEFAULT_LANGUAGE_NAME);
    return doc;
  }
View Full Code Here

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

    Type range = feature.getRange();
    List<AnnotationFS> list = getTargetAnnotation(annotation, type, stream);
    Collection<AnnotationFS> featureAnnotations = fe.getFeatureAnnotations(list, stream, parent,
            false);
    if (!featureAnnotations.isEmpty()) {
      AnnotationFS next = featureAnnotations.iterator().next();
      if (UIMAConstants.TYPE_BYTE.equals(range.getName())) {
        result = next.getByteValue(feature);
      } else if (UIMAConstants.TYPE_DOUBLE.equals(range.getName())) {
        result = next.getDoubleValue(feature);
      } else if (UIMAConstants.TYPE_FLOAT.equals(range.getName())) {
        result = next.getFloatValue(feature);
      } else if (UIMAConstants.TYPE_INTEGER.equals(range.getName())) {
        result = next.getIntValue(feature);
      } else if (UIMAConstants.TYPE_LONG.equals(range.getName())) {
        result = next.getLongValue(feature);
      } else if (UIMAConstants.TYPE_SHORT.equals(range.getName())) {
        result = next.getShortValue(feature);
      }
    }
    return result;
  }
View Full Code Here

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

    Feature feature = fe.getFeature(parent);
    List<AnnotationFS> list = getTargetAnnotation(annotation, type, stream);
    Collection<AnnotationFS> featureAnnotations = fe.getFeatureAnnotations(list, stream, parent,
            false);
    if (!featureAnnotations.isEmpty()) {
      AnnotationFS next = featureAnnotations.iterator().next();
      return next.getStringValue(feature);
    }
    return null;
  }
View Full Code Here

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

  public Collection<AnnotationFS> getFeatureAnnotations(Collection<AnnotationFS> annotations,
          RutaStream stream, RutaBlock parent, boolean checkOnFeatureValue) {
    Collection<AnnotationFS> result = new TreeSet<AnnotationFS>(comparator);
    List<Feature> features = getFeatures(parent);
    for (AnnotationFS eachBase : annotations) {
      AnnotationFS afs = eachBase;
      for (Feature feature : features) {
        if (feature.getRange().isPrimitive()) {
          if (this instanceof FeatureMatchExpression) {
            FeatureMatchExpression fme = (FeatureMatchExpression) this;
            if (checkOnFeatureValue) {
              if (fme.checkFeatureValue(afs, feature, stream, parent)) {
                result.add(afs);
              }
            } else {
              result.add(afs);
            }
            break;
          } else {
            result.add(afs);
          }
        } else {
          FeatureStructure value = afs.getFeatureValue(feature);
          afs = (AnnotationFS) value;
        }
      }
      if (!(this instanceof FeatureMatchExpression)) {
        if(stream.isVisible(afs)) {
View Full Code Here

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

  public static void addSourceDocumentInformation(CAS cas, File each) {
    Type sdiType = cas.getTypeSystem()
            .getType("org.apache.uima.examples.SourceDocumentInformation");
    if (sdiType != null) {
      if (cas.getAnnotationIndex(sdiType).size() == 0) {
        AnnotationFS sdi = cas.createAnnotation(sdiType, cas.getDocumentAnnotation().getBegin(),
                cas.getDocumentAnnotation().getEnd());
        Feature uriFeature = sdiType.getFeatureByBaseName("uri");
        sdi.setStringValue(uriFeature, each.toURI().getPath());
        cas.addFsToIndexes(sdi);
      }
    }
  }
View Full Code Here

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

      Collections.sort(selection, new AnnotationComparator());
    } else {
      Map<Integer, AnnotationFS> view = getDocument().getView(getAnnotationMode());

      AnnotationFS annotation = view.get(mCursorPosition);

      if (annotation == null) {
        annotation = view.get(mCursorPosition - 1);
      }
View Full Code Here

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

 
  public void draw(Annotation annotation, GC gc, StyledText textWidget, int offset, int length,
          Color color) {
    if (length > 0) {
      if ((annotation instanceof EclipseAnnotationPeer)) {
        AnnotationFS annotationFS = ((EclipseAnnotationPeer) annotation).getAnnotationFS();

        if (gc != null) {
          Rectangle bounds = textWidget.getTextBounds(offset, offset + length - 1);

          gc.setForeground(color);

          boolean isDrawOpenBracket = annotationFS.getBegin() == offset;
          // and no space before offset
          if (isDrawOpenBracket && offset > 1 && !isWhitespace(textWidget, offset - 1)) {
            gc.drawLine(bounds.x, bounds.y + bounds.height - 1, bounds.x + BRACKET_WIDTH, bounds.y
                    + bounds.height - 1);
           
            gc.drawLine(bounds.x, bounds.y, bounds.x, bounds.y + bounds.height - 1);

            gc.drawLine(bounds.x, bounds.y, bounds.x + BRACKET_WIDTH, bounds.y);
          }

          boolean isDrawCloseBracket = annotationFS.getEnd() == offset + length;
          // and no space after offset
          if (isDrawCloseBracket && offset + length <= textWidget.getText().length()
                  && !isWhitespace(textWidget, offset + length)) {
            gc.drawLine(bounds.x + bounds.width, bounds.y + bounds.height - 1, bounds.x
                    + bounds.width - BRACKET_WIDTH, bounds.y + bounds.height - 1);
View Full Code Here

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

  @Override
  public int compare(Viewer viewer, Object aObject, Object bObject) {
    int result = 1;

    if ((aObject instanceof IAdaptable && bObject instanceof IAdaptable)) {
      AnnotationFS aAnnotation = (AnnotationFS) ((IAdaptable) aObject)
              .getAdapter(AnnotationFS.class);

      AnnotationFS bAnnotation = (AnnotationFS) ((IAdaptable) bObject)
              .getAdapter(AnnotationFS.class);

      result = mComperator.compare(aAnnotation, bAnnotation);
    }
View Full Code Here

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

public class TextColorDrawingStrategy implements IDrawingStrategy {

  public void draw(Annotation annotation, GC gc, StyledText textWidget, int offset, int length, Color color) {
    if (length > 0) {
      if ((annotation instanceof EclipseAnnotationPeer)) {
        AnnotationFS annotationFS = ((EclipseAnnotationPeer) annotation).getAnnotationFS();

        if (gc != null) {
         
          int start = offset;
          int end = offset + length - 1;
View Full Code Here

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

        }

        int start = selection.x;
        int end = start + selection.y;

        AnnotationFS annotation = getDocument().getCAS().createAnnotation(getAnnotationMode(),
                start, end);

        getDocument().addFeatureStructure(annotation);

        setAnnotationSelection(annotation);
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.