Examples of AnnotationSet


Examples of gate.AnnotationSet

  @SuppressWarnings("unchecked")
  @Override
  public void execute() throws ExecutionException {
    // text doc annotations
    AnnotationSet annotations;
    if (annotationSetName != null && annotationSetName.length() > 0) {
      annotations = document.getAnnotations(annotationSetName);
    } else {
      annotations = document.getAnnotations();
    }

    // getdoc.get text
    // String text = document.getContent().toString();

    // get token and sentence annotations
    AnnotationSet sentences = annotations.get("Sentence");
    AnnotationSet tokensAS = annotations.get("Token");

    if (sentences != null && sentences.size() > 0 && tokensAS != null
        && tokensAS.size() > 0) {

      // order them
      List<Annotation> sentList = new LinkedList<Annotation>();

      for (Iterator iterator = sentences.iterator(); iterator.hasNext();) {
        sentList.add((Annotation) iterator.next());

      }

      java.util.Collections.sort(sentList,
          new gate.util.OffsetComparator());

      // for each sentence get token annotations
      for (Iterator iterator = sentList.iterator(); iterator.hasNext();) {
        Annotation annotation = (Annotation) iterator.next();

        AnnotationSet sentenceTokens = annotations.get("Token",
            annotation.getStartNode().getOffset(), annotation
                .getEndNode().getOffset());

        // create a list

        List<Annotation> annList = new LinkedList<Annotation>();

        for (Iterator<Annotation> iterator2 = sentenceTokens.iterator(); iterator2
            .hasNext();) {
          annList.add(iterator2.next());

        }

        // order on offset
        Collections.sort(annList, new gate.util.OffsetComparator());

        // make the array be string[] sentence
        String[] tokens = new String[sentenceTokens.size()];
        String[] postags = new String[sentenceTokens.size()];
        int i = 0;
        for (Iterator iterator3 = annList.iterator(); iterator3
            .hasNext();) {

          Annotation token = (Annotation) iterator3.next();
View Full Code Here

Examples of gate.AnnotationSet

    String locType = "location";
    String orgType = "org";
    String perType = "person";

    // extract sentences from text
    AnnotationSet sentences = inputAS.get(sequenceType);
    ArrayList<Element<Object>> elements = new ArrayList<Element<Object>>();
    OffsetComparator oc = new OffsetComparator();
    SparseVector[] x;
    Object[] y;
    ElementSequence<Element<Object>> sequence;
    Element<Object> element;
    ArrayList<Annotation> tokens, dToks, lToks, oToks, pToks;
    AnnotationSet dats, locs, orgs, pers;
    String chunk, label;

    for (Annotation sentence : sentences) {

      //extract NEs from sentence
View Full Code Here

Examples of gate.AnnotationSet

    pipeline.execute();
    Factory.deleteResource(corpus);
    Factory.deleteResource(pipeline);

    // extract sentences from text
    AnnotationSet sentences = inputAS.get(sequenceType);
    ArrayList<Element<Object>> elements = new ArrayList<Element<Object>>();
    OffsetComparator oc = new OffsetComparator();
    SparseVector[] x;
    Object[] y;
    ElementSequence<Element<Object>> sequence;
View Full Code Here

Examples of gate.AnnotationSet

    pipeline.execute();
    Factory.deleteResource(corpus);
    Factory.deleteResource(pipeline);

    // extract sentences from text
    AnnotationSet sentences = inputAS.get(sequenceType);
    ArrayList<Element<Object>> elements = new ArrayList<Element<Object>>();
    Alphabet labelAlphabet = tagger.getYAlphabet();
    OffsetComparator oc = new OffsetComparator();
    SparseVector[] x;
    Object[] y;
View Full Code Here

Examples of gate.AnnotationSet

    //specify noun and verb chunk types
    String nChunkType = "nchunk";
    String vChunkType = "vchunk";

    // extract sentences from text
    AnnotationSet sentences = inputAS.get(sequenceType);
    ArrayList<Element<Object>> elements = new ArrayList<Element<Object>>();
    OffsetComparator oc = new OffsetComparator();
    SparseVector[] x;
    Object[] y;
    ElementSequence<Element<Object>> sequence;
    Element<Object> element;
    ArrayList<Annotation> tokens, nToks, vToks;
    AnnotationSet nChunks, vChunks;
    String chunk, label;

    for (Annotation sentence : sentences) {

      //extract noun and verb chunks from sentence
View Full Code Here

Examples of gate.AnnotationSet

  @SuppressWarnings("unchecked")
  public void extractData(String sequenceType, String elementType, String labelType)
  throws ExecutionException, InvalidOffsetException, ResourceInstantiationException {

    //extract tokens from text
    AnnotationSet tokens = inputAS.get(sequenceType);
    ArrayList<Element<Object>> elements = new ArrayList<Element<Object>>();
    ElementSequence<Element<Object>> sequence;
    SparseVector[] x;
    Object[] y;
    char[] chars;
View Full Code Here

Examples of gate.AnnotationSet

    pipeline.execute();
    Factory.deleteResource(corpus);
    Factory.deleteResource(pipeline);
   
    // extract sentences from text
    AnnotationSet sentences = inputAS.get(sequenceType);
    ArrayList<Element<Object>> elements = new ArrayList<Element<Object>>();
    Alphabet labelAlphabet = tagger.getYAlphabet();
    OffsetComparator oc = new OffsetComparator();
    SparseVector[] x;
    Object[] y;
View Full Code Here

Examples of gate.AnnotationSet

    pipeline.execute();
    Factory.deleteResource(corpus);
    Factory.deleteResource(pipeline);

    // extract sentences from text
    AnnotationSet sentences = inputAS.get(sequenceType);
    ArrayList<Element<Object>> elements = new ArrayList<Element<Object>>();
    Alphabet labelAlphabet = tagger.getYAlphabet();
    OffsetComparator oc = new OffsetComparator();
    SparseVector[] x;
    Object[] y;
View Full Code Here

Examples of gate.AnnotationSet

            // get the application and assign the corpus to it
            this.GATEapplication.setCorpus(corpus);
            // process it with GATE
            this.GATEapplication.execute();

            AnnotationSet annots = null;
            if ("".equals(filters.getAnnotationSetName()))
                annots = gatedocument.getAnnotations();
            else
                annots = gatedocument.getAnnotations(filters
                        .getAnnotationSetName());
View Full Code Here

Examples of gate.AnnotationSet

            }
        }

        // finally the annotations as original markups
        // TODO change the name of the annotation set via config
        AnnotationSet outputAS = gatedocument
                .getAnnotations("Original markups");
        for (Annotation annot : inputDoc.getAnnotations()) {
            // add to outputAS as a GATE annotation
            FeatureMap features = Factory.newFeatureMap();
            features.putAll(annot.getFeatures());
            outputAS.add(annot.getStart(), annot.getEnd(), annot.getType(),
                    features);
        }
        return gatedocument;
    }
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.