我使用的是OWL-S (源代码和javadoc在这里:http://on.cs.unibas.ch/owls-api/apidocs/ )
如果我这样做,我就得到了正确的结果:
public class Example {
private static ISWRLFactory factory; //is a interface
private string url = "http://...";
private Service aService;
private OWLOntology ont;
void method_A(){
URI aURI = URI.create(url);
OWLKnowledgeBase aKB = OWLFactory.createKB();
aService = aKB.readService(aURI);
ont = aKB.createOntology(aURI);
ont.createService(aService.getURI());
}
void method_B(){
factory = SWRLFactory.createFactory(ont);
Atom builtAtom = factory.createNotEqual(x, variab); //x and variab are two variable
}
}但如果我这样做,我就得不到正确的结果:
public class Example {
private static ISWRLFactory factory; //is a interface
private string url = "http://...";
private Service aService;
private OWLOntology ont;
void method_A(){
URI aURI = URI.create(url);
OWLKnowledgeBase aKB = OWLFactory.createKB();
aService = aKB.readService(aURI);
ont = aKB.createOntology(aURI);
ont.createService(aService.getURI());
factory = SWRLFactory.createFactory(ont);
}
void method_B(){
Atom builtAtom = factory.createNotEqual(x, variab); //x and variab are two variable
}
}为什么?
发布于 2013-11-27 02:57:45
在method_A()和method_B()中执行“factory = SWRLFactory.createFactory(ont);”行存在差异。您确定在method_A()和method_B()调用之间没有修改“factory”对象吗?'x‘和'variable’对'factory‘有依赖吗?
https://stackoverflow.com/questions/20225269
复制相似问题