targeting one word in the response of an input command python
Question: I have been trying to make an artificial intelligence on python. What I have
been trying to do is make input command responses target one word. So for
example, if the user types in "whats your name" it will have the same response
as "name" by targeting the word "name". how can I do this?


Answer: What you're looking for is a library for handling [Parts of
Speech](https://en.wikipedia.org/wiki/Part_of_speech). Luckily it's pretty
well trodden ground, and there are libraries for lots of different languages -
including Python. Have a look at [Stanford's Natural Language
Toolkit](http://textminingonline.com/dive-into-nltk-part-v-using-stanford-
text-analysis-tools-in-python) (NLTK). Here's an example from the linked
article:

    
    
    >>> from nltk.tag.stanford import POSTagger
    >>> english_postagger = POSTagger(‘models/english-bidirectional-distsim.tagger’, ‘stanford-postagger.jar’)
    >>> english_postagger.tag(‘this is stanford postagger in nltk for python users’.split())
    [(u’this’, u’DT’),
    (u’is’, u’VBZ’),
    (u’stanford’, u’JJ’),
    (u’postagger’, u’NN’),
    (u’in’, u’IN’),
    (u’nltk’, u’NN’),
    (u’for’, u’IN’),
    (u’python’, u’NN’),
    (u’users’, u’NNS’)]
    

The `NN`, `VBZ`, etc. you can see are [speech
tags](https://cs.nyu.edu/grishman/jet/guide/PennPOS.html). It looks like
you're looking for nouns (`NN`).

