python 如何在python中创建本体?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1762291/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-03 23:00:26  来源:igfitidea点击:

How to create an ontology in python?

pythontextcomputer-scienceontology

提问by TIMEX

Are there libraries or certain "techniques" that you can use to create an ontology of elements?

是否有可用于创建元素本体的库或某些“技术”?

Or "design patterns"?

还是“设计模式”?

I am talking about just a "graph" of things. Suppose I have a bunch of words. Certain words are "under" other words or "related" to other words. I need a good way to group them and know their relationship.

我只是在谈论事物的“图表”。假设我有一堆单词。某些词在其他词下或与其他词“相关”。我需要一个很好的方法来分组他们并了解他们的关系。

回答by Reinout van Rees

You can use rdflibfor storing triples. You then have to make your own decisions about the kind of ontology you want to build. Look at the OWL format for that.

您可以使用rdflib来存储三元组。然后,您必须自己决定要构建的本体类型。请查看 OWL 格式。

I toyed with python and ontologies during my PhD, so perhaps a quick scan through my thesis can give you some ideas. For instance a short OWL summaryor a UML model of a plone ontology tool.

我在攻读博士学位期间玩弄了 Python 和本体论,所以快速浏览一下我的论文也许会给你一些想法。例如一个简短的 OWL 摘要一个 plone 本体工具UML 模型

回答by miku

RDFLIBis a mature implementation of a triple store, with plenty of documentation.

RDFLIB是三元组存储的成熟实现,具有大量文档

However, this library worked for me only for smaller projects. For example there is a nice RDF/XML catalog of the Gutenberg Project Library, which i wasn't able to hack around with (on my dual-core, 2GBRAM machine), because it's simply too large (~ 100M) - even Java/Protege had a tendency to stall on this filesizes. It's a pity.

但是,这个库只适用于较小的项目。例如,Gutenberg Project Library有一个很好的 RDF/XML 目录,我无法破解它(在我的双核 2GBRAM 机器上),因为它实在是太大了(~ 100M)——甚至是 Java/ Protege 倾向于在此文件大小上停滞不前。真遗憾。

Alternative: http://seth-scripting.sourceforge.net/

替代方法:http: //seth-scripting.sourceforge.net/

回答by DNA

Suppose I have a bunch of words. Certain words are "under" other words or "related" to other words. I need a good way to group them and know their relationship.

假设我有一堆单词。某些词在其他词下或与其他词“相关”。我需要一个很好的方法来分组他们并了解他们的关系。

Take a look at wordnet, which is available in RDF format i.e. according to an RDF Schema ontology. This is exactly what you describe.

看看 wordnet,它以 RDF 格式提供,即根据 RDF 模式本体。这正是你所描述的。

http://www.w3.org/2006/03/wn/wn20/

http://www.w3.org/2006/03/wn/wn20/



(C. Fellbaum. WordNet: An Electronic Lexical Database. MIT Press, 1998. See also http://wordnet.princeton.edu/)

(C. Fellbaum。WordNet:电子词汇数据库。麻省理工学院出版社,1998 年。另见http://wordnet.princeton.edu/

(van Assem, Gangemi and Schreiber (eds.). RDF/OWL Representation of WordNet, W3C Working Draft 19 June 2006 W3C Working Draft 19 June 2006; http://www.w3.org/TR/2006/WD-wordnet-rdf-20060619/)

(van Assem、Gangemi 和 Schreiber (eds.)。WordNet 的 RDF/OWL 表示,W3C 工作草案 2006 年 6 月 19 日 W3C 工作草案 2006 年 6 月 19 日;http://www.w3.org/TR/2006/WD-wordnet- rdf-20060619/)

回答by Stefano Borini

an ontology is a dictionary that defines URIs and agree on a meaning for each of them. A trivial ontology is just a bunch of URIs you pick more or less out of the blue. This method unfortunately does not give you any information about semantic relationships of your ontological entities. To explain these relationships you normally describe them with an OWL file, and you normally use tools for this. I use Protege. it's quite ok.

本体是定义 URI 并就每个 URI 的含义达成一致的字典。一个简单的本体只是一堆你或多或少突然选择的 URI。不幸的是,此方法不会为您提供有关本体实体语义关系的任何信息。为了解释这些关系,您通常使用 OWL 文件来描述它们,并且通常为此使用工具。我使用保护。没关系。

回答by Salim Fadhley

If it makes sense to represent something as a directed graph, why not just use a graph class? Python-graph offers simple pure-python graph representations. NetworkX has a slightly harder to use C implementation.

如果将某事物表示为有向图是有意义的,为什么不直接使用图类呢?Python-graph 提供了简单的纯 Python 图形表示。NetworkX 有一个稍微难以使用的 C 实现。

回答by Ilya Rusin

Owlready2is a package for manipulating OWL 2.0 ontologies in Python. It can load, modify, save ontologies, and it supports reasoning via HermiT (included). Owlready allows a transparent access to OWL ontologies.

Owlready2是一个用于在 Python 中操作 OWL 2.0 本体的包。它可以加载、修改、保存本体,并支持通过 HermiT(包括在内)进行推理。Owlready 允许透明访问 OWL 本体。