I need to build a chat-bot for the Arabic language. Is it possible?
yep for the language detection im using langdetect python library and it works fine
First you need to install langdetect to your environment (pip install lagdetect
).
Then inside your actions.py
from langdetect import detect
def getLanguage(text):
print("text " + text)
if ((detect(text)) == "ar"):
lang = "AR"
print("detected lang " + lang)
return lang
getLanguage("مرحبا")
output
text مرحبا
detected lang AR
this is simple method and then inside your actions you can use this reurning lang
class ActionGreet(Action):
def name(self) -> Text:
return "action_greet"
def run(self, dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
lang = getLang(tracker.latest_message['text'])
hope this may help you .
Thanks @rishier827, i have one more doubt. As per your solution we have to re write all utterrance_
to custome actions, right?
That is for utterance_greet
-> action_greet
utterance_goodybye
- > action_goodbye
so on…