Java 类org.semanticweb.owlapi.model.SWRLIArgument 实例源码

项目:Wolpertinger    文件:OWLNormalization.java   
public void visit(SWRLClassAtom at) {
    OWLClassExpression c=m_expressionManager.getSimplified(m_expressionManager.getNNF(at.getPredicate()));
    SWRLIArgument argument=at.getArgument();
    if (m_isPositive) {
        // head
        if (c instanceof OWLClass)
            m_normalizedHeadAtoms.add(m_factory.getSWRLClassAtom(c,argument));
        else {
            /*
            OWLClass definition=getClassFor(at.getPredicate(),m_alreadyExists);
            if (!m_alreadyExists[0])
                m_classExpressionInclusions.add(new OWLClassExpression[] { negative(definition),at.getPredicate() });
            m_normalizedHeadAtoms.add(m_factory.getSWRLClassAtom(definition,argument));
            */
        }
    }
    else {
        // body
        if (c instanceof OWLClass)
            m_normalizedBodyAtoms.add(m_factory.getSWRLClassAtom(c,argument));
        else {
            /*
            OWLClass definition=getClassFor(at.getPredicate(),m_alreadyExists);
            if (!m_alreadyExists[0])
                m_classExpressionInclusions.add(new OWLClassExpression[] { negative(at.getPredicate()),definition });
            m_normalizedBodyAtoms.add(m_factory.getSWRLClassAtom(definition,argument));
            */
        }
    }
}
项目:binaryowl    文件:SWRLObjectPropertyAtomSerializer.java   
@Override
protected SWRLObjectPropertyAtom readObject(BinaryOWLInputStream inputStream) throws IOException, BinaryOWLParseException {
    OWLObjectPropertyExpression predicate = inputStream.readOWLObject();
    SWRLIArgument firstArg = inputStream.readOWLObject();
    SWRLIArgument secondArg = inputStream.readOWLObject();
    return inputStream.getDataFactory().getSWRLObjectPropertyAtom(predicate, firstArg, secondArg);
}
项目:binaryowl    文件:SWRLDataPropertyAtomSerializer.java   
@Override
protected SWRLDataPropertyAtom readObject(BinaryOWLInputStream inputStream) throws IOException, BinaryOWLParseException {
    OWLDataPropertyExpression predicate = inputStream.readOWLObject();
    SWRLIArgument firstArg = inputStream.readOWLObject();
    SWRLDArgument secondArg = inputStream.readOWLObject();
    return inputStream.getDataFactory().getSWRLDataPropertyAtom(predicate, firstArg, secondArg);
}
项目:HermiT-android    文件:OWLNormalization.java   
public void visit(SWRLRule rule) {
    // Process head one-by-one and thus break up the conjunction in the head.
    for (SWRLAtom headAtom : rule.getHead()) {
        m_individualsToVariables.clear();
        m_bodyAtoms.clear();
        m_headAtoms.clear();
        m_variableRepresentative.clear();
        m_normalizedBodyAtoms.clear();
        m_normalizedHeadAtoms.clear();
        m_bodyDataRangeVariables.clear();
        m_headDataRangeVariables.clear();

        // Initialize body with all atoms, and initialize head with just the atom we are processing.
        m_bodyAtoms.addAll(rule.getBody());
        m_headAtoms.add(headAtom);

        // First process sameIndividual in the body to set up variable normalizations.
        for (SWRLAtom atom : rule.getBody()) {
            if (atom instanceof SWRLSameIndividualAtom) {
                m_bodyAtoms.remove(atom);
                SWRLSameIndividualAtom sameIndividualAtom=(SWRLSameIndividualAtom)atom;
                SWRLVariable variable1=getVariableFor(sameIndividualAtom.getFirstArgument());
                SWRLIArgument argument2=sameIndividualAtom.getSecondArgument();
                if (argument2 instanceof SWRLVariable)
                    m_variableRepresentative.put((SWRLVariable)argument2,variable1);
                else {
                    OWLIndividual individual=((SWRLIndividualArgument)argument2).getIndividual();
                    if (individual.isAnonymous())
                        throw new IllegalArgumentException("Internal error: Rules with anonymous individuals are not supported. ");
                    m_individualsToVariables.put(individual.asOWLNamedIndividual(),variable1);
                    m_bodyAtoms.add(m_factory.getSWRLClassAtom(m_factory.getOWLObjectOneOf(individual),variable1));
                }
            }
        }

        // Now process head atoms; this might increase the number of body atoms.
        m_isPositive=true;
        while (!m_headAtoms.isEmpty())
            m_headAtoms.remove(0).accept(this);

        // Now process body atoms.
        m_isPositive=false;
        while (!m_bodyAtoms.isEmpty())
            m_bodyAtoms.remove(0).accept(this);

        // Do some checking and return the rule.
        if (!m_bodyDataRangeVariables.containsAll(m_headDataRangeVariables))
            throw new IllegalArgumentException("A SWRL rule contains data range variables in the head, but not in the body, and this is not supported.");
        m_rules.add(new OWLAxioms.DisjunctiveRule(m_normalizedBodyAtoms.toArray(new SWRLAtom[m_normalizedBodyAtoms.size()]),m_normalizedHeadAtoms.toArray(new SWRLAtom[m_normalizedHeadAtoms.size()])));
    }
}
项目:HermiT-android    文件:OWLClausification.java   
protected static Variable toVariable(SWRLIArgument argument) {
    if (argument instanceof SWRLVariable)
        return Variable.create(((SWRLVariable)argument).getIRI().toString());
    else
        throw new IllegalStateException("Internal error: all arguments in a SWRL rule should have been normalized to variables.");
}
项目:Hermit_1.3.8_android    文件:OWLNormalization.java   
public void visit(SWRLRule rule) {
    // Process head one-by-one and thus break up the conjunction in the head.
    for (SWRLAtom headAtom : rule.getHead()) {
        m_individualsToVariables.clear();
        m_bodyAtoms.clear();
        m_headAtoms.clear();
        m_variableRepresentative.clear();
        m_normalizedBodyAtoms.clear();
        m_normalizedHeadAtoms.clear();
        m_bodyDataRangeVariables.clear();
        m_headDataRangeVariables.clear();

        // Initialize body with all atoms, and initialize head with just the atom we are processing.
        m_bodyAtoms.addAll(rule.getBody());
        m_headAtoms.add(headAtom);

        // First process sameIndividual in the body to set up variable normalizations.
        for (SWRLAtom atom : rule.getBody()) {
            if (atom instanceof SWRLSameIndividualAtom) {
                m_bodyAtoms.remove(atom);
                SWRLSameIndividualAtom sameIndividualAtom=(SWRLSameIndividualAtom)atom;
                SWRLVariable variable1=getVariableFor(sameIndividualAtom.getFirstArgument());
                SWRLIArgument argument2=sameIndividualAtom.getSecondArgument();
                if (argument2 instanceof SWRLVariable)
                    m_variableRepresentative.put((SWRLVariable)argument2,variable1);
                else {
                    OWLIndividual individual=((SWRLIndividualArgument)argument2).getIndividual();
                    if (individual.isAnonymous())
                        throw new IllegalArgumentException("Internal error: Rules with anonymous individuals are not supported. ");
                    m_individualsToVariables.put(individual.asOWLNamedIndividual(),variable1);
                    m_bodyAtoms.add(m_factory.getSWRLClassAtom(m_factory.getOWLObjectOneOf(individual),variable1));
                }
            }
        }

        // Now process head atoms; this might increase the number of body atoms.
        m_isPositive=true;
        while (!m_headAtoms.isEmpty())
            m_headAtoms.remove(0).accept(this);

        // Now process body atoms.
        m_isPositive=false;
        while (!m_bodyAtoms.isEmpty())
            m_bodyAtoms.remove(0).accept(this);

        // Do some checking and return the rule.
        if (!m_bodyDataRangeVariables.containsAll(m_headDataRangeVariables))
            throw new IllegalArgumentException("A SWRL rule contains data range variables in the head, but not in the body, and this is not supported.");
        m_rules.add(new OWLAxioms.DisjunctiveRule(m_normalizedBodyAtoms.toArray(new SWRLAtom[m_normalizedBodyAtoms.size()]),m_normalizedHeadAtoms.toArray(new SWRLAtom[m_normalizedHeadAtoms.size()])));
    }
}
项目:Hermit_1.3.8_android    文件:OWLClausification.java   
protected static Variable toVariable(SWRLIArgument argument) {
    if (argument instanceof SWRLVariable)
        return Variable.create(((SWRLVariable)argument).getIRI().toString());
    else
        throw new IllegalStateException("Internal error: all arguments in a SWRL rule should have been normalized to variables.");
}
项目:Wolpertinger    文件:OWLNormalization.java   
public void visit(SWRLRule rule) {
    // Process head one-by-one and thus break up the conjunction in the head.
    for (SWRLAtom headAtom : rule.getHead()) {
        m_individualsToVariables.clear();
        m_bodyAtoms.clear();
        m_headAtoms.clear();
        m_variableRepresentative.clear();
        m_normalizedBodyAtoms.clear();
        m_normalizedHeadAtoms.clear();
        m_bodyDataRangeVariables.clear();
        m_headDataRangeVariables.clear();

        // Initialize body with all atoms, and initialize head with just the atom we are processing.
        m_bodyAtoms.addAll(rule.getBody());
        m_headAtoms.add(headAtom);

        // First process sameIndividual in the body to set up variable normalizations.
        for (SWRLAtom atom : rule.getBody()) {
            if (atom instanceof SWRLSameIndividualAtom) {
                m_bodyAtoms.remove(atom);
                SWRLSameIndividualAtom sameIndividualAtom=(SWRLSameIndividualAtom)atom;
                SWRLVariable variable1=getVariableFor(sameIndividualAtom.getFirstArgument());
                SWRLIArgument argument2=sameIndividualAtom.getSecondArgument();
                if (argument2 instanceof SWRLVariable)
                    m_variableRepresentative.put((SWRLVariable)argument2,variable1);
                else {
                    OWLIndividual individual=((SWRLIndividualArgument)argument2).getIndividual();
                    if (individual.isAnonymous())
                        throw new IllegalArgumentException("Internal error: Rules with anonymous individuals are not supported. ");
                    m_individualsToVariables.put(individual.asOWLNamedIndividual(),variable1);
                    m_bodyAtoms.add(m_factory.getSWRLClassAtom(m_factory.getOWLObjectOneOf(individual),variable1));
                }
            }
        }

        // Now process head atoms; this might increase the number of body atoms.
        m_isPositive=true;
        while (!m_headAtoms.isEmpty())
            m_headAtoms.remove(0).accept(this);

        // Now process body atoms.
        m_isPositive=false;
        while (!m_bodyAtoms.isEmpty())
            m_bodyAtoms.remove(0).accept(this);

        // Do some checking and return the rule.
        if (!m_bodyDataRangeVariables.containsAll(m_headDataRangeVariables))
            throw new IllegalArgumentException("A SWRL rule contains data range variables in the head, but not in the body, and this is not supported.");
        m_rules.add(new OWLAxioms.DisjunctiveRule(m_normalizedBodyAtoms.toArray(new SWRLAtom[m_normalizedBodyAtoms.size()]),m_normalizedHeadAtoms.toArray(new SWRLAtom[m_normalizedHeadAtoms.size()])));
    }
}
项目:Wolpertinger    文件:OWLNormalization.java   
public void visit(SWRLObjectPropertyAtom at) {
    OWLObjectPropertyExpression ope=at.getPredicate().getSimplified();
    OWLObjectProperty op=ope.getNamedProperty();

    SWRLIArgument argument1;
    SWRLIArgument argument2;

    if (ope.isAnonymous()) {
        argument1=at.getSecondArgument();
        argument2=at.getFirstArgument();
    }
    else {
        argument1=at.getFirstArgument();
        argument2=at.getSecondArgument();

    }

    SWRLAtom newAtom=m_factory.getSWRLObjectPropertyAtom(op,argument1,argument2);


    /* we omitted the rule normalization from HermiT
    SWRLVariable variable1;
    SWRLVariable variable2;


    if (ope.isAnonymous()) {
        variable1=getVariableFor(at.getSecondArgument());
        variable2=getVariableFor(at.getFirstArgument());
    }
    else {
        variable1=getVariableFor(at.getFirstArgument());
        variable2=getVariableFor(at.getSecondArgument());

    }
    SWRLAtom newAtom=m_factory.getSWRLObjectPropertyAtom(op,variable1,variable2);
    */
    if (m_isPositive) {
        // head
        m_normalizedHeadAtoms.add(newAtom);
    }
    else {
        // body
        m_normalizedBodyAtoms.add(newAtom);
    }
}
项目:binaryowl    文件:SWRLDifferentIndividualsAtomSerializer.java   
@Override
protected SWRLDifferentIndividualsAtom readObject(BinaryOWLInputStream inputStream) throws IOException, BinaryOWLParseException {
    SWRLIArgument first = inputStream.readOWLObject();
    SWRLIArgument second = inputStream.readOWLObject();
    return inputStream.getDataFactory().getSWRLDifferentIndividualsAtom(first, second);
}
项目:binaryowl    文件:SWRLClassAtomSerializer.java   
@Override
protected SWRLClassAtom readObject(BinaryOWLInputStream inputStream) throws IOException, BinaryOWLParseException {
    OWLClassExpression predicate = inputStream.readOWLObject();
    SWRLIArgument arg = inputStream.readOWLObject();
    return inputStream.getDataFactory().getSWRLClassAtom(predicate, arg);
}
项目:binaryowl    文件:SWRLSameIndividualAtomSerializer.java   
@Override
protected SWRLSameIndividualAtom readObject(BinaryOWLInputStream inputStream) throws IOException, BinaryOWLParseException {
    SWRLIArgument first = inputStream.readOWLObject();
    SWRLIArgument second = inputStream.readOWLObject();
    return inputStream.getDataFactory().getSWRLSameIndividualAtom(first, second);
}
项目:owlapi-gwt    文件:SWRLSameIndividualAtomImpl.java   
/**
 * @param property
 *        property
 * @param arg0
 *        first individual
 * @param arg1
 *        second individual
 */
public SWRLSameIndividualAtomImpl(@Nonnull OWLObjectProperty property,
        @Nonnull SWRLIArgument arg0, @Nonnull SWRLIArgument arg1) {
    super(checkNotNull(property, "property cannot be null"), checkNotNull(
            arg0, "arg0 cannot be null"), checkNotNull(arg1,
            "arg1 cannot be null"));
}
项目:owlapi-gwt    文件:SWRLDifferentIndividualsAtomImpl.java   
/**
 * @param property
 *        property
 * @param arg0
 *        first individual
 * @param arg1
 *        second individual
 */
public SWRLDifferentIndividualsAtomImpl(
        @Nonnull OWLObjectProperty property, @Nonnull SWRLIArgument arg0,
        @Nonnull SWRLIArgument arg1) {
    super(checkNotNull(property, "property cannot be null"), checkNotNull(
            arg0, "arg0 cannot be null"), checkNotNull(arg1,
            "arg1 cannot be null"));
}
项目:owlapi-gwt    文件:SWRLDataPropertyAtomImpl.java   
/**
 * @param predicate
 *        predicate
 * @param arg0
 *        subject
 * @param arg1
 *        object
 */
public SWRLDataPropertyAtomImpl(
        @Nonnull OWLDataPropertyExpression predicate,
        @Nonnull SWRLIArgument arg0, @Nonnull SWRLDArgument arg1) {
    super(predicate, arg0, arg1);
}
项目:owlapi-gwt    文件:SWRLClassAtomImpl.java   
/**
 * @param predicate
 *        predicate
 * @param arg
 *        class argument
 */
public SWRLClassAtomImpl(@Nonnull OWLClassExpression predicate,
        @Nonnull SWRLIArgument arg) {
    super(predicate, arg);
}
项目:owlapi-gwt    文件:SWRLObjectPropertyAtomImpl.java   
/**
 * @param predicate
 *        property
 * @param arg0
 *        subject
 * @param arg1
 *        object
 */
public SWRLObjectPropertyAtomImpl(
        @Nonnull OWLObjectPropertyExpression predicate,
        @Nonnull SWRLIArgument arg0, @Nonnull SWRLIArgument arg1) {
    super(predicate, arg0, arg1);
}