如何获取同义词集的所有属性?
请给我一个示例,其中包含单词的 synset
的所有属性 我只知道这个属性: name
、 lemma_names
、 definition
synsetsWord = ObjWn.synsets( 'Book' )
i = 0
for senseWord in synsetsWord:
synsetsWord[i] = senseWord.name
print 'Sense Lema Name: ' , senseWord.lemma_names
print 'Sense Definition : ' , senseWord.definition
i = i + 1
谢谢
Please Give Me am example That have all of attribute of synset
of a word
i know only this attribute: name
, lemma_names
, definition
synsetsWord = ObjWn.synsets( 'Book' )
i = 0
for senseWord in synsetsWord:
synsetsWord[i] = senseWord.name
print 'Sense Lema Name: ' , senseWord.lemma_names
print 'Sense Definition : ' , senseWord.definition
i = i + 1
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用
dir()
内置函数口译员。这是一个示例:
您可以向
dir()
提供任何对象 获取其属性的列表
。Use the
dir()
built-in function in the interpreter.Here is an example:
You can supply any object to
dir()
to get alist
of its attributes.您可以查看 WordNet 术语表 - 它们列出了相当多的属性。它可以在这里找到:WordNet Glossary
如果我正确理解你的问题,像这样的东西也可能有效。 'nyms' 这里列出了 synset 可以具有的所有属性,try-catch 将处理 synset 不具有任何此类属性的任何情况。
有些属性仅适用于引理,不适用于同义词集,因此您可以使用相同的代码,但将同义词集替换为引理,以获得反义词、derivationally_related_forms 和 pertainyms 等属性。
You can check out the WordNet glossary for terms - they list quite a few of the attributes there. It can be found here: WordNet Glossary
If I understand your question correctly, something like this may also work. 'nyms' here lists all the attributes a synset can have and the try-catch will handle any cases where the synset doesn't have any attributes of that kind.
Some attributes are only applicable to lemmas, not synsets, so you can use the same code but replace synsets with lemmas to get attributes like antonyms, derivationally_related_forms, and pertainyms.