2014-06-13 3 views
1

단어에 대한 더 큰 카테고리를 찾고 싶습니다. 예를 들어단어 카테고리 찾기

블루 -> 색상

고양이 -> 동물

행복 -> 감정

이 얻을 수있는 가장 쉬운 방법은 무엇입니까?

나는 워드 넷 데모 확인 : http://wordnetweb.princeton.edu/perl/webwn?c=8&sub=Change&o2=&o0=1&o8=1&o1=1&o7=&o5=&o9=&o6=&o3=&o4=&i=-1&h=0000000000000000&s=blue

을하지만 바로이 작업을 수행하는 데 도움이 수 Wordnet는에있는 필드 모른다. 어떤 아이디어?

답변

1

더 구체적으로 정의 할 수 없다면 필요한 것을 얻는 명확한 방법이 없다고 생각합니다. 예를 들어 :

>>> from nltk.corpus import wordnet as wn 
>>> blue = wn.synsets('blue')[0] 
>>> cat = wn.synsets('cat')[0] 
>>> blue.definition() 
u'blue color or pigment; resembling the color of the clear sky in the daytime' 
>>> cat.definition() 
u'feline mammal usually having thick soft fur and no ability to roar: domestic cats; wildcats' 

때때로, 당신은 행운과 hypernyms의 하나 또는 두 개의 레벨이 올라갈 :

>>> blue.hypernyms() 
[Synset('chromatic_color.n.01')] 
>>> blue.hypernyms()[0].hypernyms() 
[Synset('color.n.01')] 

때때로 당신은 당신이 원하는 무엇을 얻을 수있는 hypernyms을 많은 수준을 가야 해요.

>>> happy = wn.synsets('happy')[0] 
>>> happy.definition() 
u'enjoying or showing or marked by joy or pleasure' 
>>> happy.hypernyms() 
[] 
>>> happy.root_hypernyms() 
[Synset('happy.a.01')] 
: 당신이 이동하는

>>> blue.root_hypernyms() 
[Synset('entity.n.01')] 
>>> cat.root_hypernyms() 
[Synset('entity.n.01')] 

이 때로는 더 상위 개념이 없습니다 :

>>> cat.hypernyms() 
[Synset('feline.n.01')] 
>>> cat.hypernyms()[0].hypernyms() 
[Synset('carnivore.n.01')] 
>>> cat.hypernyms()[0].hypernyms()[0].hypernyms() 
[Synset('placental.n.01')] 
>>> cat.hypernyms()[0].hypernyms()[0].hypernyms()[0].hypernyms() 
[Synset('mammal.n.01')] 
>>> cat.hypernyms()[0].hypernyms()[0].hypernyms()[0].hypernyms()[0].hypernyms() 
[Synset('vertebrate.n.01')] 
>>> cat.hypernyms()[0].hypernyms()[0].hypernyms()[0].hypernyms()[0].hypernyms()[0].hypernyms() 
[Synset('chordate.n.01')] 
>>> cat.hypernyms()[0].hypernyms()[0].hypernyms()[0].hypernyms()[0].hypernyms()[0].hypernyms()[0].hypernyms() 
[Synset('animal.n.01')] 

그리고 최상위 상위어 수준으로 점점

은별로 의미가 있습니다