我正在 java 程序中使用 Protege OWL API,但在加载本体时遇到问题。当我尝试 URI 时,它起作用了。但是,当我尝试在计算机上使用本地路径时,它不起作用。
package Test;
import edu.stanford.smi.protegex.owl.ProtegeOWL;
import edu.stanford.smi.protegex.owl.jena.JenaOWLModel;
public class TestLoad {
public static JenaOWLModel Model =null;
public static String URI="http://protege.cim3.net/file/pub/ontologies/travel/travel.owl";
// change the URI by this "C:/Users/Sara/Desktop/travel.owl";
public static void main(String[] args)
{
try
{
Model=ProtegeOWL.createJenaOWLModelFromURI(URI);
System.out.println("Success");
}
catch (Exception exception)
{
System.out.println("Error");
}
}
}
最佳答案
您使用的字符串不是完整的 URI,因为 C:
不是协议(protocol)。
在字符串前加上 file:///
前缀,您应该会得到更好的结果。
关于java - Protege OWL API 使用 URI 加载本体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32872395/