まず、ポリシームを定義します。
Polysemy: The coexistence of many possible meanings for a word or phrase.
(出典:https://www.google.com/search?q=polysemy)
Wordnetから:
WordNet® is a large lexical database of English. Nouns, verbs, adjectives and adverbs are grouped into sets of cognitive synonyms (synsets), each expressing a distinct concept. Synsets are interlinked by means of conceptual-semantic and lexical relations.
そしてWordNetの中で、我々は精通している必要があり、いくつかの条件があります。
Synset: a distinct concept/meaning
Lemma: a root form of a word
Part-Of-Speech (POS): the linguistic category of a word
Word: a surface form of a word (surface words are not in WordNet)
が(注: @alexisはlemma vs synset
の回答が良いです:https://stackoverflow.com/a/42050466/610569;コードでもhttps://stackoverflow.com/a/23715743/610569とhttps://stackoverflow.com/a/29478711/610569)
を参照してください:
は
from nltk.corpus import wordnet as wn
# Given a word "run"
word = 'run'
# We get multiple meaning (i.e. synsets) for
# the word in wordnet.
for synset in wn.synsets(word):
# Each synset comes with an ID.
offset = str(synset.offset()).zfill(8)
# Each meaning comes with their
# linguistic category (i.e. POS)
pos = synset.pos()
# Usually, offset + POS is the way
# to index a synset.
idx = offset + '-' + pos
# Each meaning also comes with their
# distinct definition.
definition = synset.definition()
# For each meaning, there are multiple
# root words (i.e. lemma)
lemmas = ','.join(synset.lemma_names())
print ('\t'.join([idx, definition, lemmas]))
[出]:
00189565-n a score in baseball made by a runner touching all four bases safely run,tally
00791078-n the act of testing something test,trial,run
07460104-n a race run on foot footrace,foot_race,run
00309011-n a short trip run
01926311-v move fast by using one's feet, with one foot off the ground at any given time run
02075049-v flee; take to one's heels; cut and run scat,run,scarper,turn_tail,lam,run_away,hightail_it,bunk,head_for_the_hills,take_to_the_woods,escape,fly_the_coop,break_away
バックの質問に行く、はどのように「名詞の平均多義性を計算します、動詞、形容詞と副詞WordNetによると "?
WordNetで作業しているので、面白い言葉が使われていないため、補題だけが残っています。
まず、どのような補題が名詞、動詞、形容詞に含まれているかを定義する必要があります。
from nltk.corpus import wordnet as wn
from collections import defaultdict
words_by_pos = defaultdict(set)
for synset in wn.all_synsets():
pos = synset.pos()
for lemma in synset.lemmas():
words_by_pos[pos].add(lemma)
しかし、これはPOS対補題関係の単純化した図である。
# There are 5 POS.
>>> words_by_pos.keys()
dict_keys(['a', 's', 'r', 'n', 'v'])
# Some words have multiple POS tags =(
>>> len(words_by_pos['n'])
119034
>>> len(words_by_pos['v'])
11531
>> len(words_by_pos['n'].intersection(words_by_pos['v']))
4062
我々はそれを無視して上を移動できるかどうか見てみましょう:
# Lets look that the verb 'v' category
num_meanings_per_verb = []
for word in words_by_pos['v']:
# No. of meaning for a word given a POS.
num_meaning = len(wn.synsets(word, pos='v'))
num_meanings_per_verb.append(num_meaning)
print(sum(num_meanings_per_verb)/len(num_meanings_per_verb))
[出]:
2.1866273523545225
番号は何を意味しますか?それは2つの意味の平均がWordNetの中のすべての動詞のうち
- 、
- があることを意味する
(それがすべてでは何を意味している場合)。
- いくつかの単語は、他のPOSカテゴリおそらく
でより多くの意味を持っているという事実を無視して、そこに多分、それにはいくつかの意味であるが、我々はnum_meanings_per_verb
内の値の数を見れば:
Counter({1: 101168,
2: 11136,
3: 3384,
4: 1398,
5: 747,
6: 393,
7: 265,
8: 139,
9: 122,
10: 85,
11: 74,
12: 39,
13: 29,
14: 10,
15: 19,
16: 10,
17: 6,
18: 2,
20: 5,
26: 1,
30: 1,
33: 1})
完全なトレースバックを表示してください。 – BrenBarn
おそらく 'synset.lemma_names'は' sysnet.lemma_names() 'でなければなりませんか? – BrenBarn
私はそれを調整しましたが、同じエラーがまだ残っています – Anna