受保护的 OWL API 编程
Protégé OWL API programming
我的代码有问题我正在使用 Protege OWL API (3.4.8) 处理 antologie 文件,我想定义所有 类本体中的用户,问题是我在 for 循环中一直有错误我无法修复这些错误,有什么办法可以得到 类.
package Test;
import java.util.Collection;
import javax.swing.text.html.HTMLDocument.Iterator;
import antlr.collections.List;
import edu.stanford.smi.protege.model.Cls;
import edu.stanford.smi.protegex.owl.ProtegeOWL;
import edu.stanford.smi.protegex.owl.jena.JenaOWLModel;
import edu.stanford.smi.protegex.owl.model.OWLDatatypeProperty;
import edu.stanford.smi.protegex.owl.model.OWLIndividual;
import edu.stanford.smi.protegex.owl.model.OWLModel;
import edu.stanford.smi.protegex.owl.model.OWLNamedClass;
import edu.stanford.smi.protegex.owl.model.OWLObjectProperty;
import edu.stanford.smi.protegex.owl.model.RDFSClass;
public class Class4 {
public static JenaOWLModel owlModel =null;
public static String scorKos_Uri="C:/Users/souad/Desktop/SCOR-KOS.owl";
//where my ontologie file exist
//change the URI by this
"http://protege.cim3.net/file/pub/ontologies/travel/travel.owl"; to have a
OWL file
/**
* @param args
*/
public static void main(String[] args) {
/**
* ontologie
*/
try {
owlModel=ProtegeOWL.createJenaOWLModelFromURI(scorKos_Uri);
System.out.println("Worked");
Collection classes = owlModel.getUserDefinedOWLNamedClasses();
for (Iterator it = classes.iterator(); it.hasNext();) {
OWLNamedClass cls = (OWLNamedClass) it.next();
Collection instances = cls.getInstances(false);
System.out.println("Class " + cls.getBrowserText() + " (" +
instances.size() + ")");
for (Iterator jt = instances.iterator(); jt.hasNext();) {
OWLIndividual individual = (OWLIndividual) jt.next();
System.out.println(" - " + individual.getBrowserText());
}
}
}catch (Exception exception) {
System.out.println("Error can't upload the ontologie ");
System.exit(1);
}
}
}
您没有导入 java.util.Iterator
。
我的代码有问题我正在使用 Protege OWL API (3.4.8) 处理 antologie 文件,我想定义所有 类本体中的用户,问题是我在 for 循环中一直有错误我无法修复这些错误,有什么办法可以得到 类.
package Test;
import java.util.Collection;
import javax.swing.text.html.HTMLDocument.Iterator;
import antlr.collections.List;
import edu.stanford.smi.protege.model.Cls;
import edu.stanford.smi.protegex.owl.ProtegeOWL;
import edu.stanford.smi.protegex.owl.jena.JenaOWLModel;
import edu.stanford.smi.protegex.owl.model.OWLDatatypeProperty;
import edu.stanford.smi.protegex.owl.model.OWLIndividual;
import edu.stanford.smi.protegex.owl.model.OWLModel;
import edu.stanford.smi.protegex.owl.model.OWLNamedClass;
import edu.stanford.smi.protegex.owl.model.OWLObjectProperty;
import edu.stanford.smi.protegex.owl.model.RDFSClass;
public class Class4 {
public static JenaOWLModel owlModel =null;
public static String scorKos_Uri="C:/Users/souad/Desktop/SCOR-KOS.owl";
//where my ontologie file exist
//change the URI by this
"http://protege.cim3.net/file/pub/ontologies/travel/travel.owl"; to have a
OWL file
/**
* @param args
*/
public static void main(String[] args) {
/**
* ontologie
*/
try {
owlModel=ProtegeOWL.createJenaOWLModelFromURI(scorKos_Uri);
System.out.println("Worked");
Collection classes = owlModel.getUserDefinedOWLNamedClasses();
for (Iterator it = classes.iterator(); it.hasNext();) {
OWLNamedClass cls = (OWLNamedClass) it.next();
Collection instances = cls.getInstances(false);
System.out.println("Class " + cls.getBrowserText() + " (" +
instances.size() + ")");
for (Iterator jt = instances.iterator(); jt.hasNext();) {
OWLIndividual individual = (OWLIndividual) jt.next();
System.out.println(" - " + individual.getBrowserText());
}
}
}catch (Exception exception) {
System.out.println("Error can't upload the ontologie ");
System.exit(1);
}
}
}
您没有导入 java.util.Iterator
。