Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Noun classification #3

Open
ThePenguin1140 opened this issue Apr 22, 2016 · 1 comment
Open

Noun classification #3

ThePenguin1140 opened this issue Apr 22, 2016 · 1 comment

Comments

@ThePenguin1140
Copy link
Contributor

ThePenguin1140 commented Apr 22, 2016

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant