diff --git a/.gitignore b/.gitignore index 6e821ff88..a066ab589 100644 --- a/.gitignore +++ b/.gitignore @@ -93,3 +93,8 @@ pip-selfcheck.json # moni_files conversations/moni* + +audios/ +audios.json +conversations/kb.db +rec_voice_audios/ \ No newline at end of file diff --git a/FormatoCV.docx b/FormatoCV.docx new file mode 100644 index 000000000..ecb3cd68b Binary files /dev/null and b/FormatoCV.docx differ diff --git a/Pipfile b/Pipfile index f2855d65d..5aaf4e0e0 100644 --- a/Pipfile +++ b/Pipfile @@ -30,6 +30,9 @@ yarl = "*" duckduckpy = "*" socketIO-client = "*" python-socketio = "*" +request = "*" +spacy = "*" +python-docx = "*" [dev-packages] diff --git a/Pipfile.lock b/Pipfile.lock index 032d32de4..9aadfac00 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "f204ef5a2d4f331f5a1f2dc5d0ce57ba7413103b37b53c6408e28bdddf32482d" + "sha256": "7d78028026693104a63393cd50063bcbff548fa7471f8ccd76123774ee53dad8" }, "pipfile-spec": 6, "requires": { @@ -105,6 +105,12 @@ "index": "pypi", "version": "==0.2" }, + "get": { + "hashes": [ + "sha256:688268840f923255932154a52bdd40ffac467de4126835c43846e9e6f112844c" + ], + "version": "==2019.4.13" + }, "gtts": { "hashes": [ "sha256:8607176dbd912f23bdb63fa346bfe70aab0c844a7fd98e2d31e0e549c443c2b3" @@ -197,6 +203,19 @@ "index": "pypi", "version": "==1.14.3" }, + "post": { + "hashes": [ + "sha256:8fd57fb16f2c90ef4a76b04b8701c4db8ded170e53fac9514b5ea0272da5d36f" + ], + "version": "==2019.4.13" + }, + "public": { + "hashes": [ + "sha256:2cfbab7dba86195864a1eda4ef1584df02455a47526d595fd6004b569c6c87f5", + "sha256:e1436a8a99693a9849dfe40b9158f3837b7c309c163b2d3f5b8e9fce23876db1" + ], + "version": "==2019.4.13" + }, "pyaudio": { "hashes": [ "sha256:0d92f6a294565260a282f7c9a0b0d309fc8cc988b5ee5b50645634ab9e2da7f7", @@ -214,18 +233,18 @@ }, "python-engineio": { "hashes": [ - "sha256:5bd0a3671365f933b1413aa2ea58bf3ac5acf849c949dfd5192322c7a974a42e", - "sha256:b2756ce53076163eb24f59c1d1a903ac72f071ad4fb7b3ef6dab1b1b9ae9a44f" + "sha256:4850c3e04b2040e4fd262d1047797473d1815b37a073807e7b80304c1c5f4848", + "sha256:89b90ee3816ed440c68ac7b6143244ae7d56a46a49295fbac8e6696482e596d1" ], - "version": "==3.5.0" + "version": "==3.8.2.post1" }, "python-socketio": { "hashes": [ - "sha256:626381a6940f0e4ec6a8bbd2dc95e231a515b2838ee0cc98c535076a4650a872", - "sha256:64feb0817f1bf7e3e7fc05f6f65e28d76146d8061cb7de25b63502717f80e908" + "sha256:335bd0fab481d65edce4ab82c3bb5cac950afa843329ea7c38777cd56c8eba38", + "sha256:efec4844456791b7d702efefd543ed67a8e314ca45efb8f0bfca7ae18fdee60a" ], "index": "pypi", - "version": "==4.0.0" + "version": "==4.2.0" }, "pyttsx3": { "hashes": [ @@ -249,6 +268,19 @@ "index": "pypi", "version": "==3.12" }, + "query-string": { + "hashes": [ + "sha256:bb24e4f58849ef6f8219b2446c2bed076d86c97720ae9c3ae918625807394ca8" + ], + "version": "==2019.4.13" + }, + "request": { + "hashes": [ + "sha256:6297b53c29a4928f7735034df2ab60aa1c7c044df989f605a81b7dc2d3713732" + ], + "index": "pypi", + "version": "==2019.4.13" + }, "requests": { "hashes": [ "sha256:6a1b267aa90cac58ac3a765d067950e7dbbf75b1da07e895d1f594193a40a38b", @@ -289,12 +321,12 @@ }, "typing-extensions": { "hashes": [ - "sha256:07b2c978670896022a43c4b915df8958bec4a6b84add7f2c87b2b728bda3ba64", - "sha256:f3f0e67e1d42de47b5c67c32c9b26641642e9170fe7e292991793705cd5fef7c", - "sha256:fb2cd053238d33a8ec939190f30cfd736c00653a85a2919415cecf7dc3d9da71" + "sha256:2ed632b30bb54fc3941c382decfd0ee4148f5c591651c9272473fea2c6397d95", + "sha256:b1edbbf0652660e32ae780ac9433f4231e7339c7f9a8057d0f042fcbcea49b87", + "sha256:d8179012ec2c620d3791ca6fe2bf7979d979acdbef1fca0bc56b37411db682ed" ], "markers": "python_version < '3.7'", - "version": "==3.7.2" + "version": "==3.7.4" }, "urllib3": { "hashes": [ diff --git a/Readme.md b/Readme.md index a930a9b7f..887e98614 100644 --- a/Readme.md +++ b/Readme.md @@ -1,4 +1,5 @@ -# chatvoice +# chatvoice +#Modificado por Jesús Ernesto Martínez Olmos A language for chatbots, uses ASR and TTS technology. diff --git a/conversation.py b/conversation.py index c0a3a2cdc..5bc8eeea8 100644 --- a/conversation.py +++ b/conversation.py @@ -21,6 +21,8 @@ # Import plugins # TODO make a better system for plugins from plugins import random_greeting +from plugins import spacy +from plugins import doc_generator # TODO make a better system for filters from filters import * @@ -205,6 +207,7 @@ def solve_(self,*args): try: if args[0] in self.contexts: self.current_context=self.contexts[args[0]] + #print("d**************",self.contexts) slots_tmp=OrderedDict(self.current_context.slots) slots_tmp_ = self.slots self.slots=self.current_context.slots @@ -300,7 +303,7 @@ def conditional_(self,line): result=eval(conditional,globals(),self.slots) except NameError: print(bcolors.WARNING, "False because variable not defined",bcolors.ENDC) - result=True + result=False if result: self.execute_line_(cmd) diff --git a/conversations/alergia_yes.yaml b/conversations/alergia_yes.yaml new file mode 100644 index 000000000..9086b6ad1 --- /dev/null +++ b/conversations/alergia_yes.yaml @@ -0,0 +1,23 @@ +strategies: + num_children: + - say "¿cuantos hijos tienes?" + - input num_children + age_children: + - say "¿qué edades tienen?" + - input age_children + subject_children: + - say "¿ya sabes que quieren estudiar?" + - input status + where_study_children: + - say "¿y dónde quieren estudiar?" + - input where_study_children + insurance_education: + - say "¿tienes algún seguro que cubra su educación?" + - input insurance_education +script: + - while number_creditcard_counter < number_creditcard solve card_info + - say num_children + - solve age_children + - solve subject_children + - solve where_study_children + - solve insurance_education diff --git a/conversations/chataracely/chatbot.yaml b/conversations/chataracely/chatbot.yaml new file mode 100644 index 000000000..c0909dfe4 --- /dev/null +++ b/conversations/chataracely/chatbot.yaml @@ -0,0 +1,35 @@ +settings: + name: ChatBot + +conversations: + - 'pract_yes_pro.yaml' + - 'idioma.yaml' + - 'trabajo.yaml' + - 'hello.yaml' + +slots: + - name + - age + - Grado_Aca + - Pract_Profesionales + +strategies: + name: + - say "Hola ¿Cómo te llamas?" + - input name + - say "mucho gusto en conocerte" + age: + - say "¿y qué edad tienes?" + - input age + Grado_Aca: + - say "¿Cual es tu grado academico?" + - input Grado_Aca + Pract_Profesionales: + - say " ¿Haz trabajado, realizado practicas profesionales, etc?" + - input Pract_Profesionales | yesno +script: + - loop_slots + - if Pract_Profesionales solve pract_yes_pro + - solve idioma + - solve trabajo + - say "adios {}".format(name) diff --git a/conversations/chataracely/denuncia.yaml b/conversations/chataracely/denuncia.yaml new file mode 100644 index 000000000..428f76b95 --- /dev/null +++ b/conversations/chataracely/denuncia.yaml @@ -0,0 +1,77 @@ +# Conversation example for simple hello and ask a name + +settings: + name: DenunciaBot + +conversations: + - 'denuncia_yes_reconocerAsaltante.yaml' + - 'denuncia_yes_antecedentes.yaml' + +slots: + - name + - denuncia + - descripcionDenuncia + - fecha + - hora + - lugar + - reconocerAsaltante + - arma + - antecedentes + - objetoRobado + - valorObjetoRobado + - tipoDenuncia + +strategies: + name: + - say "Hola, soy Denunciabot, el chatbot que recibe denuncias.. ¿Cual es tu nombre?" + - input name + denuncia: + - say "En que puedo ayudarte?" + - input denuncia + descripcionDenuncia: + - say "Sobre que es tu denuncia" + - input descripcionDenuncia + fecha: + - say "En que fecha fue asaltado?" + - input fecha + hora: + - say "A que hora ocurrieron los hechos?" + - input hora + lugar: + - say "Donde ocurrio el asalto?" + - input lugar + reconocerAsaltante: + - say "Reconocio al asaltante" + - input reconocerAsaltante | yesno + arma: + - say "Con que fue asaltado?" + - input arma + antecedentes: + - say "Ya habia sido asaltado con anterioridad por esa zona?" + - input antecedentes | yesno + objetoRobado: + - say "Que le fue despojado?" + - input objetoRobado + valorObjetoRobado: + - say "Que valor tenia?" + - input valorObjetoRobado + tipoDenuncia: + - say "¿Muy bien, desea hacer la denuncia anonima o nos permite saber sus datos?" + - input tipoDenuncia + +script: + - loop_slots + - if denuncia_yes_reconocerAsaltante + - if denuncia_yes_antecedentes + - solve name + - solve denuncia + - solve descripcionDenuncia + - solve fecha + - solve hora + - solve lugar + - solve reconocerAsaltante + - solve arma + - solve antecedentes + - solve objetoRobado + - solve valorObjetoRobado + - solve tipoDenuncia diff --git a/conversations/chataracely/denuncia_yes_antecedentes.yaml b/conversations/chataracely/denuncia_yes_antecedentes.yaml new file mode 100644 index 000000000..e9c25ffca --- /dev/null +++ b/conversations/chataracely/denuncia_yes_antecedentes.yaml @@ -0,0 +1,9 @@ +# Moni conversation for children information +strategies: + antecedentes: + - say "Cuando?" + - input antecedentes + +script: + - solve antecedentes + diff --git a/conversations/chataracely/denuncia_yes_reconocerAsaltante.yaml b/conversations/chataracely/denuncia_yes_reconocerAsaltante.yaml new file mode 100644 index 000000000..63d5bd239 --- /dev/null +++ b/conversations/chataracely/denuncia_yes_reconocerAsaltante.yaml @@ -0,0 +1,9 @@ +# Moni conversation for children information +strategies: + reconocer: + - say "Como era?" + - input reconocer + +script: + - solve reconocer + diff --git a/conversations/chataracely/hello.yaml b/conversations/chataracely/hello.yaml new file mode 100644 index 000000000..fad4df8f2 --- /dev/null +++ b/conversations/chataracely/hello.yaml @@ -0,0 +1,8 @@ +# Conversation example for simple hello + +plugins: + - random_greeting + +script: + - set_slot options ["whatsup"] + - random_greeting.execute('greeting',options) diff --git a/conversations/chataracely/idioma.yaml b/conversations/chataracely/idioma.yaml new file mode 100644 index 000000000..4c0880cc1 --- /dev/null +++ b/conversations/chataracely/idioma.yaml @@ -0,0 +1,22 @@ +strategies: + num_idioma: + - say "¿Cuantos idiomas sabes hablar?" + - input num_idioma + primero: + - say "Menciona el primer idioma" + - input primero + nivel: + - say "¿Nivel de idioma?" + - input nivel + segundo: + - say "Menciona el segundo idoma" + - input segundo + snivel: + - say "¿Nivel de idioma?" + - input snivel +script: + - solve num_idioma + - solve primero + - solve nivel + - solve segundo + - solve snivel diff --git a/conversations/chataracely/pract_yes_pro.yaml b/conversations/chataracely/pract_yes_pro.yaml new file mode 100644 index 000000000..ec9c9f2c9 --- /dev/null +++ b/conversations/chataracely/pract_yes_pro.yaml @@ -0,0 +1,27 @@ + +strategies: + num_lugar: + - say "¿En cuantos lugares?" + - input num_lugar | number + lugar: + - solve lugar_puesto + - solve periodo + - solve guardar_info + lugar_puesto: + - say "Menciona el lugar y en que puesto trabajaste" + - input lugar_puesto + periodo: + - say "¿Que periodo de tiempo estuviste?" + - input periodo + guardar_info: + - execute self.slots['lugares'].append((self.slots['lugar_puesto'],self.slots['periodo'])) + - empty_slot lugar_puesto + - empty_slot periodo + - execute self.slots['numero_contador']+=1 +script: + - solve num_lugar + - add_slot lugares + - set_slot lugares [] + - add_slot numero_contador + - set_slot numero_contador 0 + - while numero_contador < num_lugar solve lugar diff --git a/conversations/chataracely/trabajo.yaml b/conversations/chataracely/trabajo.yaml new file mode 100644 index 000000000..f70f60935 --- /dev/null +++ b/conversations/chataracely/trabajo.yaml @@ -0,0 +1,20 @@ +strategies: + puesto: + - say "¿Que puesto de trabajo buscas preferentemente?" + - input puesto + primeros: + - say "Otro puesto de trabajo?" + - input primeros + horario: + - say " En que horario, Mañana, Tarde, Noche o Mixto" + - input horario + correo: + - say "Perfecto, ahora generaremos tu CV. y buscaremos en ferias de empleo, deja tu correo para hacerte llegar todo" + - input correo + +script: + - solve puesto + - solve primeros + - solve horario + - solve correo + diff --git a/conversations/data.csv b/conversations/data.csv new file mode 100644 index 000000000..6c436adae --- /dev/null +++ b/conversations/data.csv @@ -0,0 +1,3 @@ +fact, date +benito juarez nacio en, un 21 marzo +el día de la bandere es el, 24 de febrero diff --git a/conversations/data_enf.csv b/conversations/data_enf.csv new file mode 100644 index 000000000..02f0ef2f6 --- /dev/null +++ b/conversations/data_enf.csv @@ -0,0 +1,7 @@ +fact +dolor de cabeza +dolor de estómago +congetión nasal +tos +resfriado +gripe diff --git a/conversations/enfermera.yaml b/conversations/enfermera.yaml new file mode 100644 index 000000000..fafda1284 --- /dev/null +++ b/conversations/enfermera.yaml @@ -0,0 +1,56 @@ +# Conversation example for simple hello and ask a name + +settings: + name: Florence + +conversations: + - 'hello.yaml' + +slots: + - nombre + - edad + - alergia +dbs: + main: import_csv data_enf.csv + +kb: kb.db + +strategies: + nombre: + - say "¿cúal es tu nombre?" + - input nombre + - say "mucho gusto en conocerte" + edad: + - say "¿qué edad tienes?" + - input edad + alergia: + - say "¿tienes alguna alergia?" + - input alergia | yesno + alergia_yes: + - say "Dime porfavor todas tus alergias" + - add_slot alergias + - set_slot alergias [] + - input alergias + headache: + - say "Siento que te duela la cabeza {} pero no te preocupes tengo algunas opciones que te pueden ayudar.".format(nombre) + - say "La manzanilla es ideal para aliviar el dolor de cabeza. Tómala en una infusión, dos tazas diarias." + - say "La lavanda, además de ser una planta aromática, alivia los dolores de cabeza causados por la fiebre y el insomnio. Aplica un poco de aceite de lavanda en las sienes, mezclado con otro poco de aceite de oliva. Esto generará un efecto calmante y analgésico." + stomachache: + - say "Siento que te duela el estómago {}".format(nombre) + malestar: + - input status | asign cabeza:head estómago:stomach + - if status == "head" solve headache + - if status == "stomach" solve stomachache + - say "¿Tienes algún otro malestar?" + - input males | asign si:yes no:no +script: + - solve hello + - say "Me llamo Florence" + - loop_slots + - if alergia solve alergia_yes + - say "{}, te puedo ayudar con los siguientes malestares".format(nombre) + - say "{}".format(db['main']) + - say "¿Tienes algún malestar?" + - input males | asign si:yes no:no + - while males == "yes" solve malestar + - say "Espero te alivies pronto {}, cuidate.".format(nombre) \ No newline at end of file diff --git a/conversations/hello.yaml b/conversations/hello.yaml index fad4df8f2..4eb85865d 100644 --- a/conversations/hello.yaml +++ b/conversations/hello.yaml @@ -5,4 +5,4 @@ plugins: script: - set_slot options ["whatsup"] - - random_greeting.execute('greeting',options) + - .execute('greeting',options) diff --git a/conversations/hello_name.yaml b/conversations/hello_name.yaml index 8a3337549..9f1826b0a 100644 --- a/conversations/hello_name.yaml +++ b/conversations/hello_name.yaml @@ -1,7 +1,7 @@ # Conversation example for simple hello and ask a name settings: - name: HAL + name: Viernes conversations: - 'hello.yaml' diff --git a/conversations/idioma.yaml b/conversations/idioma.yaml new file mode 100644 index 000000000..4c0880cc1 --- /dev/null +++ b/conversations/idioma.yaml @@ -0,0 +1,22 @@ +strategies: + num_idioma: + - say "¿Cuantos idiomas sabes hablar?" + - input num_idioma + primero: + - say "Menciona el primer idioma" + - input primero + nivel: + - say "¿Nivel de idioma?" + - input nivel + segundo: + - say "Menciona el segundo idoma" + - input segundo + snivel: + - say "¿Nivel de idioma?" + - input snivel +script: + - solve num_idioma + - solve primero + - solve nivel + - solve segundo + - solve snivel diff --git a/conversations/trabajo_cv_conversations/Habilidades_Tecnicas.yaml b/conversations/trabajo_cv_conversations/Habilidades_Tecnicas.yaml new file mode 100644 index 000000000..733ca116c --- /dev/null +++ b/conversations/trabajo_cv_conversations/Habilidades_Tecnicas.yaml @@ -0,0 +1,26 @@ +strategies: + idiomas: + - say "¿Cuántos idiomas hablas?" + - input idiomas | number + conocimiento: + - say "Otra pregunta... ¿Cuentas con el conocimiento de informática básico (herramientas Office)?" + - input conocimiento | yesno + nombreIdiomas: + - say "Muy Bien!! saber idiomas ayuda a entender a otras personas y ver el mundo con otros ojos" + - say "¿Cuales son?" + - empty_slot nombreIdiomas + - input nombreIdiomas + herramientas: + - say "¿Cuales son?" + - empty_slot herramientas + - input herramientas + - say "Excelente!" +script: + - solve idiomas + - add_slot nombreIdiomas + - set_slot nombreIdiomas "Natal" + - if idiomas>=2 solve nombreIdiomas + - add_slot herramientas + - set_slot herramientas "Ninguna" + - solve conocimiento + - if conocimiento solve herramientas \ No newline at end of file diff --git a/conversations/trabajo_cv_conversations/Otras_habilidades_conocimiento.yaml b/conversations/trabajo_cv_conversations/Otras_habilidades_conocimiento.yaml new file mode 100644 index 000000000..e69de29bb diff --git a/conversations/trabajo_cv_conversations/Otras_habilidades_idiomas.yaml b/conversations/trabajo_cv_conversations/Otras_habilidades_idiomas.yaml new file mode 100644 index 000000000..e69de29bb diff --git a/conversations/trabajo_cv_conversations/Sobre instalar spacy.txt b/conversations/trabajo_cv_conversations/Sobre instalar spacy.txt new file mode 100644 index 000000000..20b112705 --- /dev/null +++ b/conversations/trabajo_cv_conversations/Sobre instalar spacy.txt @@ -0,0 +1,18 @@ +Sobre instalar spacy: + +pipenv install spacy + +pip install spacy + +vim spacy_test.py + +python spacy_test.py + +python -m spacy download en_core_web_sm + +python spacy_test.py + +python -m spacy download es_core_news_sm + +https://python-docx.readthedocs.io/en/latest/?fbclid=IwAR2LGSCEe3cpE3RjWs9Vgu0aZyAzVB0_K21aADhaWBWo_riktnsC080sNrg + diff --git a/conversations/trabajo_cv_conversations/actitudes_aptitudes.yaml b/conversations/trabajo_cv_conversations/actitudes_aptitudes.yaml new file mode 100644 index 000000000..8635a7d6a --- /dev/null +++ b/conversations/trabajo_cv_conversations/actitudes_aptitudes.yaml @@ -0,0 +1,42 @@ +strategies: + capacidad: + - say "¿Tienes capacidad para resolver problemas?" + - input capacidad + creativo: + - say "¿Eres creativo?" + - input creativo + trabajar: + - say "¿Te gusta trabajar en equipo?" + - input trabajar + potencial: + - say "¿Tienes potencial de crecimiento?" + - input potencial + aprender: + - say "¿Tienes deseos de aprender?" + - input aprender + relaciones: + - say "¿Cuales son tus relaciones interpersonales?" + - input relaciones + adaptacion: + - say "¿Tienes buena capacidad de adaptación en entornos complicados?" + - input adaptacion + proactivo: + - say "¿Crees ser alguien proactivo?" + - input proactivo + innovador: + - say "¿Consideras ser alguien innovador?" + - input innovador + analizar: + - say "¿Eres bueno analizando las situaciones en general?" + - input analizar +script: + - solve capacidad + - solve creativo + - solve trabajar + - solve potencial + - solve aprender + - solve relaciones + - solve adaptacion + - solve proactivo + - solve innovador + - solve analizar diff --git a/conversations/trabajo_cv_conversations/analisis_psi.yaml b/conversations/trabajo_cv_conversations/analisis_psi.yaml new file mode 100644 index 000000000..159c639ca --- /dev/null +++ b/conversations/trabajo_cv_conversations/analisis_psi.yaml @@ -0,0 +1,31 @@ +strategies: + analisis_de: + - say "cuentame de ti, ¿Podrias decirme cuál es tu mayor debilidad y tu mayor habilidad?" + - input analisis_dibilidades + analisis_sueno: + - say "¿Es éste tu trabajo soñado?" + - input analisis_sue + analisis_encargad: + - say "Si fueses tu la persona encargada de contratar a alguien para el puesto de trabajo, ¿qué cualidades le exigirías?" + - input analisis_encargado + analisis_motiva: + - say "¿Qué te impulsa a levantarte por las mañanas?" + - input analisis_motivacion + analisis_presion: + - say "¿Cómo manejas la presión?" + - input analisis_presio + analisis_pasa: + - say "¿Cuáles son tus pasatiempos?" + - input analisis_pasat + analisis_libro: + - say "¿Cuál fue el último libro que leíste por diversión?" + - input analisis_libr +script: + - solve analisis_de + - solve analisis_sueno + - solve analisis_encargad + - solve analisis_motiva + - solve analisis_presion + - solve analisis_pasa + - solve analisis_libro + diff --git a/conversations/trabajo_cv_conversations/analsis_psi.yaml b/conversations/trabajo_cv_conversations/analsis_psi.yaml new file mode 100644 index 000000000..159c639ca --- /dev/null +++ b/conversations/trabajo_cv_conversations/analsis_psi.yaml @@ -0,0 +1,31 @@ +strategies: + analisis_de: + - say "cuentame de ti, ¿Podrias decirme cuál es tu mayor debilidad y tu mayor habilidad?" + - input analisis_dibilidades + analisis_sueno: + - say "¿Es éste tu trabajo soñado?" + - input analisis_sue + analisis_encargad: + - say "Si fueses tu la persona encargada de contratar a alguien para el puesto de trabajo, ¿qué cualidades le exigirías?" + - input analisis_encargado + analisis_motiva: + - say "¿Qué te impulsa a levantarte por las mañanas?" + - input analisis_motivacion + analisis_presion: + - say "¿Cómo manejas la presión?" + - input analisis_presio + analisis_pasa: + - say "¿Cuáles son tus pasatiempos?" + - input analisis_pasat + analisis_libro: + - say "¿Cuál fue el último libro que leíste por diversión?" + - input analisis_libr +script: + - solve analisis_de + - solve analisis_sueno + - solve analisis_encargad + - solve analisis_motiva + - solve analisis_presion + - solve analisis_pasa + - solve analisis_libro + diff --git a/conversations/trabajo_cv_conversations/curriculum.yaml b/conversations/trabajo_cv_conversations/curriculum.yaml new file mode 100644 index 000000000..0afc7283b --- /dev/null +++ b/conversations/trabajo_cv_conversations/curriculum.yaml @@ -0,0 +1,6 @@ +script: + - solve datos_personales + - solve escolar + - solve trabajo + - solve Habilidades_Tecnicas + - solve hello \ No newline at end of file diff --git a/conversations/trabajo_cv_conversations/data.csv b/conversations/trabajo_cv_conversations/data.csv new file mode 100644 index 000000000..6c436adae --- /dev/null +++ b/conversations/trabajo_cv_conversations/data.csv @@ -0,0 +1,3 @@ +fact, date +benito juarez nacio en, un 21 marzo +el día de la bandere es el, 24 de febrero diff --git a/conversations/trabajo_cv_conversations/datos_personales.yaml b/conversations/trabajo_cv_conversations/datos_personales.yaml new file mode 100755 index 000000000..5b42da3e3 --- /dev/null +++ b/conversations/trabajo_cv_conversations/datos_personales.yaml @@ -0,0 +1,34 @@ +# DATOS PERSONALES +slots: + - nombrec + - fechaN + - domicilio + - nacionalidad + - estadocivil + - telefono + - correo + +strategies: + nombrec: + - say "Hola ¿Cuál es tu nombre completo?" + - input nombrec + fechaN: + - say "Bien, ahora coloca tu fecha de nacimiento" + - input fechaN | fecha + domicilio: + - say "¿Cuál es tu domicilio? (Calle, numero, colonia, ciudad)" + - input domicilio + nacionalidad: + - say "¿Cuál es tu nacionalidad?" + - input nacionalidad + estadocivil: + - say "¿Cuál es tu estado civil? (Soltero, Casado, Divorciado o Viudo)" + - input estadocivil + telefono: + - say "¿Cual es tu numero telefónico?" + - input telefono + correo: + - say "Ingresa tu e-mail por favor" + - input correo +script: + - loop_slots \ No newline at end of file diff --git a/conversations/trabajo_cv_conversations/empresa.yaml b/conversations/trabajo_cv_conversations/empresa.yaml new file mode 100644 index 000000000..facb45479 --- /dev/null +++ b/conversations/trabajo_cv_conversations/empresa.yaml @@ -0,0 +1,7 @@ +strategies: + grado_escolar: + - say "Ahora te hare preguntas acerca de tu escolaridad" + - say "¿Que puedes contarme acerca de esto?" + - input grado_escolar +script: + - solve grado_escolar \ No newline at end of file diff --git a/conversations/trabajo_cv_conversations/entrevista.yaml b/conversations/trabajo_cv_conversations/entrevista.yaml new file mode 100644 index 000000000..065fbed43 --- /dev/null +++ b/conversations/trabajo_cv_conversations/entrevista.yaml @@ -0,0 +1,19 @@ +conversations: + - 'datos_personales.yaml' + - 'trabajo.yaml' + - 'escolar.yaml' + - 'empresa.yaml' + +dbs: + main: import_csv data.csv + +script: + - solve datos_personales + - solve escolar + - solve trabajo + - solve empresa + - solve objetivos_metas + - solve actitudes_aptitudes + - solve analisis_psi + - solve empezar + \ No newline at end of file diff --git a/conversations/trabajo_cv_conversations/escolar.yaml b/conversations/trabajo_cv_conversations/escolar.yaml new file mode 100755 index 000000000..e41e40c66 --- /dev/null +++ b/conversations/trabajo_cv_conversations/escolar.yaml @@ -0,0 +1,31 @@ +strategies: + grado_escolar: + - say "Ahora te haré preguntas acerca de tu escolaridad" + - say "¿Qué puedes contarme acerca de eso?" + - input datos_escolares + num_pro: + - say "¿Cuántos proyectos consideras relevantes en los que has participado?" + - input num_pro | number + proyecto: + - solve nombre_escolar + - solve descripcion_esc + - solve guardar_info_esc + nombre_escolar: + - say "Menciona el nombre del proyecto" + - input nombre_escolar + descripcion_esc: + - say "¿Podrías hablarme acerca de él?" + - input descripcion_esc + guardar_info_esc: + - execute self.slots['lugares_esc'].append((self.slots['nombre_escolar'],self.slots['descripcion_esc'])) + - empty_slot nombre_escolar + - empty_slot descripcion_esc + - execute self.slots['numero_contador_esc']+=1 +script: + - solve grado_escolar + - solve num_pro + - add_slot lugares_esc + - set_slot lugares_esc [] + - add_slot numero_contador_esc + - set_slot numero_contador_esc 0 + - while numero_contador_esc < num_pro solve proyecto diff --git a/conversations/trabajo_cv_conversations/hello.yaml b/conversations/trabajo_cv_conversations/hello.yaml new file mode 100644 index 000000000..a9fd8fa90 --- /dev/null +++ b/conversations/trabajo_cv_conversations/hello.yaml @@ -0,0 +1,7 @@ +plugins: + #- random_greeting + #- spacy + - doc_generator + +script: + - doc_generator.execute(nombre,fechaN,domicilio,nacionalidad,estadocivil,telefono,correo,datos_escolares,lugares_esc,lugares,nombreIdiomas,herramientas) \ No newline at end of file diff --git a/conversations/trabajo_cv_conversations/hello_name.yaml b/conversations/trabajo_cv_conversations/hello_name.yaml new file mode 100644 index 000000000..9f1826b0a --- /dev/null +++ b/conversations/trabajo_cv_conversations/hello_name.yaml @@ -0,0 +1,38 @@ +# Conversation example for simple hello and ask a name + +settings: + name: Viernes + +conversations: + - 'hello.yaml' + +slots: + - name + +dbs: + main: import_csv data.csv + +kb: kb.db + +strategies: + name: + - say "¿cúal es tu nombre?" + - input name + - remember name + - say "mucho gusto en conocerte" + excelent: + - say "me da mucho gusto que estés bien" + sorry: + - say "siento que no te encuentre bien" + +script: + - solve hello + - say greeting + - loop_slots + - say "¿como estás hoy {}?".format(name) + - input status | asign bien:good mal:bad + - if status == "good" solve excelent + - if status == "bad" solve sorry + - say "Hay algunas cosas que se" + - say "hecho {} {}".format(*db['main'][0]) + - say "adios {}".format(name) diff --git a/conversations/trabajo_cv_conversations/objetivos_metas.yaml b/conversations/trabajo_cv_conversations/objetivos_metas.yaml new file mode 100644 index 000000000..7a7a6e4e9 --- /dev/null +++ b/conversations/trabajo_cv_conversations/objetivos_metas.yaml @@ -0,0 +1,30 @@ +strategies: + objetivos_corto: + - say "Cuéntame acerca de ellos por favor" + - input objeti_corto + - say "Me parecen bien tus objetivos a corto plazo" + objetivos_largo: + - say "Cuéntame acerca de ellos por favor" + - input objeti_largo + - say "Me agradan tus objetivos a largo plazo" + metas_corto: + - say "Cuéntame acerca de ellas por favor" + - input meta_corto + - say "Me parece bien que tengas metas a corto plazo" + metas_largo: + - say "Cuéntame acerca de ellas" + - input meta_largo + - say "Me parece excelente que tengas metas a corto plazo" +script: + - say "¿Tienes algún objetivo a corto plazo?" + - input si_objet_c | yesno + - if si_objet_c solve objetivos_corto + - say "¿Tienes algún objetivo a largo plazo?" + - input si_objet_l | yesno + - if si_objet_l solve objetivos_largo + - say "¿Tienes alguna meta a corto plazo?" + - input si_meta_c | yesno + - if si_meta_c solve metas_corto + - say "¿Tienes alguna meta a largo plazo?" + - input si_meta_l | yesno + - if si_meta_l solve metas_largo \ No newline at end of file diff --git a/conversations/trabajo_cv_conversations/pract_yes_pro.yaml b/conversations/trabajo_cv_conversations/pract_yes_pro.yaml new file mode 100644 index 000000000..8eb01cecc --- /dev/null +++ b/conversations/trabajo_cv_conversations/pract_yes_pro.yaml @@ -0,0 +1,26 @@ +strategies: + num_lugar: + - say "¿En cuantos lugares?" + - input num_lugar | number + lugar: + - solve lugar_puesto + - solve periodo + - solve guardar_info + lugar_puesto: + - say "Menciona el lugar y en que puesto trabajaste" + - input lugar_puesto + periodo: + - say "¿Que periodo de tiempo estuviste?" + - input periodo + guardar_info: + - execute self.slots['lugares'].append((self.slots['lugar_puesto'],self.slots['periodo'])) + - empty_slot lugar_puesto + - empty_slot periodo + - execute self.slots['numero_contador']+=1 +script: + - solve num_lugar + - add_slot lugares + - set_slot lugares [] + - add_slot numero_contador + - set_slot numero_contador 0 + - while numero_contador < num_lugar solve lugar diff --git a/conversations/trabajo_cv_conversations/principal.yaml b/conversations/trabajo_cv_conversations/principal.yaml new file mode 100644 index 000000000..78bc537ee --- /dev/null +++ b/conversations/trabajo_cv_conversations/principal.yaml @@ -0,0 +1,45 @@ +settings: + name: Haunter + +conversations: + - 'datos_personales.yaml' + - 'hello.yaml' + - 'pract_yes_pro.yaml' + - 'entrevista.yaml' + - 'trabajo.yaml' + - 'curriculum.yaml' + - 'escolar.yaml' + - 'Habilidades_Tecnicas.yaml' + - 'actitudes_aptitudes.yaml' + - 'analisis_psi.yaml' + - 'empresa.yaml' + - 'objetivos_metas.yaml' + +slots: + - respuesta + +dbs: + main: import_csv data.csv + +kb: kb.db + +strategies: + error: + - say "Lo siento, no entendí lo que dijiste" + - solve empezar + empezar: + - say "Te puedo ayudar con dos herramientas para ti" + - say "Realizar tu Curriculum" + - say "Hacer una entrevista de trabajo de simulacion" + - input respuesta | asign curriculum:cv entrevista:ent + - if respuesta == "cv" solve curriculum + - if respuesta == "ent" solve entrevista + #- if nombre say "¡Hasta luego {}!".format(nombre) + - say "¡Hasta luego!" + #- if not respuesta=="na" and not respuesta=="cv" and not respuesta=="ent" solve error +script: + #- solve hello + #- say greeting + - say "BIENVENIDO, SOY HAUNTER EL CHATBOT QUE TE AYUDARÁ A CONSEGUIR TRABAJO" + - solve empezar + \ No newline at end of file diff --git a/conversations/trabajo_cv_conversations/spacy_test.py b/conversations/trabajo_cv_conversations/spacy_test.py new file mode 100644 index 000000000..2bdf9adf5 --- /dev/null +++ b/conversations/trabajo_cv_conversations/spacy_test.py @@ -0,0 +1,24 @@ +# pip install spacy +# python -m spacy download en_core_web_sm + +import spacy + +# Load English tokenizer, tagger, parser, NER and word vectors +nlp = spacy.load("en_core_web_sm") + +# Process whole documents +text = ("When Sebastian Thrun started working on self-driving cars at " + "Google in 2007, few people outside of the company took him " + "seriously. “I can tell you very senior CEOs of major American " + "car companies would shake my hand and turn away because I wasn’t " + "worth talking to,” said Thrun, in an interview with Recode earlier " + "this week.") +doc = nlp(text) + +# Analyze syntax +print("Noun phrases:", [chunk.text for chunk in doc.noun_chunks]) +print("Verbs:", [token.lemma_ for token in doc if token.pos_ == "VERB"]) + +# Find named entities, phrases and concepts +for entity in doc.ents: + print(entity.text, entity.label_) \ No newline at end of file diff --git a/conversations/trabajo_cv_conversations/trabajo.yaml b/conversations/trabajo_cv_conversations/trabajo.yaml new file mode 100644 index 000000000..4b5885367 --- /dev/null +++ b/conversations/trabajo_cv_conversations/trabajo.yaml @@ -0,0 +1,26 @@ +strategies: + num_lugar: + - say "¿En cuantos lugares has trabajado anteriormente?" + - input num_lugar | number + lugar: + - solve lugar_puesto + - solve periodo + - solve guardar_info + lugar_puesto: + - say "Menciona el lugar y en que puesto trabajaste" + - input lugar_puesto + periodo: + - say "¿Que periodo de tiempo estuviste?" + - input periodo + guardar_info: + - execute self.slots['lugares'].append((self.slots['lugar_puesto'],self.slots['periodo'])) + - empty_slot lugar_puesto + - empty_slot periodo + - execute self.slots['numero_contador']+=1 +script: + - solve num_lugar + - add_slot lugares + - set_slot lugares [] + - add_slot numero_contador + - set_slot numero_contador 0 + - while numero_contador < num_lugar solve lugar \ No newline at end of file diff --git a/curriculumHAUNTER.docx b/curriculumHAUNTER.docx new file mode 100644 index 000000000..a20e38d43 Binary files /dev/null and b/curriculumHAUNTER.docx differ diff --git a/filters.py b/filters.py index 54ab3e9de..948b182e2 100644 --- a/filters.py +++ b/filters.py @@ -3,6 +3,7 @@ # # Ivan Vladimir Meza Ruiz 2018 # GPL 3.0 +import dateparser def yesno(msg,*args): if msg in ['si','sí']: @@ -10,8 +11,16 @@ def yesno(msg,*args): else: return False +def fecha(msg,*args): + return dateparser.parse(u''+msg) + def number(msg,*args): - return float(msg) + msg=msg.lower() + dicc = {'ninguno':0,'cero':0,'uno':1,'dos':2,'tres':3,'cuatro':4,'cinco':5,'seis':6,'siete':7,'ocho':8,'nueve':9,'diez':10} + if msg in ['ninguno','cero','uno','dos','tres','cuatro','cinco','seis','siete','ocho','nueve','diez']: + return dicc[msg] + else: + return float(msg) def list(msg,*args): return msg.split() diff --git a/haunterbot.png b/haunterbot.png new file mode 100644 index 000000000..d641011a2 Binary files /dev/null and b/haunterbot.png differ diff --git a/plantilla.docx b/plantilla.docx new file mode 100644 index 000000000..c5273e855 Binary files /dev/null and b/plantilla.docx differ diff --git a/plugins/doc_generator.py b/plugins/doc_generator.py new file mode 100644 index 000000000..e1113729d --- /dev/null +++ b/plugins/doc_generator.py @@ -0,0 +1,84 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# +# Ivan Vladimir Meza Ruiz 2018 +# GPL 3.0 + +import random +import spacy +from docx import Document +from docx.shared import Inches + +def execute(*args): + nom=args[0] + fec=args[1] + dom=args[2] + nac=args[3] + civ=args[4] + tel=args[5] + ema=args[6] + d_e=args[7] + l_e=args[8] + lug=args[9] + idio=args[10] + offi=args[11] + f = open('plantilla.docx', 'rb') + document = Document(f) + f.close() + p=document.add_paragraph('Datos personales', style='Intense Quote') + n=document.add_paragraph('') + n.add_run('Nombre: ').bold = True + nn=nom + nn=nn.title() + n.add_run(nn) + f=document.add_paragraph('') + f.add_run('Fecha de nacimiento: ').bold = True + f.add_run(fec) + d=document.add_paragraph('') + d.add_run('Domicilio: ').bold = True + d.add_run(dom) + na=document.add_paragraph('') + na.add_run('Nancionalidad: ').bold = True + na.add_run(nac) + e=document.add_paragraph('') + e.add_run('Estado civil: ').bold = True + e.add_run(civ) + t=document.add_paragraph('') + t.add_run('Teléfono: ').bold = True + t.add_run(tel) + c=document.add_paragraph('') + c.add_run('e-mail: ').bold = True + c.add_run(ema) + p2=document.add_paragraph('Formación académica', style='Intense Quote') + de=document.add_paragraph('') + de.add_run('Datos escolares: ').bold = True + de.add_run(d_e) + le=document.add_paragraph('') + le.add_run('Proyectos escolares: ').bold = True + table = document.add_table(rows=1, cols=2) + hdr_cells = table.rows[0].cells + hdr_cells[0].text = 'Nombre del proyecto' + hdr_cells[1].text = 'Descripción' + for nomp, desc in l_e: + row_cells = table.add_row().cells + row_cells[0].text = nomp + row_cells[1].text = desc + p3=document.add_paragraph('Experiencia laboral', style='Intense Quote') + tablet = document.add_table(rows=1, cols=2) + hdr_cellst = tablet.rows[0].cells + hdr_cellst[0].text = 'Lugar y puesto' + hdr_cellst[1].text = 'Periodo' + for nompt, desct in lug: + row_cellst = tablet.add_row().cells + row_cellst[0].text = nompt + row_cellst[1].text = desct + p4=document.add_paragraph('Habilidades técnicas', style='Intense Quote') + idi=document.add_paragraph('') + idi.add_run('Idiomas: ').bold = True + idi.add_run(idio) + her=document.add_paragraph('') + her.add_run('Herramientas Office: ').bold = True + her.add_run(offi) + document.save('curriculumHAUNTER.docx') + + return 'say "¡CURRICULUM GENERADO CON ÉXITO!"' diff --git a/plugins/random_greeting.py b/plugins/random_greeting.py index c2efd4c19..7573dec37 100644 --- a/plugins/random_greeting.py +++ b/plugins/random_greeting.py @@ -9,6 +9,6 @@ def execute(*args): var=args[0] opts=args[1] - msg = random.choice(['hola','buen día','chevere']+opts) + msg = random.choice(['hola','buen día','qué tal']+opts) return 'set_slot {0} "{1}"'.format(var,msg) diff --git a/plugins/spacy.py b/plugins/spacy.py new file mode 100644 index 000000000..f48d2a2fa --- /dev/null +++ b/plugins/spacy.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# +# Ivan Vladimir Meza Ruiz 2018 +# GPL 3.0 + +import random +import spacy + +def execute(*args): + var=args[0] + opts=args[1] + msg = random.choice(['hola','buen día','qué tal']+opts) + # Load English tokenizer, tagger, parser, NER and word vectors + nlp = spacy.load("en_core_web_sm") + # Process whole documents + text = ("When Sebastian Thrun started working on self-driving cars at " + "Google in 2007, few people outside of the company took him " + "seriously. “I can tell you very senior CEOs of major American " + "car companies would shake my hand and turn away because I wasn’t " + "worth talking to,” said Thrun, in an interview with Recode earlier " + "this week.") + doc = nlp(text) + # Analyze syntax + print("Noun phrases:", [chunk.text for chunk in doc.noun_chunks]) + print("Verbs:", [token.lemma_ for token in doc if token.pos_ == "VERB"]) + # Find named entities, phrases and concepts + for entity in doc.ents: + print(entity.text, entity.label_) + + return 'set_slot {0} "{1}"'.format(var,text) + diff --git a/requierements.txt b/requierements.txt index d86c96598..e738b7fe3 100644 --- a/requierements.txt +++ b/requierements.txt @@ -7,6 +7,7 @@ certifi==2018.4.16 chardet==3.0.4 click==6.7 duckduckpy==0.2 +get==2019.4.13 gTTS==2.0.0 gTTS-token==1.1.1 idna==2.6 @@ -14,18 +15,24 @@ idna-ssl==1.1.0 multidict==4.5.2 netifaces==0.10.6 numpy==1.14.3 +pkg-resources==0.0.0 +post==2019.4.13 +public==2019.4.13 PyAudio==0.2.11 -python-engineio==3.5.0 -python-socketio==4.0.0 +python-dotenv==0.10.3 +python-engineio==3.8.2.post1 +python-socketio==4.2.0 pyttsx3==2.7 PyYAML==3.12 +query-string==2019.4.13 +request==2019.4.13 requests==2.18.4 six==1.11.0 socketio==0.1.6 socketIO-client==0.7.2 SpeechRecognition==3.8.1 tinydb==3.9.0 -typing-extensions==3.7.2 +typing-extensions==3.7.4 urllib3==1.22 webrtcvad==2.0.10 websocket-client==0.56.0 diff --git a/user.png b/user.png new file mode 100644 index 000000000..9578d242c Binary files /dev/null and b/user.png differ