Examples of RelationArgument


Examples of org.apache.ctakes.typesystem.type.relation.RelationArgument

      if (!temporalRelation.isEmpty()){
        TLinkTypeArray2 relationArray = new TLinkTypeArray2(temporalRelation, new AnnotationIdCollection(temporalRelation));

        int addedCount = 0;
        for (BinaryTextRelation relation : relationArray.getClosedTlinks(jCas)) {
          RelationArgument arg1 = relation.getArg1();
          RelationArgument arg2 = relation.getArg2();
          String relationType = relation.getCategory();
          if(relationType.equals("CONTAINED-BY")||relationType.equals("AFTER")){//ignore these two categories, because their reciprocal already exist.
            continue;
          }
          //check if the inferred relation new:
          Collection<BinaryTextRelation> relations = annotationsToRelation.get(Arrays.asList(arg1.getArgument(), arg2.getArgument()));
          if(relations.isEmpty()){ //if haven't seen this inferred relation before, then add this relation
            arg1.addToIndexes();
            arg2.addToIndexes();
            relation.addToIndexes();
            addedCount++;
          }   
        }
       
View Full Code Here

Examples of org.apache.ctakes.typesystem.type.relation.RelationArgument

    private String goldViewName = CAS.NAME_DEFAULT_SOFA;

    @Override
    public void process(JCas jCas) throws AnalysisEngineProcessException {
      for(BinaryTextRelation relation : Lists.newArrayList(JCasUtil.select(jCas, BinaryTextRelation.class))){
          RelationArgument arg1 = relation.getArg1();
          RelationArgument arg2 = relation.getArg2();
          if(arg1.getArgument() instanceof EventMention && arg2.getArgument() instanceof EventMention){
            // these are the kind we keep.
            continue;
          }
          arg1.removeFromIndexes();
          arg2.removeFromIndexes();
          relation.removeFromIndexes();
      }
    }  
View Full Code Here

Examples of org.apache.ctakes.typesystem.type.relation.RelationArgument

            }
          } else {
            String outcome = this.classifier.classify(features);
            if(outcome!=null){
              // add the relation to the CAS
                RelationArgument relArg1 = new RelationArgument(jCas);
                relArg1.setArgument(eventMention);
                relArg1.setRole("Argument");
                relArg1.addToIndexes();
                RelationArgument relArg2 = new RelationArgument(jCas);
                relArg2.setArgument(admissionTime);
                relArg2.setRole("Related_to");
                relArg2.addToIndexes();
                TemporalTextRelation relation = new TemporalTextRelation(jCas);
                relation.setArg1(relArg1);
                relation.setArg2(relArg2);
                relation.setCategory(outcome);
                relation.addToIndexes();
View Full Code Here

Examples of org.apache.ctakes.typesystem.type.relation.RelationArgument

      for(BinaryTextRelation relation : Lists.newArrayList(JCasUtil.select(goldView, BinaryTextRelation.class))) {
        if(! relation.getCategory().equals("CONTAINS")) {
          continue;
        }
       
        RelationArgument arg1 = relation.getArg1();                                                                            
        RelationArgument arg2 = relation.getArg2();

        String eventText;
        String timeText;
        if(arg1.getArgument() instanceof TimeMention && arg2.getArgument() instanceof EventMention) {
          timeText = arg1.getArgument().getCoveredText().toLowerCase();
          eventText = Utils.normalizeEventText(jCas, arg2.getArgument());
        } else if(arg1.getArgument() instanceof EventMention && arg2.getArgument() instanceof TimeMention) {
          eventText = Utils.normalizeEventText(jCas, arg1.getArgument());
          timeText = arg2.getArgument().getCoveredText().toLowerCase()
        } else {
          // this is not a event-time relation
          continue;
        }   

        HashSet<String> timeUnits = Utils.getTimeUnits(timeText);
        if(textToDistribution.containsKey(eventText) && timeUnits.size() > 0) {
          // there is duration information and we are able to get time units
          Map<String, Float> eventDistribution = textToDistribution.get(eventText);
          Map<String, Float> timeDistribution = Utils.convertToDistribution(timeUnits.iterator().next());
          float eventExpectedDuration = Utils.expectedDuration(eventDistribution);
          float timeExpectedDuration = Utils.expectedDuration(timeDistribution);
          String context = Utils.getTextBetweenAnnotations(goldView, arg1.getArgument(), arg2.getArgument());
          String out = String.format("%s|%.5f|%s|%.5f|%s\n",
              timeUnits.iterator().next(), timeExpectedDuration * 3650,
              eventText, eventExpectedDuration * 3650,
              context.length() < 80 ? context : "...");
          try {
View Full Code Here

Examples of org.apache.ctakes.typesystem.type.relation.RelationArgument

      throw new AnalysisEngineProcessException(e);                                                                          
    }                                                                                                                                                                                                                                        

    // remove relations where one or both arguments have no duration data
    for(BinaryTextRelation relation : Lists.newArrayList(JCasUtil.select(goldView, BinaryTextRelation.class))) {           
      RelationArgument arg1 = relation.getArg1();                                                                            
      RelationArgument arg2 = relation.getArg2();

      String event1Text;
      String event2Text;
      if(arg1.getArgument() instanceof EventMention && arg2.getArgument() instanceof EventMention) {
        event1Text = Utils.normalizeEventText(jCas, arg1.getArgument());
        event2Text = Utils.normalizeEventText(jCas, arg2.getArgument());
      } else {
        // this is not an event-event relation
        continue;
      }

      if(textToDistribution.containsKey(event1Text) && textToDistribution.containsKey(event2Text)) {
        // we have duration distributions for both arguments, so keep it
        continue;
      }

      arg1.removeFromIndexes();                                                                                           
      arg2.removeFromIndexes();                                                                                           
      relation.removeFromIndexes();
    }

    // remove events (that didn't participate in relations) that have no data
    for(EventMention mention : Lists.newArrayList(JCasUtil.select(goldView, EventMention.class))) {
View Full Code Here

Examples of org.apache.ctakes.typesystem.type.relation.RelationArgument

 
  @Override
  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);
        rel.setArg2(arg1);
View Full Code Here

Examples of org.apache.ctakes.typesystem.type.relation.RelationArgument

  }
 
  @Override
  protected void createRelation(JCas jCas, IdentifiedAnnotation arg1,
      IdentifiedAnnotation arg2, String predictedCategory) {
    RelationArgument relArg1 = new RelationArgument(jCas);
    relArg1.setArgument(arg1);
    relArg1.setRole("Arg1");
    relArg1.addToIndexes();
    RelationArgument relArg2 = new RelationArgument(jCas);
    relArg2.setArgument(arg2);
    relArg2.setRole("Arg2");
    relArg2.addToIndexes();
    TemporalTextRelation relation = new TemporalTextRelation(jCas);
    relation.setArg1(relArg1);
    relation.setArg2(relArg2);
    relation.setCategory(predictedCategory);
    relation.addToIndexes();
View Full Code Here

Examples of org.apache.ctakes.typesystem.type.relation.RelationArgument

  }

  @Override
  protected void createRelation(JCas jCas, IdentifiedAnnotation arg1,
      IdentifiedAnnotation arg2, String predictedCategory) {
    RelationArgument relArg1 = new RelationArgument(jCas);
    relArg1.setArgument(arg1);
    relArg1.setRole("Arg1");
    relArg1.addToIndexes();
    RelationArgument relArg2 = new RelationArgument(jCas);
    relArg2.setArgument(arg2);
    relArg2.setRole("Arg2");
    relArg2.addToIndexes();
    TemporalTextRelation relation = new TemporalTextRelation(jCas);
    relation.setArg1(relArg1);
    relation.setArg2(relArg2);
    relation.setCategory(predictedCategory);
    relation.addToIndexes();
View Full Code Here

Examples of org.apache.ctakes.typesystem.type.relation.RelationArgument

        throw new AnalysisEngineProcessException(e);
      }

      for(BinaryTextRelation relation : Lists.newArrayList(JCasUtil.select(relationView, BinaryTextRelation.class))){
        //          if(relation.getCategory().equals("CONTAINS")){
        RelationArgument arg1 = relation.getArg1();
        RelationArgument arg2 = relation.getArg2();
        if(arg1.getArgument() instanceof TimeMention && arg2.getArgument() instanceof EventMention ||
            arg1.getArgument() instanceof EventMention && arg2.getArgument() instanceof TimeMention){
          // these are the kind we keep.
          continue;
        }
        //            if(arg1.getArgument() instanceof EventMention && arg2.getArgument() instanceof EventMention){
        arg1.removeFromIndexes();
        arg2.removeFromIndexes();
        relation.removeFromIndexes();
      }
      //        }

    }
View Full Code Here

Examples of org.apache.ctakes.typesystem.type.relation.RelationArgument

            }
          } else {
            String outcome = this.classifier.classify(features);
            if(outcome!=null){
              // add the relation to the CAS
                RelationArgument relArg1 = new RelationArgument(jCas);
                relArg1.setArgument(eventMention);
                relArg1.setRole("Argument");
                relArg1.addToIndexes();
                RelationArgument relArg2 = new RelationArgument(jCas);
                relArg2.setArgument(dischargeTime);
                relArg2.setRole("Related_to");
                relArg2.addToIndexes();
                TemporalTextRelation relation = new TemporalTextRelation(jCas);
                relation.setArg1(relArg1);
                relation.setArg2(relArg2);
                relation.setCategory(outcome);
                relation.addToIndexes();
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.