Chatterbot: Extracting Nouns and other choice data

Created on 26 Oct 2016  路  7Comments  路  Source: gunthercox/ChatterBot

Can I extract useful data from the user inputs?

Like,

User: My name is saad.
Bot: Hello Saad

Can I extract nouns like above and other useful data choices from the user? On which I can direct the user to some other route in my app.

Most helpful comment

  1. To extract names, you have to use a Named Entity Extractor (nltk, Spacy, Mitie etc)
  2. To extract nouns, Chatterbot uses nltk pos tagger (or you can use your own)
from chatterbot.utils.pos_tagger import POSTagger

pos_tagger = POSTagger()
print (pos_tagger.tokenize('My name is saad'))

All this has to be done in a logic adapter

All 7 comments

  1. To extract names, you have to use a Named Entity Extractor (nltk, Spacy, Mitie etc)
  2. To extract nouns, Chatterbot uses nltk pos tagger (or you can use your own)
from chatterbot.utils.pos_tagger import POSTagger

pos_tagger = POSTagger()
print (pos_tagger.tokenize('My name is saad'))

All this has to be done in a logic adapter

@rmdort can you please elaborate a bit more on this?

I would suggest you to learn more about Parts of Speech tagger and NER tools. Google is your friend :)

Something could be useful https://github.com/DarkmatterVale/regex4dummies

import os
from subprocess import *
import re
import sys
import tarfile
import nltk
from regex4dummies import regex4dummies
from regex4dummies import Toolkit

# Testing the 'nltk' parser
print(regex.compare_strings(parser='nltk', pattern_detection="semantic", text=["Back at my desk, I poured and killed him a rattlesnake and some more rattlesnake", "the cat and the mouse in the house is sitting, in the house, on the mat", "time is it?", "what time is it here?", "This is the cat's hat"]))
sentence_information = regex.get_pattern_information()
for sentence in sentence_information:
    print "[ Pattern ]          : " + sentence.pattern
    print "[ Subject ]          : " + sentence.subject
    print "[ Verb ]             : " + sentence.verb
    print "[ Object ]           : " + sentence.object[0]
    print "[ Reliability Score ]: " + str(sentence.reliability_score)

@saadj55 I just came across an article that you might find interesting or useful: http://www.nltk.org/book/ch07.html

@gunthercox Thanks!

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings