gunthercox / ChatterBot

ChatterBot is a machine learning, conversational dialog engine for creating chat bots
https://chatterbot.readthedocs.io
BSD 3-Clause "New" or "Revised" License
14.11k stars 4.45k forks source link

Extracting Nouns and other choice data #360

Closed saadj55 closed 8 years ago

saadj55 commented 8 years ago

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.

rmdort commented 8 years ago
  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

saadj55 commented 8 years ago

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

rmdort commented 8 years ago

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

vkosuri commented 8 years ago

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)
gunthercox commented 8 years ago

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

saadj55 commented 8 years ago

@gunthercox Thanks!

lock[bot] commented 5 years ago

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.