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

Intent classification with rasa-nlu #54

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions chatbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
from googletrans import Translator
from voice_conf import *
# from speech_recognition.__main__ import r, audio
from rasa.cli.utils import print_success
from rasa.nlu.model import Interpreter
from rasa.nlu.utils import json_to_string
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
from intentClassification.intent_classification import IntentClassification

greetings = ['hey there', 'hello', 'hi', 'Hai', 'hey!', 'hey', 'hi there!']
Expand Down Expand Up @@ -61,6 +66,9 @@

intentClassifier = IntentClassification()

rasa_model_path = "intentClassification/rasa/nlu-20200427-002014/nlu"
interpreter = Interpreter.load(rasa_model_path)

personalized, longitude, latitude = get_location()
stores = []
stores_data = {}
Expand Down Expand Up @@ -106,6 +114,7 @@
engine.runAndWait()
intent = intentClassifier.intent_identifier(translate)
print("Intent:", intent)
intent_rasa = interpreter.parse(translate)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any use of this variable. Can we try replace intent with intent_rasa and check how better it is detecting. I would also like to see accuracy % in pr description.

# TODO:: entity based weather output
if intent == "weather":
print("here")
Expand Down
Empty file.
27 changes: 27 additions & 0 deletions intentClassification/rasa/actions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# This files contains your custom actions which can be used to run
# custom Python code.
#
# See this guide on how to implement these action:
# https://rasa.com/docs/rasa/core/actions/#custom-actions/


# This is a simple example for a custom action which utters "Hello World!"

# from typing import Any, Text, Dict, List
#
# from rasa_sdk import Action, Tracker
# from rasa_sdk.executor import CollectingDispatcher
#
#
# class ActionHelloWorld(Action):
#
# def name(self) -> Text:
# return "action_hello_world"
#
# def run(self, dispatcher: CollectingDispatcher,
# tracker: Tracker,
# domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
#
# dispatcher.utter_message(text="Hello World!")
#
# return []
26 changes: 26 additions & 0 deletions intentClassification/rasa/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Configuration for Rasa NLU.
# https://rasa.com/docs/rasa/nlu/components/
language: en
pipeline:
- name: WhitespaceTokenizer
- name: RegexFeaturizer
- name: LexicalSyntacticFeaturizer
- name: CountVectorsFeaturizer
- name: CountVectorsFeaturizer
analyzer: "char_wb"
min_ngram: 1
max_ngram: 4
- name: DIETClassifier
epochs: 100
- name: EntitySynonymMapper
- name: ResponseSelector
epochs: 100

# Configuration for Rasa Core.
# https://rasa.com/docs/rasa/core/policies/
policies:
- name: MemoizationPolicy
- name: TEDPolicy
max_history: 5
epochs: 100
- name: MappingPolicy
32 changes: 32 additions & 0 deletions intentClassification/rasa/credentials.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# This file contains the credentials for the voice & chat platforms
# which your bot is using.
# https://rasa.com/docs/rasa/user-guide/messaging-and-voice-channels/

rest:
# # you don't need to provide anything here - this channel doesn't
# # require any credentials


#facebook:
# verify: "<verify>"
# secret: "<your secret>"
# page-access-token: "<your page access token>"

#slack:
# slack_token: "<your slack token>"
# slack_channel: "<the slack channel>"

#socketio:
# user_message_evt: <event name for user message>
# bot_message_evt: <event name for but messages>
# session_persistence: <true/false>

#mattermost:
# url: "https://<mattermost instance>/api/v4"
# token: "<bot token>"
# webhook_url: "<callback URL>"

# This entry is needed if you are using Rasa X. The entry represents credentials
# for the Rasa X "channel", i.e. Talk to your bot and Share with guest testers.
rasa:
url: "http://localhost:5002/api"
Loading