有没有办法列出 TDB 存储中包含的模型?

发布于 2024-11-09 18:59:54 字数 146 浏览 3 评论 0原文

创建 TDB 存储并在其中存储各种命名模型。

API 是否可以列出 TDB 中包含的所有命名模型(以便您可以选择一个来使用),或者是否有必要事先知道要使用的模型的名称?

我在 APi 文档中没有找到任何关于此的内容(仅用于创建模型)或谷歌搜索。

A TDB storage is created and various named models stored within.

Is it posible with the API to list all the named models contained in the TDB (so you can pick one to work with) or is it necesary to know the name of the model you want to work with beforehand?

I find nothing in the APi documentation about this (just for creating models) or googling.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

最佳男配角 2024-11-16 18:59:54

您可以使用 sparql 查询来完成此操作:

[/tmp]
ian@rowan-15 $ cat > test.nq
<http://example.org/a> <http://example.org/p> "in graph one" <http://example.org/graph/one> .
<http://example.org/a> <http://example.org/p> "in graph two" <http://example.org/graph/two> .
[/tmp]
ian@rowan-15 $ mkdir tdb
[/tmp]
ian@rowan-15 $ tdbloader --loc=tdb test.nq
-- Start triples data phase
** Load empty triples table
-- Start quads data phase
** Load empty quads table
Load: test.nq -- 2011/05/27 08:55:59 BST
-- Finish triples data phase
-- Finish quads data phase
2 quads loaded in 0.05 seconds [Rate: 37.74 per second]
-- Start quads index phase
** Index GSPO->GPOS: 2 slots indexed
** Index GSPO->GOSP: 2 slots indexed in 0.00 seconds [Rate: 2,000.00 per second]
** Index GSPO->POSG: 2 slots indexed
** Index GSPO->OSPG: 2 slots indexed
** Index GSPO->SPOG: 2 slots indexed
-- Finish quads index phase
** 2 quads indexed in 0.01 seconds [Rate: 153.85 per second]
-- Finish triples load
-- Finish quads load
** Completed: 2 quads loaded in 0.09 seconds [Rate: 23.26 per second]
[/tmp]
ian@rowan-15 $ tdbquery --loc=tdb "select ?g where {graph ?g {?s ?p ?o}}"
----------------------------------
| g                              |
==================================
| <http://example.org/graph/one> |
| <http://example.org/graph/two> |
----------------------------------

编辑

抱歉,刚刚意识到您特别要求列出 API 中的命名图。因此,作为上述的替代方案:

String directory = "./tdb";
Dataset dataset = TDBFactory.createDataset(directory);
Iterator<String> graphNames = dataset.listNames();
while (graphNames.hasNext()) {
    String graphName = graphNames.next();
    ....
}

You can do it with a sparql query:

[/tmp]
ian@rowan-15 $ cat > test.nq
<http://example.org/a> <http://example.org/p> "in graph one" <http://example.org/graph/one> .
<http://example.org/a> <http://example.org/p> "in graph two" <http://example.org/graph/two> .
[/tmp]
ian@rowan-15 $ mkdir tdb
[/tmp]
ian@rowan-15 $ tdbloader --loc=tdb test.nq
-- Start triples data phase
** Load empty triples table
-- Start quads data phase
** Load empty quads table
Load: test.nq -- 2011/05/27 08:55:59 BST
-- Finish triples data phase
-- Finish quads data phase
2 quads loaded in 0.05 seconds [Rate: 37.74 per second]
-- Start quads index phase
** Index GSPO->GPOS: 2 slots indexed
** Index GSPO->GOSP: 2 slots indexed in 0.00 seconds [Rate: 2,000.00 per second]
** Index GSPO->POSG: 2 slots indexed
** Index GSPO->OSPG: 2 slots indexed
** Index GSPO->SPOG: 2 slots indexed
-- Finish quads index phase
** 2 quads indexed in 0.01 seconds [Rate: 153.85 per second]
-- Finish triples load
-- Finish quads load
** Completed: 2 quads loaded in 0.09 seconds [Rate: 23.26 per second]
[/tmp]
ian@rowan-15 $ tdbquery --loc=tdb "select ?g where {graph ?g {?s ?p ?o}}"
----------------------------------
| g                              |
==================================
| <http://example.org/graph/one> |
| <http://example.org/graph/two> |
----------------------------------

Edit

Sorry, just realised that you specifically asked for listing the named graphs from the API. So, as an alternative to the above:

String directory = "./tdb";
Dataset dataset = TDBFactory.createDataset(directory);
Iterator<String> graphNames = dataset.listNames();
while (graphNames.hasNext()) {
    String graphName = graphNames.next();
    ....
}
贪了杯 2024-11-16 18:59:54

此 SPARQL 查询应该有效:

SELECT DISTINCT ?g WHERE { GRAPH ?g { } }

This SPARQL query should work:

SELECT DISTINCT ?g WHERE { GRAPH ?g { } }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文