跳到正文
Skillpedia
数据库14k · #11154

query

它能做什么

这项技能搜索 Semantica 知识图谱,图谱可以在内存中,也可以位于外部 RDF 或图数据库里。适合想在图谱中查找特定事实和关联的人。

适用场景

  • ✓当你想用一组关键词搜索知识图谱的时候。
  • ✓当你的图谱存储在 RDF 三元组存储中,需要 SPARQL 查询的时候。
  • ✓当你的图谱位于带标签属性图数据库中,需要 Cypher 查询的时候。

技能链接

https://github.com/semantica-agi/semantica/blob/main/plugins/skills/query/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/semantica-agi/semantica/blob/main/plugins/skills/query/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请帮我在知识图谱中搜索所有与供应商选择相关的内容?”

每周 5 个新技能,1 分钟读完。

工作原理

智能体会加载图谱,并在其条目中运行你的搜索;或者把 SPARQL 或 Cypher 查询发送到你指定的数据库。然后它会返回匹配的结果。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

/semantica:query

Query the graph. Usage: /semantica:query <task> [args]

Which API you want depends on where the graph lives.


search "<keywords>" — the in-memory ContextGraph

This is the one that works with no external server.

import os
from semantica.context import ContextGraph

graph = ContextGraph()
graph.load_from_file(os.path.expanduser("~/.semantica/kg.json"))   # load_from_file does not expand ~

results = graph.query("vendor selection", skip=0, limit=20)

Related lookups on the same object:

graph.find_nodes(...)          graph.find_node(...)
graph.find_related_nodes(...)  graph.get_neighbors(node_id)
graph.find_similar_nodes(...)  graph.get_nodes_by_label(label)

Decision-specific queries belong to /semantica:decision.


sparql "<query>" — RDF triple stores

from semantica.triplet_store import TripletStore

store = TripletStore(backend="oxigraph")       # embedded; needs semantica[tripletstore-oxigraph]
# or backend="blazegraph" | "jena" | "rdf4j" with endpoint="http://..."
result = store.execute_query(sparql)

For query planning, optimisation, and caching over a backend:

from semantica.triplet_store import QueryEngine, OxigraphStore

# QueryEngine needs an object exposing execute_sparql() — the raw backend,
# not the TripletStore wrapper above (which only exposes execute_query()).
backend = OxigraphStore()

qe = QueryEngine()
plan   = qe.plan_query(sparql)
tuned  = qe.optimize_query(sparql)
result = qe.execute_query(sparql, store_backend=backend)
stats  = qe.get_query_statistics()

Blazegraph / Jena / RDF4J need no extra — semantica.triplet_store speaks SPARQL over HTTP using the core requests dependency.


cypher "<query>" — labeled property graphs

from semantica.graph_store import Neo4jStore    # needs semantica[graph-neo4j]

store = Neo4jStore(uri=..., user=..., password=...)
result = store.execute_query(query, parameters={...})

Also available: FalkorDBStore, ApacheAgeStore, AmazonNeptuneStore, and GraphManager / GraphStore for backend-agnostic access.

Not installed in this environment — add the backend extra first, e.g. pip install "semantica[graph-neo4j]".

常见问题

关键词搜索需要数据库服务器吗?

不需要。关键词搜索可以在从文件加载到内存中的图谱上进行。

什么是 SPARQL?

它是一种查询语言,用于查询以 RDF 三元组形式存储的关联数据图谱。

文中提到了哪些数据库?

技能提到了嵌入式的 Oxigraph 存储,以及 Blazegraph、Jena 和 RDF4J 等其他 RDF 存储。

详情

作者的原始描述

Query Semantica knowledge graphs — in-memory ContextGraph search, SPARQL over RDF triple stores, and Cypher over LPG backends.

repo: semantica-agi/semantica

热度

GitHub 星标
14k
排名
#11154
许可证
MIT
更新时间
2026/11/2

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能