gpt4 book ai didi

java - 如何使用耶拿图书馆将三元组插入议会三元组存储

转载 作者:行者123 更新时间:2023-12-01 13:41:19 25 4
gpt4 key购买 nike

嗨,我想添加基于空间的三元组

http://www.izmirdeafet.com/Disaster htp://www.opengis.net/ont/geosparql#asWKT> "htp://www.opengis.net/def/crs/OGC/1.3/CRS84 POINT (8.46035239692792 51.48661096320327)"^^<http://www.opengis.net/ont/sf#wktLiteral>

进入议会三重商店 jena下面的java代码中的库,但我在下面出现了错误。我有基于空间的本体,我已经将其添加到三重存储中。

public static void main(String[] args) {       
// set to false when running the second time to avoid recreating the graphs/index
boolean firstTime = true;
// create spatial index factory and configure for GeoSPARQL. This is used
// by the GraphStore whenever a new named graph is created.
SpatialIndexFactory factory = new SpatialIndexFactory();
Properties properties = new Properties();
properties.setProperty(Constants.GEOMETRY_INDEX_TYPE,
Constants.GEOMETRY_INDEX_RTREE);
properties.setProperty(Constants.GEOSPARQL_ENABLED,
Boolean.TRUE.toString());
factory.configure(properties);

// register factory
IndexFactoryRegistry.getInstance().register(factory);

// create a Parliament graph and graph store
//KbGraph graph= KbGraphFactory.createNamedGraph();
KbGraph graph =
KbGraphFactory.createDefaultGraph("file:C:\\ParliamentKB\\data\\");
KbGraphStore graphStore = new KbGraphStore(graph);
graphStore.initialize();

if (firstTime) {
// create spatial index from factory
SpatialIndex index = factory.createIndex(graph, null);

// register index with IndexManager
IndexManager.getInstance().register(graph, null, factory, index);

// the following tells the graph store that the graph is now an
// indexing graph. This is necessary so that the next time Parliament
// loads, the index is read in automatically.
graphStore.setIndexingEnabled(KbGraphStore.DEFAULT_GRAPH_NODE, true);
}

// create a Jena model
Model model = ModelFactory.createModelForGraph(graph);

// load data
String fileName =
"C:\\Users\\Can\\Desktop\\DisasterOntologyEnglish\\disaster.rdf";
RDFFormat dataFormat = RDFFormat.parseFilename(fileName);
FileManager.get().readModel(model, fileName, dataFormat.toString());

// get index and print size
System.out.println(IndexManager.getInstance().
getIndexes(graph).get(0).size());

// do a spatial query
String query = ""
+ "\nPREFIX my: <http://somewhere/ApplicationSchema#>"
+ "\nPREFIX geo: <http://www.opengis.net/ont/OGC-GeoSPARQL/1.0/>"
+ "\nPREFIX geof:
<http://www.opengis.net/def/queryLanguage/OGC-GeoSPARQL/1.0/function/>"
+ "\nSELECT ?f" + "\nWHERE { my:A my:hasExactGeometry ?aGeom ."
+ "\n ?aGeom geo:asWKT ?aWKT ."
+ "\n ?f my:hasExactGeometry ?fGeom ."
+ "\n ?fGeom geo:asWKT ?fWKT ."
+ "\n FILTER (geof:sf-contains(?aWKT, ?fWKT) &&"
+ "\n !sameTerm(?aGeom, ?fGeom)) " + "\n}";

Query q = QueryFactory.create(query, Syntax.syntaxARQ);
ResultSet rs = QueryExecutionFactory.create(q, model).execSelect();
while (rs.hasNext()) {
System.out.println(rs.nextSolution());
}
}

错误

   Exception in thread "main" java.lang.UnsatisfiedLinkError: 
no Parliament in java.library.path
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at com.bbn.parliament.jni.Config.<clinit>(Config.java:184)
at com.bbn.parliament.jena.graph.KbGraphFactory.getKbConfigForDefaultGraph
(KbGraphFactory.java:81)
at com.bbn.parliament.jena.graph.KbGraphFactory.createDefaultGraph
(KbGraphFactory.java:38)
at com.disaster.demo.GeoSPARQLTest.main(GeoSPARQLTest.java:46)

我认为问题来自createdefaultgraph部分:

你说的目录路径取自 ParliamentConfig.txt

  KbGraph graph = KbGraphFactory.createDefaultGraph("file:C:\\ParliamentKB\\data\\");

我是这样写的,但是没用。

最佳答案

链接不满足的错误可能表示在java路径中找不到Parliament.dll。

检查此 SO 以获取有关 java 路径中 dll 的详细信息: java.lang.UnsatisfiedLinkError no *****.dll in java.library.path

此外,您是否遵循议会设置指南? http://parliament.semwebcentral.org/ParliamentUserGuide.pdf

您可能还想确保您使用的是正确的 dll...已经有一段时间了,所以我可能是错的,但我认为有 32 位和 64 位版本。

关于java - 如何使用耶拿图书馆将三元组插入议会三元组存储,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20746454/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com