Search in sources :

Example 6 with org.w3._2005.atom

use of org.w3._2005.atom in project hale by halestudio.

the class ModelRifToRifTranslator method createTargetInstanceMembershipFormula.

private Assert createTargetInstanceMembershipFormula(Actions actions, ModelSentence sentence, RifVariable instanceVariable) {
    Assert assert1 = factory.createAssert();
    Target target = factory.createAssertTarget();
    Member member = factory.createMember();
    Instance instance = factory.createInstance();
    Var var = factory.createVar();
    var.getContent().add(instanceVariable.getName());
    instance.setVar(var);
    member.setInstance(instance);
    org.w3._2007.rif.Class clazz = factory.createClass();
    Const const1 = factory.createConst();
    // $NON-NLS-1$
    const1.setType("rif:iri");
    const1.getContent().add(instanceVariable.getClassName());
    clazz.setConst(const1);
    member.setClazz(clazz);
    target.setMember(member);
    assert1.setTarget(target);
    return assert1;
}
Also used : Target(org.w3._2007.rif.Assert.Target) Assert(org.w3._2007.rif.Assert) Instance(org.w3._2007.rif.Instance) ActionVar(org.w3._2007.rif.Do.ActionVar) Var(org.w3._2007.rif.Var) Const(org.w3._2007.rif.Const) Member(org.w3._2007.rif.Member)

Example 7 with org.w3._2005.atom

use of org.w3._2005.atom in project hale by halestudio.

the class ModelRifToRifTranslator method initialiseFrame.

private Frame initialiseFrame(RifVariable contextVariable) {
    Frame frame = factory.createFrame();
    frame = factory.createFrame();
    org.w3._2007.rif.Object frameObject = factory.createObject();
    frame.setObject(frameObject);
    Var var = factory.createVar();
    var.getContent().add(contextVariable.getName());
    frameObject.setVar(var);
    return frame;
}
Also used : Frame(org.w3._2007.rif.Frame) ActionVar(org.w3._2007.rif.Do.ActionVar) Var(org.w3._2007.rif.Var)

Example 8 with org.w3._2005.atom

use of org.w3._2005.atom in project hale by halestudio.

the class TestModelRifToRifTranslator method checkDoElements.

private void checkDoElements(Do do1) {
    assertNotNull(do1.getActionVar());
    assertTrue(do1.getActionVar().size() >= 1);
    // count number of news and frames in the collection
    int numNews = 0;
    int numFrames = 0;
    for (ActionVar v : do1.getActionVar()) {
        assertNotNull(v);
        if (v.getNew() != null) {
            numNews++;
            checkActionVarTypeNew(v);
        }
        if (v.getFrame() != null) {
            numFrames++;
            checkActionVarTypeFrame(v);
        }
    }
    assertThat(numNews, is(equalTo(1)));
    int numAsserts = 0;
    for (Object action : do1.getActions().getACTION()) {
        assertTrue(action instanceof org.w3._2007.rif.Assert);
        numAsserts++;
        org.w3._2007.rif.Assert a = (org.w3._2007.rif.Assert) action;
        assertNotNull(a);
        checkAssertTarget(a);
    }
    // CHECKSTYLE:OFF
    assertThat(numAsserts, is(equalTo(3)));
// CHECKSTYLE:ON
}
Also used : ActionVar(org.w3._2007.rif.Do.ActionVar) Assert(org.w3._2007.rif.Assert) Assert(org.w3._2007.rif.Assert)

Example 9 with org.w3._2005.atom

use of org.w3._2005.atom in project hale by halestudio.

the class TestModelRifToRifTranslator method testTranslateExample3CP.

/**
 * Tests that it is possible to translate the example 3 CP source dataset.
 *
 * @throws TranslationException
 *             if any errors occurred during the translation
 */
@Test
public void testTranslateExample3CP() throws TranslationException {
    URL url = getClass().getClassLoader().getResource(// $NON-NLS-1$
    "com/onespatial/jrc/tnstg/oml_to_rif/alignments/example3_cp.goml");
    org.w3._2007.rif.Document doc = translator.translate(url);
    assertNotNull(doc);
    assertNotNull(doc.getPayload());
    assertNotNull(doc.getPayload().getGroup());
    assertNotNull(doc.getPayload().getGroup().getSentence());
    assertThat(doc.getPayload().getGroup().getSentence().size(), is(1));
    assertNotNull(doc.getPayload().getGroup().getSentence().get(0));
    checkJavaBindings(doc);
}
Also used : URL(java.net.URL) Document(org.w3._2007.rif.Document) DomBasedUnitTest(com.onespatial.jrc.tns.oml_to_rif.fixture.DomBasedUnitTest) Test(org.junit.Test)

Example 10 with org.w3._2005.atom

use of org.w3._2005.atom in project packages-jpl by SWI-Prolog.

the class Zahed method main.

public static void main(java.lang.String[] argv) {
    System.out.println("starting...");
    Compound goal1 = new Compound("consult", new Term[] { new Atom("zahed.pl") });
    Query q1 = new Query(goal1);
    if (!q1.hasSolution()) {
        System.out.println("consult('zahed.pl') failed");
        return;
    }
    Term t2 = new Compound("t", new Term[] { new Atom("v"), new Atom("[]"), new Atom("a") });
    Compound list2 = new Compound(".", new Term[] { t2, new Atom("[]") });
    Compound t1 = new Compound("t", new Term[] { new Atom("c"), new Atom("q"), new Atom("[]") });
    Compound list1 = new Compound(".", new Term[] { t1, list2 });
    Variable answer = new Variable("A");
    Compound goal2 = new Compound("gen", new Term[] { list1, answer });
    Query q2 = new Query(goal2);
    Map<String, Term> solution = q2.oneSolution();
    if (solution == null) {
        System.out.println("failed");
    } else {
        System.out.println(solution.get("A").toString());
    }
    System.out.println("finished");
}
Also used : Variable(org.jpl7.Variable) Query(org.jpl7.Query) Compound(org.jpl7.Compound) Term(org.jpl7.Term) Atom(org.jpl7.Atom)

Aggregations

Atom (org.jpl7.Atom)38 Term (org.jpl7.Term)23 Query (org.jpl7.Query)21 Variable (org.jpl7.Variable)15 Compound (org.jpl7.Compound)14 URL (java.net.URL)6 Test (org.junit.Test)6 ActionVar (org.w3._2007.rif.Do.ActionVar)5 DomBasedUnitTest (com.onespatial.jrc.tns.oml_to_rif.fixture.DomBasedUnitTest)4 Document (org.w3._2007.rif.Document)4 Var (org.w3._2007.rif.Var)4 Map (java.util.Map)3 PrologException (org.jpl7.PrologException)3 Const (org.w3._2007.rif.Const)3 MapItem (org.apache.sis.portrayal.MapItem)2 WhereType (org.geotoolkit.georss.xml.v100.WhereType)2 DirectPositionType (org.geotoolkit.gml.xml.v311.DirectPositionType)2 EnvelopeType (org.geotoolkit.gml.xml.v311.EnvelopeType)2 Assert (org.w3._2007.rif.Assert)2 Instance (org.w3._2007.rif.Instance)2