Skip to content

Instantly share code, notes, and snippets.

@vijay120
Last active December 2, 2019 07:33
Show Gist options
  • Save vijay120/0b7d7d1ce12b42e2ade1c76f2247e5c1 to your computer and use it in GitHub Desktop.
Save vijay120/0b7d7d1ce12b42e2ade1c76f2247e5c1 to your computer and use it in GitHub Desktop.
MindMeld EMEAR demo
# Mindmeld getting started
docker pull mindmeldworkbench/dep:latest
docker run -p 0.0.0.0:9200:9200 -p 0.0.0.0:7151:7151 -p 0.0.0.0:9300:9300 mindmeldworkbench/dep -ti -d
bash -c "$(curl -s https://devcenter.mindmeld.com/scripts/mindmeld_lite_init.sh)"
# download dependencies
mkdir emear
cd emear
virtualenv -p python3 .
source bin/activate
pip install mindmeld
pip install jupyter
# download hr assistant
python -c "import mindmeld as mm; mm.blueprint('hr_assistant');"
# open jupyter notebook
jupyter notebook
# build and dump
from mindmeld.components import QuestionAnswerer
from mindmeld.components import NaturalLanguageProcessor
bp_name = '/Users/vijay/emear/hr_assistant'
nlp = NaturalLanguageProcessor(bp_name)
nlp.build()
nlp.dump()
# some conversations
from mindmeld.components.dialogue import Conversation
conv = Conversation(nlp=nlp, app_path=bp_name)
# single turn dialogs
conv.say('Hello')
conv.say("What is Elisa's marital status")
# multi-turn dialogs
conv.say('Can you tell me about daniel')
conv.say('how much does daniel make')
# aggregate queries
conv.say('How many males are in the company')
conv.say('what is the average salary')
# introspecting NLP component
query = 'How much does daniel make'
nlp.process(query)
nlp.inspect(query, domain='salary')
# unstructed QA system
qa = QuestionAnswerer(app_path='hr_assistant')
query = 'is there an online course on how to set goals?'
qa.get(index='hr_faq_data', query_type='text', question=query)[0]
qa.get(index='hr_faq_data', query_type='text', question=query, answer=query)[0]
# introspecting the elasticsearch indices
curl -X GET "localhost:9200/_cat/indices?v&pretty"
qa.get(index='hr_faq_data')
# Dialogue management inspection
vi /Users/vijay/emear/hr_assistant/salary.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment