Examples of RelationshipDelta


Examples of edu.cmu.cs.fusion.relationship.RelationshipDelta

  }

  @Test
  public void testApplyChangesToContextBottom() {
    RelationshipContext b1 = new RelationshipContext(true);
    RelationshipDelta delta = new RelationshipDelta();
    RelationshipContext changes;
   
    changes = b1.applyChangesFromDelta(delta);
    assertTrue(b1.isMorePreciseOrEqualTo(changes));
    assertTrue(changes.isMorePreciseOrEqualTo(b1));
   
    delta.setRelationship(new Relationship(tA, new ObjectLabel[] {w, y}), SevenPointLattice.UNK);
    changes = b1.applyChangesFromDelta(delta);
    assertTrue(b1.isMorePreciseOrEqualTo(changes));
    assertTrue(!changes.isMorePreciseOrEqualTo(b1));
  }
View Full Code Here

Examples of edu.cmu.cs.fusion.relationship.RelationshipDelta

    w = new AbstractObjectLabel("w");
    x = new AbstractObjectLabel("x");
    y = new AbstractObjectLabel("y");
    z = new AbstractObjectLabel("z");

    d1 = new RelationshipDelta();
    d1.setRelationship(new Relationship(tA, new ObjectLabel[] {w, y}), SevenPointLattice.TRU);
    d1.setRelationship(new Relationship(tA, new ObjectLabel[] {x, z}), SevenPointLattice.FAL);
    d1.setRelationship(new Relationship(tB, new ObjectLabel[] {y, z}), SevenPointLattice.TRU);
    d1.setRelationship(new Relationship(tB, new ObjectLabel[] {z, y}), SevenPointLattice.UNK);

    d2 = new RelationshipDelta();
    d2.setRelationship(new Relationship(tA, new ObjectLabel[] {w, y}), SevenPointLattice.TRU);
    d2.setRelationship(new Relationship(tA, new ObjectLabel[] {x, y}), SevenPointLattice.FAL);
    d2.setRelationship(new Relationship(tB, new ObjectLabel[] {y, z}), SevenPointLattice.UNK);
    d2.setRelationship(new Relationship(tB, new ObjectLabel[] {z, y}), SevenPointLattice.UNK);

    d3 = new RelationshipDelta();
    d3.setRelationship(new Relationship(tA, new ObjectLabel[] {w, y}), SevenPointLattice.TRU);
    d3.setRelationship(new Relationship(tA, new ObjectLabel[] {w, z}), SevenPointLattice.FAL);
    d3.setRelationship(new Relationship(tA, new ObjectLabel[] {x, y}), SevenPointLattice.UNK);
    d3.setRelationship(new Relationship(tA, new ObjectLabel[] {x, z}), SevenPointLattice.UNK);
    d3.setRelationship(new Relationship(tB, new ObjectLabel[] {y, z}), SevenPointLattice.UNK);
    d3.setRelationship(new Relationship(tB, new ObjectLabel[] {z, y}), SevenPointLattice.UNK);

    d4 = new RelationshipDelta();
    d4.setRelationship(new Relationship(tA, new ObjectLabel[] {w, y}), SevenPointLattice.TRU_STAR);
    d4.setRelationship(new Relationship(tA, new ObjectLabel[] {w, z}), SevenPointLattice.UNK);
    d4.setRelationship(new Relationship(tA, new ObjectLabel[] {x, y}), SevenPointLattice.TRU);
    d4.setRelationship(new Relationship(tA, new ObjectLabel[] {x, z}), SevenPointLattice.FAL_STAR);
    d4.setRelationship(new Relationship(tB, new ObjectLabel[] {y, z}), SevenPointLattice.FAL_STAR);
View Full Code Here

Examples of edu.cmu.cs.fusion.relationship.RelationshipDelta

    d4.setRelationship(new Relationship(tB, new ObjectLabel[] {z, y}), SevenPointLattice.TRU_STAR);
  }

  @Test
  public void testPolarize() {
    RelationshipDelta polar = d1.polarize();
   
    assertTrue(polar.getValue(new Relationship(tA, new ObjectLabel[] {w, y})) == SevenPointLattice.TRU_STAR);
    assertTrue(polar.getValue(new Relationship(tA, new ObjectLabel[] {x, z})) == SevenPointLattice.FAL_STAR);
    assertTrue(polar.getValue(new Relationship(tB, new ObjectLabel[] {y, z})) == SevenPointLattice.TRU_STAR);
    assertTrue(polar.getValue(new Relationship(tB, new ObjectLabel[] {z, y})) == SevenPointLattice.UNK);

    polar = d4.polarize();
   
    assertTrue(polar.getValue(new Relationship(tA, new ObjectLabel[] {w, y})) == SevenPointLattice.TRU_STAR);
    assertTrue(polar.getValue(new Relationship(tA, new ObjectLabel[] {w, z})) == SevenPointLattice.UNK);
    assertTrue(polar.getValue(new Relationship(tA, new ObjectLabel[] {x, y})) == SevenPointLattice.TRU_STAR);
    assertTrue(polar.getValue(new Relationship(tA, new ObjectLabel[] {x, z})) == SevenPointLattice.FAL_STAR);
    assertTrue(polar.getValue(new Relationship(tB, new ObjectLabel[] {y, z})) == SevenPointLattice.FAL_STAR);
    assertTrue(polar.getValue(new Relationship(tB, new ObjectLabel[] {z, y})) == SevenPointLattice.TRU_STAR);
  }
View Full Code Here

Examples of edu.cmu.cs.fusion.relationship.RelationshipDelta

    assertTrue(polar.getValue(new Relationship(tB, new ObjectLabel[] {z, y})) == SevenPointLattice.TRU_STAR);
  }
 
  @Test
  public void testJoin() {
    RelationshipDelta join;
    List<RelationshipDelta> list;
       
    list = new LinkedList<RelationshipDelta>();
    list.add(d1);
    list.add(d2);
    join = RelationshipDelta.join(list);
   
    assertTrue(join.getValue(new Relationship(tA, new ObjectLabel[] {w, y})) == SevenPointLattice.TRU);
    assertTrue(join.getValue(new Relationship(tA, new ObjectLabel[] {x, y})) == SevenPointLattice.FAL_STAR);
    assertTrue(join.getValue(new Relationship(tA, new ObjectLabel[] {x, z})) == SevenPointLattice.FAL_STAR);
    assertTrue(join.getValue(new Relationship(tB, new ObjectLabel[] {y, z})) == SevenPointLattice.UNK);
    assertTrue(join.getValue(new Relationship(tB, new ObjectLabel[] {z, y})) == SevenPointLattice.UNK);

    list = new LinkedList<RelationshipDelta>();
    list.add(d2);
    list.add(d4);
    join = RelationshipDelta.join(list);
   
    assertTrue(join.getValue(new Relationship(tA, new ObjectLabel[] {w, y})) == SevenPointLattice.TRU_STAR);
    assertTrue(join.getValue(new Relationship(tA, new ObjectLabel[] {w, z})) == SevenPointLattice.UNK);
    assertTrue(join.getValue(new Relationship(tA, new ObjectLabel[] {x, y})) == SevenPointLattice.UNK);
    assertTrue(join.getValue(new Relationship(tB, new ObjectLabel[] {y, z})) == SevenPointLattice.UNK);
    assertTrue(join.getValue(new Relationship(tB, new ObjectLabel[] {z, y})) == SevenPointLattice.UNK);

    list = new LinkedList<RelationshipDelta>();
    list.add(d1);
    list.add(d2);
    list.add(d3);
    list.add(d4);
    join = RelationshipDelta.join(list);
   
    assertTrue(join.getValue(new Relationship(tA, new ObjectLabel[] {w, y})) == SevenPointLattice.TRU_STAR);
    assertTrue(join.getValue(new Relationship(tA, new ObjectLabel[] {w, z})) == SevenPointLattice.UNK);
    assertTrue(join.getValue(new Relationship(tA, new ObjectLabel[] {x, y})) == SevenPointLattice.UNK);
    assertTrue(join.getValue(new Relationship(tA, new ObjectLabel[] {x, z})) == SevenPointLattice.UNK);
    assertTrue(join.getValue(new Relationship(tB, new ObjectLabel[] {y, z})) == SevenPointLattice.UNK);
    assertTrue(join.getValue(new Relationship(tB, new ObjectLabel[] {z, y})) == SevenPointLattice.UNK);
  }
View Full Code Here

Examples of edu.cmu.cs.fusion.relationship.RelationshipDelta

  }
 
  @Test
  public void testStrictPrecise() {
    RelationshipContext ctx = new RelationshipContext(false).applyChangesFromDelta(d1);
    RelationshipDelta delta;
   
    //test the empty delta
    delta = new RelationshipDelta();
    assertTrue(!delta.isStrictlyMorePrecise(ctx));
   
    //test an equal delta
    delta = new RelationshipDelta();
    delta.setRelationship(new Relationship(tA, new ObjectLabel[] {w, y}), SevenPointLattice.TRU);
    delta.setRelationship(new Relationship(tA, new ObjectLabel[] {x, z}), SevenPointLattice.FAL);
    delta.setRelationship(new Relationship(tB, new ObjectLabel[] {y, z}), SevenPointLattice.TRU);
    delta.setRelationship(new Relationship(tB, new ObjectLabel[] {z, y}), SevenPointLattice.UNK);
    assertTrue(!delta.isStrictlyMorePrecise(ctx));
   
    //test a more precise delta
    delta.setRelationship(new Relationship(tB, new ObjectLabel[] {z, y}), SevenPointLattice.TRU);
    assertTrue(delta.isStrictlyMorePrecise(ctx));
    delta.setRelationship(new Relationship(tB, new ObjectLabel[] {z, y}), SevenPointLattice.UNK);
   
    //test a more and less precise delta
    delta.setRelationship(new Relationship(tA, new ObjectLabel[] {w, y}), SevenPointLattice.UNK);
    delta.setRelationship(new Relationship(tB, new ObjectLabel[] {z, y}), SevenPointLattice.TRU);
    assertTrue(!delta.isStrictlyMorePrecise(ctx));
    delta.setRelationship(new Relationship(tA, new ObjectLabel[] {w, y}), SevenPointLattice.TRU);
    delta.setRelationship(new Relationship(tB, new ObjectLabel[] {z, y}), SevenPointLattice.UNK);

    //test a less precise U delta
    delta.setRelationship(new Relationship(tB, new ObjectLabel[] {y, z}), SevenPointLattice.UNK);
    assertTrue(!delta.isStrictlyMorePrecise(ctx));
    delta.setRelationship(new Relationship(tB, new ObjectLabel[] {y, z}), SevenPointLattice.TRU);
   
    //test a thrashing delta
    delta.setRelationship(new Relationship(tB, new ObjectLabel[] {y, z}), SevenPointLattice.FAL);
    assertTrue(!delta.isStrictlyMorePrecise(ctx));
    delta.setRelationship(new Relationship(tB, new ObjectLabel[] {y, z}), SevenPointLattice.TRU);
   
    //test a delta which is less precise when star is used.
    delta.setRelationship(new Relationship(tB, new ObjectLabel[] {x, z}), SevenPointLattice.TRU_STAR);
    assertTrue(!delta.isStrictlyMorePrecise(ctx));
    delta.setRelationship(new Relationship(tB, new ObjectLabel[] {x, z}), SevenPointLattice.FAL);
   
    //another star, but equal precise
    delta.setRelationship(new Relationship(tB, new ObjectLabel[] {y, z}), SevenPointLattice.TRU_STAR);
    assertTrue(!delta.isStrictlyMorePrecise(ctx));
    delta.setRelationship(new Relationship(tB, new ObjectLabel[] {y, z}), SevenPointLattice.TRU);
   
    //test a more and the star used
    delta.setRelationship(new Relationship(tA, new ObjectLabel[] {w, y}), SevenPointLattice.TRU_STAR);
    delta.setRelationship(new Relationship(tB, new ObjectLabel[] {z, y}), SevenPointLattice.FAL);
    assertTrue(delta.isStrictlyMorePrecise(ctx));
    delta.setRelationship(new Relationship(tA, new ObjectLabel[] {w, y}), SevenPointLattice.TRU);
    delta.setRelationship(new Relationship(tB, new ObjectLabel[] {z, y}), SevenPointLattice.UNK);
  }
View Full Code Here

Examples of edu.cmu.cs.fusion.relationship.RelationshipDelta

 
  static ObjectLabel w, x, y, z;

  @BeforeClass
  static public void testRelationships() {
    RelationshipDelta delta;
    tA = new Relation("A", new String[] {"Foo", "Bar"});
    tB = new Relation("B", new String[] {"Bar", "Bar"});
   
    w = new AbstractObjectLabel("w");
    x = new AbstractObjectLabel("x");
    y = new AbstractObjectLabel("y");
    z = new AbstractObjectLabel("z");

    delta = new RelationshipDelta();
    delta.setRelationship(new Relationship(tA, new ObjectLabel[] {w, y}), SevenPointLattice.TRU);
    delta.setRelationship(new Relationship(tA, new ObjectLabel[] {w, z}), SevenPointLattice.FAL);
    delta.setRelationship(new Relationship(tA, new ObjectLabel[] {x, y}), SevenPointLattice.TRU);
    delta.setRelationship(new Relationship(tA, new ObjectLabel[] {x, z}), SevenPointLattice.FAL);
    delta.setRelationship(new Relationship(tB, new ObjectLabel[] {y, z}), SevenPointLattice.TRU);
    delta.setRelationship(new Relationship(tB, new ObjectLabel[] {z, y}), SevenPointLattice.UNK);
    c1 = new RelationshipContext(true).applyChangesFromDelta(delta);
   
    delta = new RelationshipDelta();
    delta.setRelationship(new Relationship(tA, new ObjectLabel[] {w, y}), SevenPointLattice.TRU);
    delta.setRelationship(new Relationship(tA, new ObjectLabel[] {w, z}), SevenPointLattice.FAL);
    delta.setRelationship(new Relationship(tA, new ObjectLabel[] {x, y}), SevenPointLattice.FAL);
    delta.setRelationship(new Relationship(tA, new ObjectLabel[] {x, z}), SevenPointLattice.TRU);
    delta.setRelationship(new Relationship(tB, new ObjectLabel[] {y, z}), SevenPointLattice.UNK);
    delta.setRelationship(new Relationship(tB, new ObjectLabel[] {z, y}), SevenPointLattice.UNK);
    c2 = new RelationshipContext(true).applyChangesFromDelta(delta);

    delta = new RelationshipDelta();
    delta.setRelationship(new Relationship(tA, new ObjectLabel[] {w, y}), SevenPointLattice.TRU);
    delta.setRelationship(new Relationship(tA, new ObjectLabel[] {w, z}), SevenPointLattice.FAL);
    delta.setRelationship(new Relationship(tA, new ObjectLabel[] {x, y}), SevenPointLattice.UNK);
    delta.setRelationship(new Relationship(tA, new ObjectLabel[] {x, z}), SevenPointLattice.UNK);
    delta.setRelationship(new Relationship(tB, new ObjectLabel[] {y, z}), SevenPointLattice.UNK);
    delta.setRelationship(new Relationship(tB, new ObjectLabel[] {z, y}), SevenPointLattice.UNK);
    c3 = new RelationshipContext(true).applyChangesFromDelta(delta);

    delta = new RelationshipDelta();
    delta.setRelationship(new Relationship(tA, new ObjectLabel[] {w, y}), SevenPointLattice.TRU);
    delta.setRelationship(new Relationship(tA, new ObjectLabel[] {w, z}), SevenPointLattice.UNK);
    delta.setRelationship(new Relationship(tA, new ObjectLabel[] {x, y}), SevenPointLattice.FAL);
    delta.setRelationship(new Relationship(tA, new ObjectLabel[] {x, z}), SevenPointLattice.UNK);
    delta.setRelationship(new Relationship(tB, new ObjectLabel[] {y, z}), SevenPointLattice.UNK);
    delta.setRelationship(new Relationship(tB, new ObjectLabel[] {z, y}), SevenPointLattice.UNK);
    c4 = new RelationshipContext(true).applyChangesFromDelta(delta);
   
   
    d1 = new RelationshipDelta();
    d1.setRelationship(new Relationship(tA, new ObjectLabel[] {w, y}), SevenPointLattice.TRU);
    d1.setRelationship(new Relationship(tA, new ObjectLabel[] {x, z}), SevenPointLattice.FAL);
    d1.setRelationship(new Relationship(tB, new ObjectLabel[] {y, z}), SevenPointLattice.TRU);
    d1.setRelationship(new Relationship(tB, new ObjectLabel[] {z, y}), SevenPointLattice.UNK);

    d2 = new RelationshipDelta();
    d2.setRelationship(new Relationship(tA, new ObjectLabel[] {w, y}), SevenPointLattice.TRU);
    d2.setRelationship(new Relationship(tA, new ObjectLabel[] {x, y}), SevenPointLattice.FAL);
    d2.setRelationship(new Relationship(tB, new ObjectLabel[] {y, z}), SevenPointLattice.UNK);
    d2.setRelationship(new Relationship(tB, new ObjectLabel[] {z, y}), SevenPointLattice.UNK);

    d3 = new RelationshipDelta();
    d3.setRelationship(new Relationship(tA, new ObjectLabel[] {w, y}), SevenPointLattice.TRU_STAR);
    d3.setRelationship(new Relationship(tA, new ObjectLabel[] {w, z}), SevenPointLattice.FAL);
    d3.setRelationship(new Relationship(tA, new ObjectLabel[] {x, y}), SevenPointLattice.UNK);
    d3.setRelationship(new Relationship(tA, new ObjectLabel[] {x, z}), SevenPointLattice.UNK);
    d3.setRelationship(new Relationship(tB, new ObjectLabel[] {y, z}), SevenPointLattice.UNK);
    d3.setRelationship(new Relationship(tB, new ObjectLabel[] {z, y}), SevenPointLattice.UNK);

    d4 = new RelationshipDelta();
    d4.setRelationship(new Relationship(tA, new ObjectLabel[] {w, y}), SevenPointLattice.TRU_STAR);
    d4.setRelationship(new Relationship(tA, new ObjectLabel[] {w, z}), SevenPointLattice.UNK);
    d4.setRelationship(new Relationship(tA, new ObjectLabel[] {x, y}), SevenPointLattice.TRU);
    d4.setRelationship(new Relationship(tA, new ObjectLabel[] {x, z}), SevenPointLattice.FAL_STAR);
    d4.setRelationship(new Relationship(tB, new ObjectLabel[] {y, z}), SevenPointLattice.FAL_STAR);
View Full Code Here

Examples of edu.cmu.cs.fusion.relationship.RelationshipDelta

    relations = new Relation[2];
    relations[0] = new Relation("A", new String[] {"Foo", "Bar"});
    relations[1] = new Relation("B", new String[] {"Foo", "Foo"});
   
    ctx = new RelationshipContext(false);
    RelationshipDelta delta = new RelationshipDelta();
    delta.setRelationship(new Relationship(relations[0], new ObjectLabel[] {labels[0], labels[1]}), SevenPointLattice.TRU);
    ctx = ctx.applyChangesFromDelta(delta);
   
    FreeVars.setHierarchy(testH);
  }
View Full Code Here

Examples of edu.cmu.cs.fusion.relationship.RelationshipDelta

   
    RelationshipPredicate find = new RelationshipPredicate(relations[0], new SpecVar[] {new SpecVar("a"), new SpecVar("a")});
    Substitution sub = new Substitution();
    sub = sub.addSub(new SpecVar("a"), labels[0]);
   
    RelationshipDelta delta = env.getInferredDelta(find, sub);
    assertNotNull(delta);
    SevenPointLattice val = delta.getValue(new Relationship(relations[0], new ObjectLabel[] {labels[0], labels[0]}));
    assertEquals(SevenPointLattice.TRU, val);
    assertEquals(1, delta.numberOfChanges())
  }
View Full Code Here

Examples of edu.cmu.cs.fusion.relationship.RelationshipDelta

   
    RelationshipPredicate find = new RelationshipPredicate(relations[1], new SpecVar[] {new SpecVar("a"), new SpecVar("a")});
    Substitution sub = new Substitution();
    sub = sub.addSub(new SpecVar("a"), labels[0]);
   
    RelationshipDelta delta = env.getInferredDelta(find, sub);
    assertNotNull(delta);
    SevenPointLattice val = delta.getValue(new Relationship(relations[1], new ObjectLabel[] {labels[0], labels[0]}));
    assertEquals(SevenPointLattice.TRU, val);
    assertEquals(1, delta.numberOfChanges());   
  }
View Full Code Here

Examples of edu.cmu.cs.fusion.relationship.RelationshipDelta

   
    RelationshipPredicate find = new RelationshipPredicate(relations[1], new SpecVar[] {new SpecVar("a"), new SpecVar("a")});
    Substitution sub = new Substitution();
    sub = sub.addSub(new SpecVar("a"), labels[0]);
   
    RelationshipDelta delta = env.getInferredDelta(find, sub);
    assertNotNull(delta);
    SevenPointLattice val = delta.getValue(new Relationship(relations[1], new ObjectLabel[] {labels[0], labels[0]}));
    assertEquals(SevenPointLattice.TRU, val);
    assertEquals(1, delta.numberOfChanges());   
   
  }
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.