[本体中的DataProperty,使用rake和owlready2中的关键字

问题描述 投票:0回答:1

我正在尝试提取dataProperty的值:如果我对此进行测试---->可行!

keywords="Tunisia"
key="*"+keywords+"*"
country= onto.search(iri=key)
country
print(country[1].recovered, country[1].cases) ------> ['216'] ['949']

但是当我尝试这个时:

        r.extract_keywords_from_text("Tunisia")
        words=r.get_ranked_phrases()
        keywords=str(words)
        key="*"+keywords+"*"
        country= onto.search(iri=key)
        if len(country)>0:

            print(country[1].recovered,country[1].cases)

        else:
            print("no cases")

此错误出现:追溯(最近一次通话):

文件“”,第8行,print(country [1] .recovered,country [1] .cases]

文件“ C:\ Users \ stef info \ Anaconda3 \ lib \ site-packages \ owlready2 \ prop.py”,第243行,位于getattr引发AttributeError(“属性只能具有注释属性值!”)

AttributeError:属性只能具有注释属性值!

我该如何解决!

python rake ontology owlready
1个回答
0
投票

我通过替换固定它

       keywords=str(words)
       key="*"+keywords+"*"

作者

        key="*"+words[0]+"*"
© www.soinside.com 2019 - 2024. All rights reserved.