/NLP_Chatbot_on_Slack

A text classification model which can classify input sentences into several certain groups and extract numerical values.

Primary LanguagePython

Interactive-nlp-model-on-Slack

The model I built is a text-classification model with a dictionary list which can keep being trained when users enters more and more data.

Before applying the model, sentences entered by user will first be parsed and cleaned into a list of token. The cleaning procedure includes removing punctuation, tokenization, misspelling correction, stopwords filtering, lemmatisation, stemming and removing repetitive words. Then each words in the list of token will be checked if they have already been in our dictionary and gives result directly if so. Otherwise, the model will calculate the similarity value between each token entered by user with labels of different groups in the dictionary. If there is a pair of words whose similarity score is over our threshold 0.8, we use that group as the result. If more than one pair of words whose similarity score is over the threshold, user will be asked to make sure which specific group is he/she commanding. If no pair of words pass the threshold, the model will return 3 pair of words with highest similarity score, and user will be asked to classify the sentence manually. After user finishes, the dictionary will add the new word into its group so that the model can classify the next time user enters the same or similar words. The NLP libraries of cleaning and similarity function we used are spaCy and NLTK. Similarity is determined by comparing word vectors or "word embeddings", multi-dimensional meaning representations of a word.

Users can give commands to robots by entering a sentence in Slack. The sentence will be parsed and analyzed by our NLP model to be classified into one of the certain classes. The classes include: battery, location, speed, picture, panorama, attention, rotate, forward and help. Numerical values of distance, angle, coordinates and certain location names that exist in database will be extracted as well and sent them to ROS(Robot Operating System). Users should give one command in each sentence. Users need to specify which robot to be used by entering robot’s name when giving commands. The names of the robots are something like “robot1" or "bot1”. Please remember typing @teamabot before entering commands.