Examples of AnnotationSet


Examples of gate.AnnotationSet

    parms = Factory.newFeatureMap();
    File docFile = new File(testingDir,"news1pre.xml");
    parms.put("sourceUrl",docFile.toURI().toURL());
    Document doc = (Document)
         Factory.createResource("gate.corpora.DocumentImpl", parms);
    AnnotationSet lookups = doc.getAnnotations("EXT").get("Lookup");
    assertEquals(0,lookups.size());
    // run the gazetteer on the document
    eg.setDocument(doc);
    eg.execute();
    AnnotationDiffer differ = new AnnotationDiffer();
    differ.setSignificantFeaturesSet(new HashSet<String>());
    AnnotationSet keys = doc.getAnnotations().get("Lookup");
    System.out.println("Lookups old: "+keys.size());
    AnnotationSet responses = doc.getAnnotations("EXT").get("Lookup");
    System.out.println("Lookups new: "+responses.size());
    differ.calculateDiff(keys, responses);
    int correct = differ.getCorrectMatches();
    int falsePositives = differ.getFalsePositivesStrict();
    int missing = differ.getMissing();
    System.out.println("Diff: correct="+correct+" false positives="+falsePositives+" missing="+missing);
View Full Code Here

Examples of gate.AnnotationSet

    inputAnnotSet = document.getAnnotations(getInputAS());
    document.getAnnotations(getOutputAS());
    if (inputAnnotSet == null || inputAnnotSet.isEmpty()) {
      System.err.println("Null or empty input annotations.");
    } else {
      AnnotationSet codableSpanAnnotations = inputAnnotSet.get(getInputAnnotationType());
      if (codableSpanAnnotations == null || codableSpanAnnotations.size() == 0) {
        codableSpanAnnotations = deriveCodableSpansFromDocumentLines();
      }
      if (codableSpanAnnotations == null || codableSpanAnnotations.isEmpty()) {
        throw new GateRuntimeException("NobleCoder Warning:"
            + "No codable spans found for processing!");
      }
      for (gate.Annotation codableSpanAnnotation : codableSpanAnnotations) {
        currentCodableSpanAnnotation = codableSpanAnnotation;
View Full Code Here

Examples of gate.AnnotationSet

      features.put("definition", concept.getDefinition());
      features.put("preferredTerm", concept.getPreferredTerm().getText());
      features.put("synonyms", StringUtils.join(concept.getSynonyms(), ";"));
      features.put("tuis", joinTuis(concept.getSemanticTypes()));
      features.put("stys", joinStys(concept.getSemanticTypes()));
      AnnotationSet nobleCoderSet = getDocument().getAnnotations(
          getOutputAS());
      nobleCoderSet.add(sPos, ePos, getOutputAnnotationType(), features);
    } catch (Exception x) {
      if (debugging) {
        StringBuffer sb = new StringBuffer();
        sb.append("\n\nFailed to add Concept:");
        sb.append("\n\tDocument name ==> " + getDocument().getName());
View Full Code Here

Examples of gate.AnnotationSet

    inputAnnotSet = document.getAnnotations(getInputAS());
    document.getAnnotations(getOutputAS());
    if (inputAnnotSet == null || inputAnnotSet.isEmpty()) {
      System.err.println("Null or empty input annotations.");
    } else {
      AnnotationSet codableSpanAnnotations = inputAnnotSet.get(getInputAnnotationType());
      if (codableSpanAnnotations == null || codableSpanAnnotations.size() == 0) {
        codableSpanAnnotations = deriveCodableSpansFromDocumentLines();
      }
      if (codableSpanAnnotations == null || codableSpanAnnotations.isEmpty()) {
        throw new GateRuntimeException("NobleCoder Warning:"
            + "No codable spans found for processing!");
      }
      for (gate.Annotation codableSpanAnnotation : codableSpanAnnotations) {
        currentCodableSpanAnnotation = codableSpanAnnotation;
View Full Code Here

Examples of gate.AnnotationSet

      features.put("definition", concept.getDefinition());
      features.put("preferredTerm", concept.getPreferredTerm().getText());
      features.put("synonyms", StringUtils.join(concept.getSynonyms(),";"));
      features.put("tuis", joinTuis(concept.getSemanticTypes()));
      features.put("stys", joinStys(concept.getSemanticTypes()));
      AnnotationSet nobleCoderSet = getDocument().getAnnotations(
          getOutputAS());
      nobleCoderSet.add(sPos, ePos, getOutputAnnotationType(), features);
    } catch (Exception x) {
      if (debugging) {
        StringBuffer sb = new StringBuffer();
        sb.append("\n\nFailed to add Concept:");
        sb.append("\n\tDocument name ==> " + getDocument().getName());
View Full Code Here

Examples of gate.AnnotationSet

     * @param quest
     */
    public void parseQuestion(String quest, String col_data) throws Exception {

        this.question = cleanQuestion(quest);
        AnnotationSet ann = gateChunker.ParseQuestion(question);
        System.out.println("\n-----Start(LinguisticComponent.java): "
                + "cac ham GetAnnotationsType(...) -----\n");

        Lookup_ann = gateChunker.GetAnnotationsType(question, "Lookup", ann);
        //Person_ann = gateChunker.GetAnnotationsType(question, "Person", ann);
View Full Code Here

Examples of gate.AnnotationSet

  private String dictionaryEncoding = "UTF-8";

  @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 sentence annotations
    AnnotationSet sentences = annotations.get("Sentence");

    // order sentences

    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> tokenList = new LinkedList<Annotation>();

      for (Iterator iterator2 = sentenceTokens.iterator(); iterator2
          .hasNext();) {
        tokenList.add((Annotation) iterator2.next());

      }
View Full Code Here

Examples of gate.AnnotationSet

  private List<NameFinder> finder;

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

    AnnotationSet outputAnnots;
    if (outputASName != null && outputASName.length() > 0)
      outputAnnots = document.getAnnotations(outputASName);
    else
      outputAnnots = document.getAnnotations();
View Full Code Here

Examples of gate.AnnotationSet

  URL model;

  @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();

    // get sentence annotations
    //AnnotationSet sentences = document.getAnnotations("Sentence");

    // getdoc.get text
    String text = document.getContent().toString();
    // run tokenizer
    Span[] spans = tokenizer.tokenizePos(text);
    // compare the resulting
    // spans and add annotations

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

      FeatureMap fm = Factory.newFeatureMap();
      // type
      fm.put("source", "openNLP");
      fm.put("string", text.substring(spans[i].getStart(), spans[i]
          .getEnd()));
      // source
//      fm.put("type", "urn:lsid:ontotext.com:kim:iextraction:Token");

      try {
        annotations.add(Long.valueOf(spans[i].getStart()), Long
            .valueOf(spans[i].getEnd()), "Token", fm);

      } catch (InvalidOffsetException e) {
        e.printStackTrace();
        throw new RuntimeException(e);
View Full Code Here

Examples of gate.AnnotationSet

  @Override
  public void execute() throws ExecutionException {
    boolean isSentenceSplitted = false;
    // 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();
    // run tokenizer
    int[] spans = splitter.sentPosDetect(text);
    // compare the resulting
    // sentences and add annotations
    int prevSpan = 0;
    for (int i = 0; i < spans.length; i++) {

      FeatureMap fm = Factory.newFeatureMap();
      // type
      fm.put("source", "openNLP");
      // source
      // fm.put("type", "urn:lsid:ontotext.com:kim:iextraction:Sentence");

      try {
        // annotations.add(Long.valueOf(spans[i].getStart()),
        // Long.valueOf(spans[i].getEnd()), "Sentence", fm);
        // annotations.add(i == 0 ? Long.valueOf(prevSpan) : Long
        // .valueOf(prevSpan + countSpaces(prevSpan - 1)),
        // i == (spans.length - 1) ? Long.valueOf(spans[i]) : Long
        // .valueOf(spans[i] - 1), "Sentence", fm);
        int start = prevSpan;
        int end = spans[i];

        // remove leading spaces of a sentence
        for (int j = start; j < end
            && Character.isWhitespace(text.charAt(j)); j++) {
          start = j + 1;
        }

        // remove trailing spaces of a sentence
        if (end > 1) {
          for (int j = end; j > start
              && Character.isWhitespace(text.charAt(j - 1)); j--) {
            end = j - 1;
          }
        }

        annotations.add(Long.valueOf(start), Long.valueOf(end),
            "Sentence", fm);
        if(!isSentenceSplitted)
          isSentenceSplitted = true;

      } catch (InvalidOffsetException e) {
        e.printStackTrace();
        throw new RuntimeException(e);
      }

      prevSpan = spans[i];
    }
    if(!isSentenceSplitted){
      FeatureMap fm = Factory.newFeatureMap();
      // type
      fm.put("source", "openNLP");
      try {
        annotations.add(new Long(0), new Long(text.length()),
            "Sentence", fm);
      } catch (InvalidOffsetException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
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.