首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >通过本体生成错误加载本体

通过本体生成错误加载本体
EN

Stack Overflow用户
提问于 2021-03-10 13:47:20
回答 1查看 1K关注 0票数 2

我想使用本体"dbnary“,并且在尝试从网站加载本体时使用owlready,我得到了以下错误:

也许我使用的是错误的库,是否有一个以海龟格式使用本体的库。我想通过那个图书馆提取单词的同义词。

代码语言:javascript
复制
from owlready2 import *
onto_path.append(r"C:\Users\Em\Docu\tal\Substitution\fr_dbnary_ontolex\fr_dbnary_ontolex.ttl")
onto = get_ontology(r"C:\Users\Em\Docu\tal\Substitution\fr_dbnary_ontolex\fr_dbnary_ontolex.ttl")
onto.load()

#error 
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
~\Anaconda3\lib\site-packages\owlready2\driver.py in parse(self, f, format, delete_existing_triples, default_base)
    153               if not line.endswith("\n"): line = "%s\n" % line
--> 154               s,p,o = splitter.split(line[:-3], 2)
    155 

ValueError: not enough values to unpack (expected 3, got 1)

The above exception was the direct cause of the following exception:

OwlReadyOntologyParsingError              Traceback (most recent call last)
<ipython-input-6-259cabd311da> in <module>
      2 onto_path.append(r"C:\Users\Emmanuelle\Documents\tal\Substitution\fr_dbnary_ontolex\fr_dbnary_ontolex.ttl")
      3 onto = get_ontology(r"C:\Users\Emmanuelle\Documents\tal\Substitution\fr_dbnary_ontolex\fr_dbnary_ontolex.ttl")
----> 4 onto.load()

~\Anaconda3\lib\site-packages\owlready2\namespace.py in load(self, only_local, fileobj, reload, reload_if_newer, url, **args)
    785         if _LOG_LEVEL: print("* Owlready2 *     ...loading ontology %s from %s..." % (self.name, f), file = sys.stderr)
    786         fileobj = open(f, "rb")
--> 787         try:     new_base_iri = self.graph.parse(fileobj, default_base = self.base_iri, **args)
    788         finally: fileobj.close()
    789       else:

~\Anaconda3\lib\site-packages\owlready2\driver.py in parse(self, f, format, delete_existing_triples, default_base)
    186           self._add_obj_triple_raw_spo(self.onto.storid, rdf_type, owl_ontology)
    187         if current_line:
--> 188           raise OwlReadyOntologyParsingError("NTriples parsing error (or unrecognized file format) in %s, line %s." % (getattr(f, "name", getattr(f, "url", "???")), current_line)) from e
    189         else:
    190           raise OwlReadyOntologyParsingError("NTriples parsing error (or unrecognized file format) in %s." % getattr(f, "name", getattr(f, "url", "???"))) from e

OwlReadyOntologyParsingError: NTriples parsing error (or unrecognized file format) in C:\Users\Emmanuelle\Documents\tal\Substitution\fr_dbnary_ontolex\fr_dbnary_ontolex.ttl, line 29
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-03-11 11:13:54

来自猫头鹰的医生

Owlready2可以:

  • 以NTriples、RDF/XML或OWL/XML格式导入OWL2.0本体

使用RDFLib解析海龟。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66566050

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档