Figured out a way to help classify nouns using WordNet
from nltk.corpus import wordnet as wn
def isAnimal(animal):
peng = wn.synsets(animal, pos=wn.NOUN)[0]
hypernyms = peng.hypernyms()
while(hypernyms):
for hypernym in hypernyms:
if 'animal' in hypernym.name():
return 'true'
hypernyms = hypernym.hypernyms();
return 'false'
isAnimal('penguin') //true
isAnimal('JFK') //false
isAnimal('dog') //true
isAnimal('tower') //false
The function demonstrates the ability to identify different kind of 'things'.
We can use this to customize pages based on content. For example, animals show origin and/or endangerment status etc. while people can show date of birth/death etc, buildings could show locations, date built, and events could show dates or stuff like that.
Figured out a way to help classify nouns using WordNet
The function demonstrates the ability to identify different kind of 'things'. We can use this to customize pages based on content. For example, animals show origin and/or endangerment status etc. while people can show date of birth/death etc, buildings could show locations, date built, and events could show dates or stuff like that.