Search in sources :

Example 1 with Sentence

use of org.w3._2007.rif.Sentence in project hale by halestudio.

the class TestModelRifToRifTranslator method checkDeclareElement.

private And checkDeclareElement(Sentence actualSentence) {
    List<Declare> declareList = actualSentence.getImplies().getIf().getExists().getDeclare();
    assertNotNull(declareList);
    assertTrue(declareList.size() >= 1);
    for (Declare d : declareList) {
        assertNotNull(d);
        assertNotNull(d.getVar());
        assertNotNull(d.getVar().getContent());
        assertThat(d.getVar().getContent().size(), is(equalTo(1)));
        assertNotNull(d.getVar().getContent().get(0));
    }
    assertNotNull(actualSentence.getImplies().getIf().getExists().getFormula());
    And and = actualSentence.getImplies().getIf().getExists().getFormula().getAnd();
    assertNotNull(and);
    return and;
}
Also used : And(org.w3._2007.rif.And) Declare(org.w3._2007.rif.Declare)

Example 2 with Sentence

use of org.w3._2007.rif.Sentence 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 3 with Sentence

use of org.w3._2007.rif.Sentence in project hale by halestudio.

the class ModelRifToRifTranslator method createSourceInstanceMembershipFormula.

private Formula createSourceInstanceMembershipFormula(ModelSentence sentence, RifVariable instanceVariable) {
    Formula result = factory.createFormula();
    Member member = factory.createMember();
    Instance instance = factory.createInstance();
    Var var = factory.createVar();
    String name = sentence.getSourceClass().getName();
    var.getContent().add(name);
    Const const1 = factory.createConst();
    // $NON-NLS-1$
    const1.setType("rif:iri");
    const1.getContent().add(instanceVariable.getClassName());
    org.w3._2007.rif.Class clazz = factory.createClass();
    instance.setVar(var);
    clazz.setConst(const1);
    member.setInstance(instance);
    member.setClazz(clazz);
    result.setMember(member);
    return result;
}
Also used : Formula(org.w3._2007.rif.Formula) 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 4 with Sentence

use of org.w3._2007.rif.Sentence in project hale by halestudio.

the class ModelRifToRifTranslator method buildSentence.

private Sentence buildSentence(ModelSentence s) {
    // sort variables within sentence
    final Sentence sentence = factory.createSentence();
    final Implies implies = factory.createImplies();
    sentence.setImplies(implies);
    final If if1 = factory.createIf();
    implies.setIf(if1);
    final Exists exists = factory.createExists();
    if1.setExists(exists);
    ThenPart then = factory.createThenPart();
    implies.setThen(then);
    Do do1 = factory.createDo();
    then.setDo(do1);
    processChildren(s, exists, do1);
    return sentence;
}
Also used : Implies(org.w3._2007.rif.Implies) Exists(org.w3._2007.rif.Exists) ThenPart(org.w3._2007.rif.ThenPart) Do(org.w3._2007.rif.Do) ModelSentence(com.onespatial.jrc.tns.oml_to_rif.model.rif.ModelSentence) Sentence(org.w3._2007.rif.Sentence) If(org.w3._2007.rif.If)

Example 5 with Sentence

use of org.w3._2007.rif.Sentence in project hale by halestudio.

the class ModelRifToRifTranslator method recurseChildren.

private void recurseChildren(final Exists exists, Do do1, RifVariable variable, ModelSentence sentence, boolean isSource) {
    List<RifVariable> children = sentence.findChildren(variable);
    if (isSource) {
        exists.getDeclare().add(createSourceDeclare(variable));
        if (variable.getType().equals(Type.INSTANCE)) {
            exists.getFormula().getAnd().getFormula().add(createSourceInstanceMembershipFormula(sentence, variable));
        }
    } else {
        // if (!children.isEmpty()) // problem?
        do1.getActionVar().add(createTargetVariableDeclare(variable));
        if (variable.getType() == Type.INSTANCE) {
            do1.getActions().getACTION().add(createTargetInstanceMembershipFormula(do1.getActions(), sentence, variable));
        }
    }
    if (!children.isEmpty()) {
        if (isSource) {
            Frame frame = initialiseFrame(variable);
            for (RifVariable child : children) {
                recurseChildren(exists, do1, child, sentence, isSource);
                createBindingSlot(child, frame);
            }
            Formula frameFormula = factory.createFormula();
            frameFormula.setFrame(frame);
            exists.getFormula().getAnd().getFormula().add(frameFormula);
        } else {
            for (RifVariable child : children) {
                recurseChildren(exists, do1, child, sentence, isSource);
            }
        }
    }
}
Also used : Formula(org.w3._2007.rif.Formula) Frame(org.w3._2007.rif.Frame) RifVariable(com.onespatial.jrc.tns.oml_to_rif.translate.context.RifVariable)

Aggregations

And (org.w3._2007.rif.And)2 Const (org.w3._2007.rif.Const)2 ActionVar (org.w3._2007.rif.Do.ActionVar)2 Formula (org.w3._2007.rif.Formula)2 Instance (org.w3._2007.rif.Instance)2 Member (org.w3._2007.rif.Member)2 Sentence (org.w3._2007.rif.Sentence)2 Var (org.w3._2007.rif.Var)2 ModelSentence (com.onespatial.jrc.tns.oml_to_rif.model.rif.ModelSentence)1 RifVariable (com.onespatial.jrc.tns.oml_to_rif.translate.context.RifVariable)1 Assert (org.w3._2007.rif.Assert)1 Target (org.w3._2007.rif.Assert.Target)1 Declare (org.w3._2007.rif.Declare)1 Do (org.w3._2007.rif.Do)1 Exists (org.w3._2007.rif.Exists)1 Frame (org.w3._2007.rif.Frame)1 If (org.w3._2007.rif.If)1 Implies (org.w3._2007.rif.Implies)1 ThenPart (org.w3._2007.rif.ThenPart)1