Examples of BinaryTextRelation


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

  @Override
  protected String getRelationCategory(Map<List<Annotation>, BinaryTextRelation> relationLookup,
      IdentifiedAnnotation arg1, IdentifiedAnnotation arg2) {

    BinaryTextRelation relation = relationLookup.get(Arrays.asList(arg1, arg2));
    if (this.classifyBothDirections) {
      // if classifying both directions, we'll see {X, Y} once when X is first and
      // once when Y is first, so just do the single direction lookup here
      if (relation != null) {
        return relation.getCategory();
      } else if (coin.nextDouble() <= this.probabilityOfKeepingANegativeExample) {
        return NO_RELATION_CATEGORY;
      } else {
        return null;
      }
    } else {
      // if classifying in a single direction, we'll see {X, Y} only once,
      // so do lookups in both directions, and change the category name for
      // the relations in the reverse order
      if (relation != null) {
        return relation.getCategory();
      } else {
        relation = relationLookup.get(Arrays.asList(arg2, arg1));
        if (relation != null) {
          // Change category name to show reverse order
          return relation.getCategory() + "-1";
        } else if (coin.nextDouble() <= this.probabilityOfKeepingANegativeExample) {
          return NO_RELATION_CATEGORY;
        } else {
          return null;
        }
View Full Code Here

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

  @Override
  protected String getRelationCategory(
      Map<List<Annotation>, BinaryTextRelation> relationLookup,
      IdentifiedAnnotation arg1, IdentifiedAnnotation arg2) {
    BinaryTextRelation relation = relationLookup.get(Arrays.asList(arg1, arg2));
    return (relation != null) ? relation.getCategory() : NO_RELATION_CATEGORY;
  }
View Full Code Here

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

            relArg1.addToIndexes();
            RelationArgument relArg2 = new RelationArgument(relationView);
            relArg2.setArgument(arg2);
            relArg2.setRole("Related_to");
            relArg2.addToIndexes();
            BinaryTextRelation relation = new BinaryTextRelation(relationView);
            relation.setArg1(relArg1);
            relation.setArg2(relArg2);
            relation.setCategory(predictedCategory);
            relation.addToIndexes();
          }
        }
      } // end pair in pairs
    } // end for(Sentence)
  }
View Full Code Here

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

      RelationArgument relationArgument2 = new RelationArgument(jCas);
      relationArgument2.setId(relationArgumentId++);
      relationArgument2.setArgument(entityMention);
      relationArgument2.setRole(Constants.shareEntityMentionRole);

      BinaryTextRelation binaryTextRelation = new BinaryTextRelation(jCas);
      binaryTextRelation.setArg1(relationArgument1);
      binaryTextRelation.setArg2(relationArgument2);
      binaryTextRelation.setId(relationId++);
      binaryTextRelation.setCategory(relationInfo.category);
      binaryTextRelation.setDiscoveryTechnique(CONST.REL_DISCOVERY_TECH_GOLD_ANNOTATION);
      binaryTextRelation.setConfidence(1);
      binaryTextRelation.addToIndexes();
    }

  }
View Full Code Here

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

      RelationArgument relationArgument2 = new RelationArgument(jCas);
      relationArgument2.setId(relationArgumentId++);
      relationArgument2.setArgument(entityMention2);
      relationArgument2.setRole(relationInfo.role2);

      BinaryTextRelation binaryTextRelation = new BinaryTextRelation(jCas);
      binaryTextRelation.setArg1(relationArgument1);
      binaryTextRelation.setArg2(relationArgument2);
      binaryTextRelation.setId(relationId++);
      binaryTextRelation.setCategory(relationInfo.category);
      binaryTextRelation.setDiscoveryTechnique(CONST.REL_DISCOVERY_TECH_GOLD_ANNOTATION);
      binaryTextRelation.setConfidence(1);
      binaryTextRelation.addToIndexes();
    }
  }
View Full Code Here

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

      sourceRA.setArgument(sourceMention);
      sourceRA.addToIndexes();
      RelationArgument targetRA = new RelationArgument(jCas);
      targetRA.setArgument(targetMention);
      targetRA.addToIndexes();
      BinaryTextRelation relation = new BinaryTextRelation(jCas);
      if (this.type != null) {
        // TODO: do something better with knowtatorRelation.annotation.type
        relation.setCategory(this.annotation.type + '_' + this.type);
      } else {
        relation.setCategory(this.annotation.type);
      }
      relation.setArg1(sourceRA);
      relation.setArg2(targetRA);
      relation.addToIndexes();
    }
View Full Code Here

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

    // test the relation annotators
    Collection<BinaryTextRelation> relations = JCasUtil.select(jCas, BinaryTextRelation.class);
    assertEquals(2, relations.size());
    Iterator<BinaryTextRelation> iterator = relations.iterator();
    BinaryTextRelation slightFracture = iterator.next();
    assertEquals("degree_of", slightFracture.getCategory());
    assertEquals(fracture, slightFracture.getArg1().getArgument());
    assertEquals(slight, slightFracture.getArg2().getArgument());
    BinaryTextRelation fractureFibula = iterator.next();
    assertEquals("location_of", fractureFibula.getCategory());
    // TODO: this seems backwards, but maybe that's how it's supposed to be?
    assertEquals(fibula, fractureFibula.getArg1().getArgument());
    assertEquals(fracture, fractureFibula.getArg2().getArgument());
  }
View Full Code Here

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

        }
        Set<HashableArguments> all = Sets.union(goldMap.keySet(), systemMap.keySet());
        List<HashableArguments> sorted = Lists.newArrayList(all);
        Collections.sort(sorted);
        for (HashableArguments key : sorted) {
          BinaryTextRelation goldRelation = goldMap.get(key);
          BinaryTextRelation systemRelation = systemMap.get(key);
          if (goldRelation == null) {
            System.out.println("System added: " + formatRelation(systemRelation));
          } else if (systemRelation == null) {
            System.out.println("System dropped: " + formatRelation(goldRelation));
          } else if (!systemRelation.getCategory().equals(goldRelation.getCategory())) {
            String label = systemRelation.getCategory();
            System.out.printf("System labeled %s for %s\n", label, formatRelation(goldRelation));
          } else{
            System.out.println("Nailed it! " + formatRelation(systemRelation));
          }
        }
View Full Code Here

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

        for (Annotation container : isContainedIn.get(contained)) {
          RelationArgument arg1 = new RelationArgument(jCas);
          arg1.setArgument(container);
          RelationArgument arg2 = new RelationArgument(jCas);
          arg2.setArgument(contained);
          BinaryTextRelation relation = new BinaryTextRelation(jCas);
          relation.setArg1(arg1);
          relation.setArg2(arg2);
          relation.setCategory("CONTAINS");
          arg1.addToIndexes();
          arg2.addToIndexes();
          relation.addToIndexes();
        }
      }
    }
View Full Code Here

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

      }

      for (BinaryTextRelation relation : containsRelations) {
        RelationArgument arg1 = (RelationArgument) relation.getArg1().clone();
        RelationArgument arg2 = (RelationArgument) relation.getArg2().clone();
        BinaryTextRelation newrelation = new BinaryTextRelation(jCas);
        newrelation.setArg1(arg1);
        newrelation.setArg2(arg2);
        newrelation.setCategory("OVERLAP");
        arg1.addToIndexes();
        arg2.addToIndexes();
        newrelation.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.