r.setValue("emails"); r.setSource(from); r.setTarget(reciever); r.addToIndexes(); });
r.setValue("emails"); r.setSource(from); r.setTarget(reciever); r.addToIndexes(); });
private Relation createRelation(JCas jCas, Entity e1, Entity e2) { final Relation p2l = new Relation(jCas); p2l.setSource(e2); p2l.setTarget(e1); p2l.setRelationshipType("from"); p2l.addToIndexes(); return p2l; } }
a.setRelationshipType(r.getType()); a.setSource(source.get()); a.setTarget(target.get()); getSupport().add(a);
r.setRelationSubType("went"); r.setSource(p); r.setTarget(l); r.addToIndexes();
@Test public void test() throws AnalysisEngineProcessException, ResourceInitializationException { final Person p = new Person(jCas); p.addToIndexes(); final Location l = new Location(jCas); p.addToIndexes(); final Relation p2l = new Relation(jCas); p2l.setSource(p); p2l.setTarget(l); p2l.setRelationshipType("went"); p2l.setRelationSubType("past"); p2l.addToIndexes(); final Relation p2p = new Relation(jCas); p2p.setSource(p); p2p.setTarget(p); p2p.setRelationshipType("knew"); p2p.addToIndexes(); processJCas("mongo", fongoErd); final List<Relation> select = new ArrayList<>(JCasUtil.select(jCas, Relation.class)); assertEquals(2, select.size()); }
r.setRelationSubType("went"); r.setSource(p); r.setTarget(l); r.addToIndexes();
r.setRelationSubType("went"); r.setSource(p); r.setTarget(l); r.addToIndexes();
@Test public void testStrict() throws AnalysisEngineProcessException, ResourceInitializationException { final Person p = new Person(jCas); p.addToIndexes(); final Location l = new Location(jCas); p.addToIndexes(); final Relation p2l = new Relation(jCas); p2l.setSource(p); p2l.setTarget(l); p2l.setRelationshipType("went"); p2l.setRelationSubType("past"); p2l.addToIndexes(); final Relation p2p = new Relation(jCas); p2p.setSource(p); p2p.setTarget(p); p2p.setRelationshipType("went"); p2l.setRelationSubType("past"); p2p.addToIndexes(); processJCas("mongo", fongoErd, "strict", true); final List<Relation> select = new ArrayList<>(JCasUtil.select(jCas, Relation.class)); assertEquals(1, select.size()); }
/** * Merge entity onto targetEntity (assuming they have the same ReferentTarget), updating * relationships as required. * * @return True if merge was successful, false otherwise */ private boolean mergeEntities(Entity entity, Entity targetEntity) { ReferenceTarget targetRef = targetEntity.getReferent(); ReferenceTarget entityRef = entity.getReferent(); if (mergeDistinctEntities || isSameTarget(targetRef, entityRef)) { addMergeToHistory(targetEntity, entity); // Update relationship pointers for (Relation r : getRelations(entity)) { if (r.getSource() == entity) { r.setSource(targetEntity); } if (r.getTarget() == entity) { r.setTarget(targetEntity); } } remove(entity); return true; } else { monitor.debug( "Not merging objects {} and {} as they have different referents", targetEntity.getInternalId(), entity.getInternalId()); return false; } }
/** * Merge entity onto targetEntity (assuming they have the same ReferentTarget), updating * relationships as required. * * @return True if merge was successful, false otherwise */ private boolean mergeEntities(Entity entity, Entity targetEntity) { ReferenceTarget targetRef = targetEntity.getReferent(); ReferenceTarget entityRef = entity.getReferent(); if (mergeDistinctEntities || isSameTarget(targetRef, entityRef)) { addMergeToHistory(targetEntity, entity); // Update relationship pointers for (Relation r : getRelations(entity)) { if (r.getSource() == entity) { r.setSource(targetEntity); } if (r.getTarget() == entity) { r.setTarget(targetEntity); } } remove(entity); return true; } else { monitor.debug( "Not merging objects {} and {} as they have different referents", targetEntity.getInternalId(), entity.getInternalId()); return false; } }
r.setEnd(1); r.setSource(p2); r.setTarget(p3); r.addToIndexes();
@Test public void testRelations() throws UIMAException { final Person s = new Person(jCas); s.setValue("source"); final Location t = new Location(jCas); t.setValue("target"); final Relation r = new Relation(jCas); r.setSource(s); r.setTarget(t); r.setRelationshipType("check"); r.addToIndexes(); SimplePipeline.runPipeline(jCas, AnalysisEngineFactory.createEngine(Relations.class)); }
r1.setRelationshipType("subtype"); r1.setSource(a); r1.setTarget(b); r1.addToIndexes(); r4.setRelationSubType(r1.getRelationSubType()); r4.setSource(a); r4.setTarget(b); r4.addToIndexes(); r5.setRelationSubType(r1.getRelationSubType()); r5.setSource(c); r5.setTarget(b); r5.addToIndexes(); r6.setRelationSubType(r1.getRelationSubType()); r6.setSource(a); r6.setTarget(c); r6.addToIndexes();
r.setValue("James went to London"); r.setSource(p); r.setTarget(l); r.setRelationshipType("AT"); r.setConfidence(0.7);