コード例 #1
0
 /** {@inheritDoc} */
 @Override
 public void onMatching(
     String docUri, Type type, SortedSet<Annotation> goldAnnos, SortedSet<Annotation> sysAnnos) {
   if (goldAnnos.size() == 1 && sysAnnos.size() == 1) {
     Annotation goldAnno = goldAnnos.iterator().next();
     Annotation sysAnno = sysAnnos.iterator().next();
     if (goldAnno.getBegin() == sysAnno.getBegin() && goldAnno.getEnd() == sysAnno.getEnd()) {
       printRow(
           type.getShortName(),
           "Exact",
           goldAnno.getCoveredText(),
           String.valueOf(goldAnno.getBegin()),
           sysAnno.getCoveredText(),
           String.valueOf(sysAnno.getBegin()),
           docUri);
       return;
     }
   }
   printRow(
       type.getShortName(),
       "Partial",
       Joiner.on(" /// ").join(transform(goldAnnos, annoToTxt)),
       Joiner.on(", ").join(transform(goldAnnos, annoToOffset)),
       Joiner.on(" /// ").join(transform(sysAnnos, annoToTxt)),
       Joiner.on(", ").join(transform(sysAnnos, annoToOffset)),
       docUri);
 }
コード例 #2
0
ファイル: Mapper.java プロジェクト: sanju2010/ttc-project
 @Override
 public void process(JCas cas) throws AnalysisEngineProcessException {
   this.setSource(cas);
   this.setTarget(cas);
   AnnotationIndex<Annotation> index = cas.getAnnotationIndex(this.getSourceType());
   FSIterator<Annotation> iter = index.iterator();
   while (iter.hasNext()) {
     Annotation annotation = iter.next();
     String source = null;
     if (this.getSourceFeature() == null) {
       source = annotation.getCoveredText();
     } else {
       source = annotation.getStringValue(this.getSourceFeature());
     }
     if (source != null) {
       String target = this.getMapping().get(source);
       if (target != null) {
         if (this.update().booleanValue()) {
           this.update(cas, annotation, this.getTargetFeature(), target);
         } else {
           this.create(
               cas, this.getTargetFeature(), annotation.getBegin(), annotation.getEnd(), target);
         }
       }
     }
   }
 }
コード例 #3
0
 /** {@inheritDoc} */
 @Override
 public void onSpurious(String docUri, Type type, Annotation sysAnno) {
   printRow(
       type.getShortName(),
       "Spurious",
       null,
       null,
       sysAnno.getCoveredText(),
       String.valueOf(sysAnno.getBegin()),
       docUri);
 }
コード例 #4
0
 /** {@inheritDoc} */
 @Override
 public void onMissing(String docUri, Type type, Annotation goldAnno) {
   printRow(
       type.getShortName(),
       "Missing",
       goldAnno.getCoveredText(),
       String.valueOf(goldAnno.getBegin()),
       null,
       null,
       docUri);
 }
コード例 #5
0
 @Override
 public void process(JCas jCas) throws AnalysisEngineProcessException {
   if (windowClass != null) {
     for (Annotation window : JCasUtil.select(jCas, windowClass)) {
       String text = window.getCoveredText();
       createParentheticals(jCas, text, window.getBegin());
     }
   } else {
     String text = jCas.getDocumentText();
     createParentheticals(jCas, text, 0);
   }
 }
コード例 #6
0
  @Override
  public void process(JCas jcas) throws AnalysisEngineProcessException {
    Type type = jcas.getCas().getTypeSystem().getType(TYPE_NAME);
    Feature entityFeature = type.getFeatureByBaseName(ENTITY_FEATURE);
    Feature nameFeature = type.getFeatureByBaseName(NAME_FEATURE);

    for (Annotation annotation : jcas.getAnnotationIndex(TokenAnnotation.type)) {
      String tokenPOS = ((TokenAnnotation) annotation).getPosTag();

      if (NP.equals(tokenPOS) || NPS.equals(tokenPOS)) {
        AnnotationFS entityAnnotation =
            jcas.getCas().createAnnotation(type, annotation.getBegin(), annotation.getEnd());

        entityAnnotation.setStringValue(entityFeature, annotation.getCoveredText());

        String name =
            "OTHER"; // "OTHER" makes no sense. In practice, "PERSON", "COUNTRY", "E-MAIL", etc.
        if (annotation.getCoveredText().equals("Apache")) name = "ORGANIZATION";
        entityAnnotation.setStringValue(nameFeature, name);

        jcas.addFsToIndexes(entityAnnotation);
      }
    }
  }
コード例 #7
0
 @Override
 public String apply(Annotation input) {
   return input.getCoveredText();
 }
コード例 #8
0
 /**
  * Echo in the standard output (the console) the type and the covered text of the given annotation
  *
  * @param anAnnotation
  */
 public static void echo(Annotation anAnnotation) {
   System.out.printf(
       "type>%s<\t\tcoveredText>%s<\n",
       anAnnotation.getClass().getSimpleName(), anAnnotation.getCoveredText());
 }