public void visit(SWRLSameIndividualAtom atom) { Set<OWLNamedIndividual> inds=new HashSet<OWLNamedIndividual>(); for (SWRLArgument arg : atom.getAllArguments()) { if (!(arg instanceof SWRLIndividualArgument)) throwVarError(atom); OWLIndividual ind=((SWRLIndividualArgument)arg).getIndividual(); if (ind.isAnonymous()) throwAnonIndError(atom); inds.add(ind.asOWLNamedIndividual()); } addFact(m_factory.getOWLSameIndividualAxiom(inds)); }
@Override public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof SWRLSameIndividualAtom)) { return false; } SWRLSameIndividualAtom other = (SWRLSameIndividualAtom) obj; return other.getAllArguments().equals(getAllArguments()); }
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()]))); } }
public void visit(SWRLSameIndividualAtom at) { if (m_isPositive) m_normalizedHeadAtoms.add(m_factory.getSWRLSameIndividualAtom(getVariableFor(at.getFirstArgument()),getVariableFor(at.getSecondArgument()))); else throw new IllegalStateException("Internal error: this SWRLSameIndividualAtom should have been processed earlier."); }
public Atom visit(SWRLSameIndividualAtom atom) { Variable variable1=toVariable(atom.getFirstArgument()); Variable variable2=toVariable(atom.getSecondArgument()); return Atom.create(Equality.INSTANCE,variable1,variable2); }
@Override public O visit(SWRLSameIndividualAtom node) { return doDefault(node); }
@Override public void visit(SWRLSameIndividualAtom node) { handleDefault(node); }
@Override public void visit(SWRLSameIndividualAtom node) { type = RULE_OBJECT_TYPE_INDEX_BASE + 9; }
@Override public void visit(SWRLSameIndividualAtom node) { node.getFirstArgument().accept(this); node.getSecondArgument().accept(this); }
@Override public void visit(SWRLSameIndividualAtom node) { hashCode = primes[71]; hashCode = hashCode * MULT + node.getFirstArgument().hashCode(); hashCode = hashCode * MULT + node.getSecondArgument().hashCode(); }
@Override public SWRLSameIndividualAtom visit(SWRLSameIndividualAtom node) { return node; }
@Override public void visit(@Nonnull SWRLSameIndividualAtom node) { node.getFirstArgument().accept(this); node.getSecondArgument().accept(this); }
@Override protected void writeObject(SWRLSameIndividualAtom object, BinaryOWLOutputStream outputStream) throws IOException { outputStream.writeOWLObject(object.getFirstArgument()); outputStream.writeOWLObject(object.getSecondArgument()); }
@Override protected SWRLSameIndividualAtom readObject(BinaryOWLInputStream inputStream) throws IOException, BinaryOWLParseException { SWRLIArgument first = inputStream.readOWLObject(); SWRLIArgument second = inputStream.readOWLObject(); return inputStream.getDataFactory().getSWRLSameIndividualAtom(first, second); }