Search in sources :

Example 6 with DefaultRegistry

use of com.sri.ai.grinder.core.DefaultRegistry in project aic-expresso by aic-sri-international.

the class AssignmentsIteratorTest method test1.

@Test
public void test1() {
    Registry registry = new DefaultRegistry();
    Type myType = new Categorical("People", 4, arrayList(makeSymbol("oscar"), makeSymbol("mary")));
    Symbol x = makeSymbol("X");
    Symbol y = makeSymbol("Y");
    String expected = "{X=oscar, Y=oscar}\n" + "{X=mary, Y=oscar}\n" + "{X=people3, Y=oscar}\n" + "{X=people4, Y=oscar}\n" + "{X=oscar, Y=mary}\n" + "{X=mary, Y=mary}\n" + "{X=people3, Y=mary}\n" + "{X=people4, Y=mary}\n" + "{X=oscar, Y=people3}\n" + "{X=mary, Y=people3}\n" + "{X=people3, Y=people3}\n" + "{X=people4, Y=people3}\n" + "{X=oscar, Y=people4}\n" + "{X=mary, Y=people4}\n" + "{X=people3, Y=people4}\n" + "{X=people4, Y=people4}";
    Symbol myTypeExpression = makeSymbol(myType.getName());
    registry = registry.makeNewContextWithAddedType(myType);
    registry = registry.makeCloneWithAdditionalRegisteredSymbolsAndTypes(map(x, myTypeExpression, y, myTypeExpression));
    AssignmentMapsIterator assignmentsIterator = new AssignmentMapsIterator(list(x, y), registry);
    String actual = join("\n", assignmentsIterator);
    // System.out.println(actual);
    assertEquals(expected, actual);
}
Also used : AssignmentMapsIterator(com.sri.ai.grinder.helper.AssignmentMapsIterator) Type(com.sri.ai.expresso.api.Type) Expressions.makeSymbol(com.sri.ai.expresso.helper.Expressions.makeSymbol) Symbol(com.sri.ai.expresso.api.Symbol) DefaultRegistry(com.sri.ai.grinder.core.DefaultRegistry) Registry(com.sri.ai.grinder.api.Registry) DefaultRegistry(com.sri.ai.grinder.core.DefaultRegistry) Categorical(com.sri.ai.expresso.type.Categorical) Test(org.junit.Test)

Aggregations

DefaultRegistry (com.sri.ai.grinder.core.DefaultRegistry)6 AssignmentMapsIterator (com.sri.ai.grinder.helper.AssignmentMapsIterator)5 Symbol (com.sri.ai.expresso.api.Symbol)4 Expressions.makeSymbol (com.sri.ai.expresso.helper.Expressions.makeSymbol)4 Type (com.sri.ai.expresso.api.Type)3 Categorical (com.sri.ai.expresso.type.Categorical)3 Registry (com.sri.ai.grinder.api.Registry)3 Test (org.junit.Test)3 Expression (com.sri.ai.expresso.api.Expression)2 LinkedHashMap (java.util.LinkedHashMap)2 StringJoiner (java.util.StringJoiner)2 ArrayList (java.util.ArrayList)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Before (org.junit.Before)1