Package org.apache.uima.jcas.tcas

Examples of org.apache.uima.jcas.tcas.Annotation


      Map<List<Annotation>, TemporalTextRelation> dischargeTimeRelationLookup;
        dischargeTimeRelationLookup = new HashMap<>();
        if (this.isTraining()) {
          dischargeTimeRelationLookup = new HashMap<>();
          for (TemporalTextRelation relation : JCasUtil.select(jCas, TemporalTextRelation.class)) {
            Annotation arg1 = relation.getArg1().getArgument();
            Annotation arg2 = relation.getArg2().getArgument();
            // The key is a list of args so we can do bi-directional lookup
            if(arg1 instanceof TimeMention && arg2 instanceof EventMention ){
              if( arg1==admissionTime){
                dischargeTimeRelationLookup.put(Arrays.asList(arg1, arg2), relation);
                continue;
View Full Code Here


  public void process(JCas jCas) throws AnalysisEngineProcessException {
    for(TemporalLink link : JCasUtil.select(jCas, TemporalLink.class)){
      BinaryTextRelation rel = new BinaryTextRelation(jCas);
      RelationArgument arg1 = new RelationArgument(jCas);
      Anchor source = link.getSource();
      arg1.setArgument(new Annotation(jCas, source.getBegin(), source.getEnd()));
      arg1.addToIndexes();
     
      RelationArgument arg2 = new RelationArgument(jCas);
      Anchor target = link.getTarget();
      arg2.setArgument(new Annotation(jCas, target.getBegin(), target.getEnd()));
      arg2.addToIndexes();
     
      String cat = getMappedCategory(link.getRelationType());
      if(cat.endsWith("-1")){
        rel.setArg1(arg2);
View Full Code Here

      // /
      if (!filteredIterator.hasNext()) {
              throw new RuntimeException(
                              "Surrounding sentence annotation not found!!");
      }
      Annotation sentenceAnnotation = filteredIterator.next();
      Sentence sentence = (Sentence) sentenceAnnotation;
      int lineNumber = sentence.getSentenceNumber() + 1;

      // FSIterator<Annotation> tokensInSentenceIterator = jcas
      // .getAnnotationIndex(baseTokenTypeId).subiterator(sentence);
      //
      // if (!tokensInSentenceIterator.hasNext()) {
      // throw new RuntimeException("First token in sentence not found!!");
      // }
      // Annotation firstTokenAnnotation = tokensInSentenceIterator.next();
      // BaseToken firstToken = (BaseToken) firstTokenAnnotation;
      // int firstTokenInSentenceNumber = firstToken.getTokenNumber();

      FSIterator<Annotation> beginTokenInSentenceIterator = constraintConstructorFindContainedWithin
                      .createFilteredIterator(problemBegin, problemEnd, baseTokenType);

      // if (!beginTokenInSentenceIterator.hasNext()) {
      // throw new RuntimeException("First token in sentence not found!!");
      // }
      // Annotation beginTokenAnnotation =
      // beginTokenInSentenceIterator.next();
      // BaseToken beginToken = (BaseToken) beginTokenAnnotation;
      // int beginTokenNumber = beginToken.getTokenNumber();
      // int beginTokenWordNumber = beginTokenNumber
      // - firstTokenInSentenceNumber;
      BaseToken beginToken = this
                      .getNextNonEOLToken(beginTokenInSentenceIterator);
      int beginTokenWordNumber = this.sentenceToTokenNumberMap.get(sentence)
                      .indexOf(beginToken);

      beginTokenInSentenceIterator.moveToLast();
      if (!beginTokenInSentenceIterator.hasNext()) {
              throw new RuntimeException("First token in sentence not found!!");
      }
      Annotation endTokenAnnotation = beginTokenInSentenceIterator.next();
      BaseToken endToken = (BaseToken) endTokenAnnotation;
      // int endTokenNumber = endToken.getTokenNumber();
      // int endTokenWordNumber = endTokenNumber - firstTokenInSentenceNumber;
      int endTokenWordNumber = this.sentenceToTokenNumberMap.get(sentence)
                      .indexOf(endToken);
View Full Code Here

  private int printAnnos(JCas jCas, int type) {
    AnnotationIndex<Annotation> sentences = jCas.getAnnotationIndex(type);
    Iterator<Annotation> iter = sentences.iterator();
    int sentCount = 0;
    while (iter.hasNext()) {
      Annotation sent = (Annotation) iter.next();
      System.out.println(sent.getClass().getSimpleName() + " ["
          + sent.getCoveredText() + "]");
      sentCount++;
    }
    return sentCount;
  }
View Full Code Here

          if (spanEnd > end) {
            end = spanEnd;
          }
        }

        Annotation annotation;
        if (type.equals("EVENT")) {
          String docTimeRel = removeSingleChildText(propertiesElem, "DocTimeRel", id);
          if (docTimeRel == null) {
            error("no docTimeRel, assuming OVERLAP", id);
            docTimeRel = "OVERLAP";
View Full Code Here

      String targetID,
      String category,
      Map<String, Annotation> idToAnnotation,
      String causeID) {
    if (sourceID != null && targetID != null) {
      Annotation source = getArgument(sourceID, idToAnnotation, causeID);
      Annotation target = getArgument(targetID, idToAnnotation, causeID);
      if (source != null && target != null) {
        RelationArgument sourceArg = new RelationArgument(jCas);
        sourceArg.setArgument(source);
        sourceArg.addToIndexes();
        RelationArgument targetArg = new RelationArgument(jCas);
View Full Code Here

  private static Annotation getArgument(
      String id,
      Map<String, Annotation> idToAnnotation,
      String causeID) {
    Annotation annotation = idToAnnotation.get(id);
    if (annotation == null) {
      error("no annotation with id " + id, causeID);
    }
    return annotation;
  }
View Full Code Here

      _entityIdCollection = entityIdCollection;
      populateTlinkTypesArray( tlinkList );
   }

   public TlinkTypeSet getTlinkTypes( final BinaryTextRelation tlink ) {
      final Annotation entityA = tlink.getArg1().getArgument();
      final Annotation entityB = tlink.getArg2().getArgument();
      final int entityIdA = _entityIdCollection.getAnnotationId( entityA );
      final int entityIdB = _entityIdCollection.getAnnotationId( entityB );
      final int indexA = _entityIdList.indexOf( entityIdA );
      final int indexB = _entityIdList.indexOf( entityIdB );
      return getTlinkTypes( indexA, indexB );
View Full Code Here

      return closedTlinks;
   }

   private BinaryTextRelation createTlink( final JCas jCas, int row, final int column, final TlinkType tlinkType ) {
     //      final ClassType tlinkClass = new CustomClassType( "TLINK" );
     final Annotation entityA = getAnnotation( row );
     final Annotation entityB = getAnnotation( column );
     if ( entityA == null || entityB == null ) {
       return null;
     }
     //      final Attribute tlinkAttribute = tlinkType.getAsAttribute();
     ////      if ( entityB instanceof Timex ) {
View Full Code Here

      goldMentions.addAll(JCasUtil.select(goldView, EntityMention.class));
      goldMentions.addAll(JCasUtil.select(goldView, Modifier.class));
      CasCopier copier = new CasCopier(goldView.getCas(), systemView.getCas());
      for (IdentifiedAnnotation goldMention : goldMentions)
      {
        Annotation copy = (Annotation) copier.copyFs(goldMention);
        Feature sofaFeature = copy.getType().getFeatureByBaseName("sofa");
        copy.setFeatureValue(sofaFeature, systemView.getSofa());
        copy.addToIndexes();
      }
    }
View Full Code Here

TOP

Related Classes of org.apache.uima.jcas.tcas.Annotation

Copyright © 2018 www.massapicom. 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.