OWL-S 前置条件表达式提取
OWL-S Precondition expression extracting
我正在尝试将前提条件的表达式提取为 SWRL 以制作 IOPE 网络服务OWL-S 匹配
这是我的代码
final OWLIndividualList<Condition> cs = service.getProcess().getConditions();
final ArrayList<ArrayList<URI>> conditions = new ArrayList<ArrayList<URI>>();
for (final Condition<?> c : cs){
if (c.canCastTo(Condition.SWRL.class)){
final Condition.SWRL sc = c.castTo(Condition.SWRL.class);
for (final Atom a : sc.getBody()){
a.accept(new AtomVisitor() {
public void visit(final IndividualPropertyAtom atom){
URI aux = null;
final ArrayList<URI> uris = new ArrayList<URI>();
URI a1 = aux.create((atom.getArgument1().getNamespace().toString()
+atom.getArgument1().toString()));
URI a2 = aux.create((atom.getArgument2().getNamespace().toString()
+atom.getArgument2().toString()));
URI p = aux.create(atom.getPropertyPredicate().toString());
uris.add(p);
uris.add(a1);
uris.add(a2);
conditions.add(uris);
}
public void visit(final DataPropertyAtom atom) { }
public void visit(final SameIndividualAtom atom) { }
public void visit(final DifferentIndividualsAtom atom) { }
public void visit(final ClassAtom atom) { }
public void visit(final BuiltinAtom atom) { }
});
}
}
}
我在“final Atom a : sc.getBody()”java.lang.NullPointerException 上得到一个 java.lang.NullPointerException
OWL-S 前置条件语句
<expr:SWRL-Condition rdf:ID="DifferentLocations">
<expr:expressionLanguage rdf:resource="http://www.daml.org/services/owl-
s/1.2/generic/Expression.owl#SWRL"/>
<expr:expressionBody rdf:parseType="Literal">
<swrl:AtomList>
<rdf:first>
<swrl:DifferentIndividualsAtom>
<swrl:argument1 rdf:resource="#_GEOPOLITICAL-ENTITY"/>
<swrl:argument2 rdf:resource="#_GEOPOLITICAL-ENTITY1"/>
</swrl:DifferentIndividualsAtom>
</rdf:first>
<rdf:rest rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"/>
</swrl:AtomList>
</expr:expressionBody>
</expr:SWRL-Condition>
拜托,我需要帮助
此问题与 java 代码无关,而是与 OWLS-S 文件语法相关。您可以通过替换来解决此问题:
<expr:expressionBody rdf:parseType="Literal">
持有 SWRL 前提条件(或最终结果),作者:
<expr:expressionObject>
我正在尝试将前提条件的表达式提取为 SWRL 以制作 IOPE 网络服务OWL-S 匹配
这是我的代码
final OWLIndividualList<Condition> cs = service.getProcess().getConditions();
final ArrayList<ArrayList<URI>> conditions = new ArrayList<ArrayList<URI>>();
for (final Condition<?> c : cs){
if (c.canCastTo(Condition.SWRL.class)){
final Condition.SWRL sc = c.castTo(Condition.SWRL.class);
for (final Atom a : sc.getBody()){
a.accept(new AtomVisitor() {
public void visit(final IndividualPropertyAtom atom){
URI aux = null;
final ArrayList<URI> uris = new ArrayList<URI>();
URI a1 = aux.create((atom.getArgument1().getNamespace().toString()
+atom.getArgument1().toString()));
URI a2 = aux.create((atom.getArgument2().getNamespace().toString()
+atom.getArgument2().toString()));
URI p = aux.create(atom.getPropertyPredicate().toString());
uris.add(p);
uris.add(a1);
uris.add(a2);
conditions.add(uris);
}
public void visit(final DataPropertyAtom atom) { }
public void visit(final SameIndividualAtom atom) { }
public void visit(final DifferentIndividualsAtom atom) { }
public void visit(final ClassAtom atom) { }
public void visit(final BuiltinAtom atom) { }
});
}
}
}
我在“final Atom a : sc.getBody()”java.lang.NullPointerException 上得到一个 java.lang.NullPointerException
OWL-S 前置条件语句
<expr:SWRL-Condition rdf:ID="DifferentLocations">
<expr:expressionLanguage rdf:resource="http://www.daml.org/services/owl-
s/1.2/generic/Expression.owl#SWRL"/>
<expr:expressionBody rdf:parseType="Literal">
<swrl:AtomList>
<rdf:first>
<swrl:DifferentIndividualsAtom>
<swrl:argument1 rdf:resource="#_GEOPOLITICAL-ENTITY"/>
<swrl:argument2 rdf:resource="#_GEOPOLITICAL-ENTITY1"/>
</swrl:DifferentIndividualsAtom>
</rdf:first>
<rdf:rest rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"/>
</swrl:AtomList>
</expr:expressionBody>
</expr:SWRL-Condition>
拜托,我需要帮助
此问题与 java 代码无关,而是与 OWLS-S 文件语法相关。您可以通过替换来解决此问题:
<expr:expressionBody rdf:parseType="Literal">
持有 SWRL 前提条件(或最终结果),作者:
<expr:expressionObject>