mirror of
https://github.com/leon-ai/leon.git
synced 2024-09-20 14:27:40 +03:00
Merge branch 'modules-actions' into develop
This commit is contained in:
commit
232efad74c
@ -14,7 +14,7 @@ def main():
|
||||
queryobj = utils.getqueryobj()
|
||||
m = import_module('packages.' + queryobj['package'] + '.' + queryobj['module'])
|
||||
|
||||
return getattr(m, queryobj['module'])(queryobj['query'], queryobj['entities'])
|
||||
return getattr(m, queryobj['action'])(queryobj['query'], queryobj['entities'])
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
@ -61,6 +61,7 @@ def output(type, code, speech = ''):
|
||||
print(dumps({
|
||||
'package': queryobj['package'],
|
||||
'module': queryobj['module'],
|
||||
'action': queryobj['action'],
|
||||
'lang': queryobj['lang'],
|
||||
'input': queryobj['query'],
|
||||
'entities': queryobj['entities'],
|
||||
|
@ -13,7 +13,8 @@
|
||||
{
|
||||
"words": ["merci"],
|
||||
"package": "leon",
|
||||
"module": "welcome"
|
||||
"module": "welcome",
|
||||
"action": "run"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "leon",
|
||||
"version": "1.0.0-beta.2",
|
||||
"version": "1.0.0-beta.3",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "leon",
|
||||
"version": "1.0.0-beta.2",
|
||||
"version": "1.0.0-beta.3",
|
||||
"description": "Server, packages and web app of the Leon personal assistant",
|
||||
"author": {
|
||||
"name": "Louis Grenard",
|
||||
|
19
packages/calendar/README.md
Normal file
19
packages/calendar/README.md
Normal file
@ -0,0 +1,19 @@
|
||||
# Calendar Package
|
||||
|
||||
WIP...
|
||||
|
||||
## Modules
|
||||
|
||||
### To-Do List
|
||||
|
||||
WIP...
|
||||
|
||||
#### Usage
|
||||
|
||||
WIP...
|
||||
|
||||
```
|
||||
(en-US) "..."
|
||||
|
||||
(fr-FR) "..."
|
||||
```
|
0
packages/calendar/__init__.py
Normal file
0
packages/calendar/__init__.py
Normal file
0
packages/calendar/config/.gitkeep
Normal file
0
packages/calendar/config/.gitkeep
Normal file
5
packages/calendar/config/config.sample.json
Normal file
5
packages/calendar/config/config.sample.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"todolist": {
|
||||
"options": {}
|
||||
}
|
||||
}
|
0
packages/calendar/data/.gitkeep
Normal file
0
packages/calendar/data/.gitkeep
Normal file
0
packages/calendar/data/answers/.gitkeep
Normal file
0
packages/calendar/data/answers/.gitkeep
Normal file
25
packages/calendar/data/answers/en.json
Normal file
25
packages/calendar/data/answers/en.json
Normal file
@ -0,0 +1,25 @@
|
||||
{
|
||||
"todolist": {
|
||||
"list_created": [
|
||||
"I created the \"%list%\" list."
|
||||
],
|
||||
"list_already_exists": [
|
||||
"You already have a list named \"%list%\"."
|
||||
],
|
||||
"list_renamed": [
|
||||
"I renamed the \"%old_list%\" list to \"%new_list%\" list."
|
||||
],
|
||||
"list_deleted": [
|
||||
"I deleted the \"%list%\" list and all the todos it contained."
|
||||
],
|
||||
"todo_added": [
|
||||
"I added \"%todo%\" to your \"%list%\" list."
|
||||
],
|
||||
"todo_completed": [
|
||||
"I completed \"%todo%\" from your \"%list%\" list, congrats!"
|
||||
],
|
||||
"todo_archived": [
|
||||
"I archived \"%todo%\" from your \"%list%\" list."
|
||||
]
|
||||
}
|
||||
}
|
25
packages/calendar/data/answers/fr.json
Normal file
25
packages/calendar/data/answers/fr.json
Normal file
@ -0,0 +1,25 @@
|
||||
{
|
||||
"todolist": {
|
||||
"list_created": [
|
||||
"J'ai créé la liste \"%list%\"."
|
||||
],
|
||||
"list_already_exists": [
|
||||
"Vous avez déjà une liste nommée \"%list%\"."
|
||||
],
|
||||
"list_renamed": [
|
||||
"J'ai renommé la liste \"%old_list%\" en liste \"%new_list%\"."
|
||||
],
|
||||
"list_deleted": [
|
||||
"J'ai supprimé la liste \"%list%\" et toutes les tâches qu'elle contenait."
|
||||
],
|
||||
"todo_added": [
|
||||
"J'ai ajouté la tâche \"%todo%\" à votre liste \"%list%\"."
|
||||
],
|
||||
"todo_completed": [
|
||||
"J'ai complété la tâche \"%todo%\" de votre liste \"%list%\", bravo !"
|
||||
],
|
||||
"todo_archived": [
|
||||
"J'ai archivé la tâche \"%todo%\" de votre liste \"%list%\"."
|
||||
]
|
||||
}
|
||||
}
|
0
packages/calendar/data/db/.gitkeep
Normal file
0
packages/calendar/data/db/.gitkeep
Normal file
0
packages/calendar/data/expressions/.gitkeep
Normal file
0
packages/calendar/data/expressions/.gitkeep
Normal file
40
packages/calendar/data/expressions/en.json
Normal file
40
packages/calendar/data/expressions/en.json
Normal file
@ -0,0 +1,40 @@
|
||||
{
|
||||
"todolist": {
|
||||
"create_list": {
|
||||
"expressions": [
|
||||
"Create the list",
|
||||
"Create a list"
|
||||
]
|
||||
},
|
||||
"rename_list": {
|
||||
"expressions": [
|
||||
"Rename the list to list",
|
||||
"Rename my list to list"
|
||||
]
|
||||
},
|
||||
"delete_list": {
|
||||
"expressions": [
|
||||
"Delete the list",
|
||||
"Delete my list"
|
||||
]
|
||||
},
|
||||
"add_todo": {
|
||||
"expressions": [
|
||||
"Add to the list",
|
||||
"Add to my list"
|
||||
]
|
||||
},
|
||||
"complete_todo": {
|
||||
"expressions": [
|
||||
"Complete from the list",
|
||||
"Complete from my list"
|
||||
]
|
||||
},
|
||||
"archive_todo": {
|
||||
"expressions": [
|
||||
"Archive from the list",
|
||||
"Archive from my list"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
40
packages/calendar/data/expressions/fr.json
Normal file
40
packages/calendar/data/expressions/fr.json
Normal file
@ -0,0 +1,40 @@
|
||||
{
|
||||
"todolist": {
|
||||
"create_list": {
|
||||
"expressions": [
|
||||
"Créé la liste",
|
||||
"Créé une liste"
|
||||
]
|
||||
},
|
||||
"rename_list": {
|
||||
"expressions": [
|
||||
"Renomme la liste en liste",
|
||||
"Renomme ma liste en liste"
|
||||
]
|
||||
},
|
||||
"delete_list": {
|
||||
"expressions": [
|
||||
"Supprime la liste",
|
||||
"Supprime ma liste"
|
||||
]
|
||||
},
|
||||
"add_todo": {
|
||||
"expressions": [
|
||||
"Ajoute à la liste",
|
||||
"Ajoute à ma liste"
|
||||
]
|
||||
},
|
||||
"complete_todo": {
|
||||
"expressions": [
|
||||
"Complète de la liste",
|
||||
"Complete de ma liste"
|
||||
]
|
||||
},
|
||||
"archive_todo": {
|
||||
"expressions": [
|
||||
"Archive de la liste",
|
||||
"Archive de ma liste"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
13
packages/calendar/test/todolist.js
Normal file
13
packages/calendar/test/todolist.js
Normal file
@ -0,0 +1,13 @@
|
||||
'use strict'
|
||||
|
||||
describe('calendar:todolist', async () => {
|
||||
test('creates a list', async () => {
|
||||
global.nlu.brain.execute = jest.fn()
|
||||
await global.nlu.process('Create the fake list')
|
||||
|
||||
const [obj] = global.nlu.brain.execute.mock.calls
|
||||
await global.brain.execute(obj[0])
|
||||
|
||||
expect(global.brain.finalOutput.codes).toIncludeSameMembers(['list_created'])
|
||||
})
|
||||
})
|
47
packages/calendar/todolist.py
Normal file
47
packages/calendar/todolist.py
Normal file
@ -0,0 +1,47 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding:utf-8 -*-
|
||||
|
||||
import requests
|
||||
import utils
|
||||
|
||||
def create_list(string, entities):
|
||||
"""WIP"""
|
||||
|
||||
return utils.output('end', 'list_created', utils.translate('list_created', { 'list': 'fake' }))
|
||||
|
||||
def rename_list(string, entities):
|
||||
"""WIP"""
|
||||
|
||||
return utils.output('end', 'list_renamed', utils.translate('list_renamed', {
|
||||
'old_list': 'fake',
|
||||
'new_list': 'new'
|
||||
}))
|
||||
|
||||
def delete_list(string, entities):
|
||||
"""WIP"""
|
||||
|
||||
return utils.output('end', 'list_deleted', utils.translate('list_deleted', { 'list': 'fake' }))
|
||||
|
||||
def add_todo(string, entities):
|
||||
"""WIP"""
|
||||
|
||||
return utils.output('end', 'todo_added', utils.translate('todo_added', {
|
||||
'list': 'fake',
|
||||
'todo': 'todo 1'
|
||||
}))
|
||||
|
||||
def complete_todo(string, entities):
|
||||
"""WIP"""
|
||||
|
||||
return utils.output('end', 'todo_completed', utils.translate('todo_completed', {
|
||||
'list': 'fake',
|
||||
'todo': 'todo 1'
|
||||
}))
|
||||
|
||||
def archive_todo(string, entities):
|
||||
"""WIP"""
|
||||
|
||||
return utils.output('end', 'todo_archived', utils.translate('todo_archived', {
|
||||
'list': 'fake',
|
||||
'todo': 'todo 1'
|
||||
}))
|
1
packages/calendar/version.txt
Normal file
1
packages/calendar/version.txt
Normal file
@ -0,0 +1 @@
|
||||
1.0.0
|
@ -1,29 +1,37 @@
|
||||
{
|
||||
"isitdown": [
|
||||
"Is getleon.ai up?",
|
||||
"Is mozilla.org down?",
|
||||
"Is mozilla.org up or down?",
|
||||
"Is github.com up?",
|
||||
"Is github.com down?",
|
||||
"Check if github.com is up or down",
|
||||
"Check if github.com is down",
|
||||
"Check if github.com is up",
|
||||
"Check if nodejs.org is down",
|
||||
"Check if nodejs.org is up",
|
||||
"Check if nodejs.org is working",
|
||||
"Check if amazon.com is up or down"
|
||||
],
|
||||
"haveibeenpwned": [
|
||||
"Has iifeoluwa.ao@gmail.com been pwned?",
|
||||
"Has iifeoluwa.ao@gmail.com been compromised?",
|
||||
"Has iifeoluwa.ao@gmail.com been exposed in a breach?",
|
||||
"Is iifeoluwa.ao@gmail.com still uncompromised?",
|
||||
"Is iifeoluwa.ao@gmail.com compromised?",
|
||||
"Have my email address been pwned?",
|
||||
"Check that iifeoluwa.ao@gmail.com and louis.grenard@gmail.com haven't been compromised",
|
||||
"Check that iifeoluwa.ao@gmail.com and louis.grenard@gmail.com haven't been pwned",
|
||||
"Check that iifeoluwa.ao@gmail.com and louis.grenard@gmail.com haven't been exposed in a breach",
|
||||
"Verify the pwnage status of iifeoluwa.ao@gmail.com",
|
||||
"Verify the pwnage status of iifeoluwa.ao@gmail.com and louis.grenard@gmail.com"
|
||||
]
|
||||
"isitdown": {
|
||||
"run": {
|
||||
"expressions": [
|
||||
"Is getleon.ai up?",
|
||||
"Is mozilla.org down?",
|
||||
"Is mozilla.org up or down?",
|
||||
"Is github.com up?",
|
||||
"Is github.com down?",
|
||||
"Check if github.com is up or down",
|
||||
"Check if github.com is down",
|
||||
"Check if github.com is up",
|
||||
"Check if nodejs.org is down",
|
||||
"Check if nodejs.org is up",
|
||||
"Check if nodejs.org is working",
|
||||
"Check if amazon.com is up or down"
|
||||
]
|
||||
}
|
||||
},
|
||||
"haveibeenpwned": {
|
||||
"run": {
|
||||
"expressions": [
|
||||
"Has iifeoluwa.ao@gmail.com been pwned?",
|
||||
"Has iifeoluwa.ao@gmail.com been compromised?",
|
||||
"Has iifeoluwa.ao@gmail.com been exposed in a breach?",
|
||||
"Is iifeoluwa.ao@gmail.com still uncompromised?",
|
||||
"Is iifeoluwa.ao@gmail.com compromised?",
|
||||
"Have my email address been pwned?",
|
||||
"Check that iifeoluwa.ao@gmail.com and louis.grenard@gmail.com haven't been compromised",
|
||||
"Check that iifeoluwa.ao@gmail.com and louis.grenard@gmail.com haven't been pwned",
|
||||
"Check that iifeoluwa.ao@gmail.com and louis.grenard@gmail.com haven't been exposed in a breach",
|
||||
"Verify the pwnage status of iifeoluwa.ao@gmail.com",
|
||||
"Verify the pwnage status of iifeoluwa.ao@gmail.com and louis.grenard@gmail.com"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,27 +1,35 @@
|
||||
{
|
||||
"isitdown": [
|
||||
"Est-ce que getleon.ai est en ligne ?",
|
||||
"Est-ce que mozilla.org est hors ligne ?",
|
||||
"mozilla.org est en ligne ou hors ligne ?",
|
||||
"github.com en ligne ?",
|
||||
"github.com hors ligne ?",
|
||||
"Vérifies si github.com en ligne ou hors ligne",
|
||||
"Vérifies si github.com hors ligne",
|
||||
"Vérifies si github.com en ligne",
|
||||
"Vérifies si nodejs.org hors ligne",
|
||||
"Vérifies si nodejs.org en ligne",
|
||||
"Vérifies si nodejs.org fonctionne",
|
||||
"Vérifies si amazon.com en ligne ou hors ligne"
|
||||
],
|
||||
"haveibeenpwned": [
|
||||
"iifeoluwa.ao@gmail.com a-t-elle été pwned ?",
|
||||
"iifeoluwa.ao@gmail.com a-t-elle été compromise ?",
|
||||
"iifeoluwa.ao@gmail.com a-t-elle été exposée à une brèche ?",
|
||||
"iifeoluwa.ao@gmail.com est-elle toujours non compromise ?",
|
||||
"Est-ce que iifeoluwa.ao@gmail.com est compromise ?",
|
||||
"Est-ce que mon adresse email a été compromise ?",
|
||||
"Vérifies que iifeoluwa.ao@gmail.com et louis.grenard@gmail.com n'ont pas été compromise",
|
||||
"Vérifies que iifeoluwa.ao@gmail.com et louis.grenard@gmail.com n'ont pas été pwned",
|
||||
"Vérifies que iifeoluwa.ao@gmail.com et louis.grenard@gmail.com n'ont pas été exposées à une brèche"
|
||||
]
|
||||
"isitdown": {
|
||||
"run": {
|
||||
"expressions": [
|
||||
"Est-ce que getleon.ai est en ligne ?",
|
||||
"Est-ce que mozilla.org est hors ligne ?",
|
||||
"mozilla.org est en ligne ou hors ligne ?",
|
||||
"github.com en ligne ?",
|
||||
"github.com hors ligne ?",
|
||||
"Vérifies si github.com en ligne ou hors ligne",
|
||||
"Vérifies si github.com hors ligne",
|
||||
"Vérifies si github.com en ligne",
|
||||
"Vérifies si nodejs.org hors ligne",
|
||||
"Vérifies si nodejs.org en ligne",
|
||||
"Vérifies si nodejs.org fonctionne",
|
||||
"Vérifies si amazon.com en ligne ou hors ligne"
|
||||
]
|
||||
}
|
||||
},
|
||||
"haveibeenpwned": {
|
||||
"run": {
|
||||
"expressions": [
|
||||
"iifeoluwa.ao@gmail.com a-t-elle été pwned ?",
|
||||
"iifeoluwa.ao@gmail.com a-t-elle été compromise ?",
|
||||
"iifeoluwa.ao@gmail.com a-t-elle été exposée à une brèche ?",
|
||||
"iifeoluwa.ao@gmail.com est-elle toujours non compromise ?",
|
||||
"Est-ce que iifeoluwa.ao@gmail.com est compromise ?",
|
||||
"Est-ce que mon adresse email a été compromise ?",
|
||||
"Vérifies que iifeoluwa.ao@gmail.com et louis.grenard@gmail.com n'ont pas été compromise",
|
||||
"Vérifies que iifeoluwa.ao@gmail.com et louis.grenard@gmail.com n'ont pas été pwned",
|
||||
"Vérifies que iifeoluwa.ao@gmail.com et louis.grenard@gmail.com n'ont pas été exposées à une brèche"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ from time import sleep
|
||||
from urllib import parse
|
||||
from requests import codes, exceptions
|
||||
|
||||
def haveibeenpwned(string, entities):
|
||||
def run(string, entities):
|
||||
emails = []
|
||||
|
||||
for item in entities:
|
||||
|
@ -4,7 +4,7 @@
|
||||
import requests
|
||||
import utils
|
||||
|
||||
def isitdown(string, entities):
|
||||
def run(string, entities):
|
||||
"""Check if a website is down or not"""
|
||||
|
||||
domains = []
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
import utils
|
||||
|
||||
def bye(string, entities):
|
||||
def run(string, entities):
|
||||
"""Leon says good bye"""
|
||||
|
||||
return utils.output('end', 'good_bye', utils.translate('good_bye'))
|
||||
|
@ -1,60 +1,93 @@
|
||||
{
|
||||
"whoami": [
|
||||
"Who are you?",
|
||||
"How they call you?",
|
||||
"What's your name?",
|
||||
"Tell me who you are",
|
||||
"Introduce yourself"
|
||||
],
|
||||
"joke": [
|
||||
"Tell me a joke",
|
||||
"Give me a joke",
|
||||
"Make me laugh",
|
||||
"Do you have jokes to tell me?"
|
||||
],
|
||||
"greeting": [
|
||||
"Hi",
|
||||
"Hey",
|
||||
"Hello",
|
||||
"Good morning",
|
||||
"Good afternoon",
|
||||
"Good evening",
|
||||
"What's up?",
|
||||
"How are you?",
|
||||
"How are you doing?"
|
||||
],
|
||||
"welcome": [
|
||||
"Thank you",
|
||||
"Thanks",
|
||||
"Thanks a lot",
|
||||
"You are the best"
|
||||
],
|
||||
"meaningoflife": [
|
||||
"What is the meaning of life?",
|
||||
"Tell me what is the meaning of life"
|
||||
],
|
||||
"randomnumber": [
|
||||
"Give me a random number",
|
||||
"Give me a number",
|
||||
"Tell me a random number",
|
||||
"Choose a number",
|
||||
"Pickup a number"
|
||||
],
|
||||
"bye": [
|
||||
"Bye",
|
||||
"Goodbye",
|
||||
"Good bye",
|
||||
"See you later",
|
||||
"Bye bye"
|
||||
],
|
||||
"partnerassistant": [
|
||||
"Do you have something to say about Alexa?",
|
||||
"Tell me about the personal assistant Alexa",
|
||||
"Tell me about the personal assistant Cortana",
|
||||
"Do you have something to say about Cortana?",
|
||||
"Tell me about the personal assistant Siri",
|
||||
"Do you have something to say about Siri?",
|
||||
"Tell me about the personal assistant Google Assistant",
|
||||
"Do you have something to say about Google Assistant?"
|
||||
]
|
||||
"whoami": {
|
||||
"run": {
|
||||
"expressions": [
|
||||
"Who are you?",
|
||||
"How they call you?",
|
||||
"What's your name?",
|
||||
"Tell me who you are",
|
||||
"Introduce yourself"
|
||||
]
|
||||
}
|
||||
},
|
||||
"joke": {
|
||||
"run": {
|
||||
"expressions": [
|
||||
"Tell me a joke",
|
||||
"Give me a joke",
|
||||
"Make me laugh",
|
||||
"Do you have jokes to tell me?"
|
||||
]
|
||||
}
|
||||
},
|
||||
"greeting": {
|
||||
"run": {
|
||||
"expressions": [
|
||||
"Hi",
|
||||
"Hey",
|
||||
"Hello",
|
||||
"Good morning",
|
||||
"Good afternoon",
|
||||
"Good evening",
|
||||
"What's up?",
|
||||
"How are you?",
|
||||
"How are you doing?"
|
||||
]
|
||||
}
|
||||
},
|
||||
"welcome": {
|
||||
"run": {
|
||||
"expressions": [
|
||||
"Thank you",
|
||||
"Thanks",
|
||||
"Thanks a lot",
|
||||
"You are the best"
|
||||
]
|
||||
}
|
||||
},
|
||||
"meaningoflife": {
|
||||
"run": {
|
||||
"expressions": [
|
||||
"What is the meaning of life?",
|
||||
"Tell me what is the meaning of life"
|
||||
]
|
||||
}
|
||||
},
|
||||
"randomnumber": {
|
||||
"run": {
|
||||
"expressions": [
|
||||
"Give me a random number",
|
||||
"Give me a number",
|
||||
"Tell me a random number",
|
||||
"Choose a number",
|
||||
"Pickup a number"
|
||||
]
|
||||
}
|
||||
|
||||
},
|
||||
"bye": {
|
||||
"run": {
|
||||
"expressions": [
|
||||
"Bye",
|
||||
"Goodbye",
|
||||
"Good bye",
|
||||
"See you later",
|
||||
"Bye bye"
|
||||
]
|
||||
}
|
||||
},
|
||||
"partnerassistant": {
|
||||
"run": {
|
||||
"expressions": [
|
||||
"Do you have something to say about Alexa?",
|
||||
"Tell me about the personal assistant Alexa",
|
||||
"Tell me about the personal assistant Cortana",
|
||||
"Do you have something to say about Cortana?",
|
||||
"Tell me about the personal assistant Siri",
|
||||
"Do you have something to say about Siri?",
|
||||
"Tell me about the personal assistant Google Assistant",
|
||||
"Do you have something to say about Google Assistant?"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,61 +1,93 @@
|
||||
{
|
||||
"whoami": [
|
||||
"Qui es-tu ?",
|
||||
"Comment t'appelles-tu ?",
|
||||
"Comment tu t'appelles ?",
|
||||
"Dis-moi qui tu es",
|
||||
"Présente-toi"
|
||||
],
|
||||
"joke": [
|
||||
"Raconte-moi une blague",
|
||||
"Dis-moi une blague",
|
||||
"Donne-moi une blague",
|
||||
"Je veux rire",
|
||||
"As-tu des blagues à raconter ?"
|
||||
],
|
||||
"greeting": [
|
||||
"Salut",
|
||||
"Bonjour",
|
||||
"Bonsoir",
|
||||
"Salutations",
|
||||
"Hello",
|
||||
"Coucou"
|
||||
],
|
||||
"welcome": [
|
||||
"Merci",
|
||||
"Merci bien",
|
||||
"Merci beaucoup",
|
||||
"Merci mille fois",
|
||||
"Merci infiniment",
|
||||
"Merci à toi",
|
||||
"Tu es le meilleur",
|
||||
"Mes remerciements"
|
||||
],
|
||||
"meaningoflife": [
|
||||
"Quel est le but de la vie ?",
|
||||
"Quel est l'objectif de la vie ?"
|
||||
],
|
||||
"randomnumber": [
|
||||
"Donne-moi un nombre aléatoire",
|
||||
"Donne-moi un nombre",
|
||||
"Dis-moi un nombre aléatoire",
|
||||
"Choisis un nombre",
|
||||
"Pioche un nombre"
|
||||
],
|
||||
"bye": [
|
||||
"Au revoir",
|
||||
"Aurevoir",
|
||||
"Bye",
|
||||
"A la prochaine"
|
||||
],
|
||||
"partnerassistant": [
|
||||
"Connais-tu quelque chose sur Alexa ?",
|
||||
"Dis-moi quelque chose sur l'assistant personnel Alexa",
|
||||
"Connais-tu quelque chose sur Cortana ?",
|
||||
"Dis-moi quelque chose sur l'assistant personnel Cortana",
|
||||
"Connais-tu quelque chose sur Siri ?",
|
||||
"Dis-moi quelque chose sur l'assistant personnel Siri",
|
||||
"Connais-tu quelque chose sur le Google Assistant ?",
|
||||
"Dis-moi quelque chose sur l'assistant personnel Google Assistant"
|
||||
]
|
||||
"whoami": {
|
||||
"run": {
|
||||
"expressions": [
|
||||
"Qui es-tu ?",
|
||||
"Comment t'appelles-tu ?",
|
||||
"Comment tu t'appelles ?",
|
||||
"Dis-moi qui tu es",
|
||||
"Présente-toi"
|
||||
]
|
||||
}
|
||||
},
|
||||
"joke": {
|
||||
"run": {
|
||||
"expressions": [
|
||||
"Raconte-moi une blague",
|
||||
"Dis-moi une blague",
|
||||
"Donne-moi une blague",
|
||||
"Je veux rire",
|
||||
"As-tu des blagues à raconter ?"
|
||||
]
|
||||
}
|
||||
},
|
||||
"greeting": {
|
||||
"run": {
|
||||
"expressions": [
|
||||
"Salut",
|
||||
"Bonjour",
|
||||
"Bonsoir",
|
||||
"Salutations",
|
||||
"Hello",
|
||||
"Coucou"
|
||||
]
|
||||
}
|
||||
},
|
||||
"welcome": {
|
||||
"run": {
|
||||
"expressions": [
|
||||
"Merci",
|
||||
"Merci bien",
|
||||
"Merci beaucoup",
|
||||
"Merci mille fois",
|
||||
"Merci infiniment",
|
||||
"Merci à toi",
|
||||
"Tu es le meilleur",
|
||||
"Mes remerciements"
|
||||
]
|
||||
}
|
||||
},
|
||||
"meaningoflife": {
|
||||
"run": {
|
||||
"expressions": [
|
||||
"Quel est le but de la vie ?",
|
||||
"Quel est l'objectif de la vie ?"
|
||||
]
|
||||
}
|
||||
},
|
||||
"randomnumber": {
|
||||
"run": {
|
||||
"expressions": [
|
||||
"Donne-moi un nombre aléatoire",
|
||||
"Donne-moi un nombre",
|
||||
"Dis-moi un nombre aléatoire",
|
||||
"Choisis un nombre",
|
||||
"Pioche un nombre"
|
||||
]
|
||||
}
|
||||
},
|
||||
"bye": {
|
||||
"run": {
|
||||
"expressions": [
|
||||
"Au revoir",
|
||||
"Aurevoir",
|
||||
"Bye",
|
||||
"A la prochaine"
|
||||
]
|
||||
}
|
||||
},
|
||||
"partnerassistant": {
|
||||
"run": {
|
||||
"expressions": [
|
||||
"Connais-tu quelque chose sur Alexa ?",
|
||||
"Dis-moi quelque chose sur l'assistant personnel Alexa",
|
||||
"Connais-tu quelque chose sur Cortana ?",
|
||||
"Dis-moi quelque chose sur l'assistant personnel Cortana",
|
||||
"Connais-tu quelque chose sur Siri ?",
|
||||
"Dis-moi quelque chose sur l'assistant personnel Siri",
|
||||
"Connais-tu quelque chose sur le Google Assistant ?",
|
||||
"Dis-moi quelque chose sur l'assistant personnel Google Assistant"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import utils
|
||||
from datetime import datetime
|
||||
from random import randint
|
||||
|
||||
def greeting(string, entities):
|
||||
def run(string, entities):
|
||||
"""Leon greets you"""
|
||||
|
||||
time = datetime.time(datetime.now())
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
import utils
|
||||
|
||||
def joke(string, entities):
|
||||
def run(string, entities):
|
||||
"""Leon says some jokes"""
|
||||
|
||||
return utils.output('end', 'jokes', utils.translate('jokes'))
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
import utils
|
||||
|
||||
def meaningoflife(string, entities):
|
||||
def run(string, entities):
|
||||
"""Leon says what's the meaning of life"""
|
||||
|
||||
return utils.output('end', 'meaning_of_life', utils.translate('meaning_of_life'))
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
import utils
|
||||
|
||||
def partnerassistant(string, entities):
|
||||
def run(string, entities):
|
||||
"""Leon tells you about other personal assistants"""
|
||||
|
||||
string = string.lower()
|
||||
|
@ -4,7 +4,7 @@
|
||||
import utils
|
||||
from random import randint
|
||||
|
||||
def randomnumber(string, entities):
|
||||
def run(string, entities):
|
||||
"""Leon gives a random number"""
|
||||
|
||||
return utils.output('end', 'success', randint(0, 100))
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
import utils
|
||||
|
||||
def welcome(string, entities):
|
||||
def run(string, entities):
|
||||
"""Leon welcomes you"""
|
||||
|
||||
return utils.output('end', 'welcome', utils.translate('welcome'))
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
import utils
|
||||
|
||||
def whoami(string, entities):
|
||||
def run(string, entities):
|
||||
"""Leon introduces himself"""
|
||||
|
||||
return utils.output('end', 'introduction', utils.translate('introduction'))
|
||||
|
@ -1,10 +1,14 @@
|
||||
{
|
||||
"speedtest": [
|
||||
"What is my current Internet speed?",
|
||||
"Can you make me a speedtest?",
|
||||
"Make a speedtest",
|
||||
"Start a speed test",
|
||||
"Is my Internet network good?",
|
||||
"Is my Internet connection good?"
|
||||
]
|
||||
"speedtest": {
|
||||
"run": {
|
||||
"expressions": [
|
||||
"What is my current Internet speed?",
|
||||
"Can you make me a speedtest?",
|
||||
"Make a speedtest",
|
||||
"Start a speed test",
|
||||
"Is my Internet network good?",
|
||||
"Is my Internet connection good?"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,14 @@
|
||||
{
|
||||
"speedtest": [
|
||||
"Quelle est ma vitesse Internet actuelle?",
|
||||
"Peux-tu me faire un speedtest ?",
|
||||
"Fais un speedtest",
|
||||
"Lance-moi un test de vitesse",
|
||||
"Mon réseau Internet est-il bon ?",
|
||||
"Ma connexion Internet est-elle bonne ?"
|
||||
]
|
||||
"speedtest": {
|
||||
"run": {
|
||||
"expressions": [
|
||||
"Quelle est ma vitesse Internet actuelle?",
|
||||
"Peux-tu me faire un speedtest ?",
|
||||
"Fais un speedtest",
|
||||
"Lance-moi un test de vitesse",
|
||||
"Mon réseau Internet est-il bon ?",
|
||||
"Ma connexion Internet est-elle bonne ?"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ import sys
|
||||
import subprocess
|
||||
import re
|
||||
|
||||
def speedtest(string, entities):
|
||||
def run(string, entities):
|
||||
"""The SpeedTest package will give you information about your network speed """
|
||||
|
||||
utils.output('inter', 'testing', utils.translate('testing'))
|
||||
|
@ -1,19 +1,27 @@
|
||||
{
|
||||
"github": [
|
||||
"What are the trends on GitHub?",
|
||||
"Give me the GitHub trends",
|
||||
"What's trending on GitHub?",
|
||||
"What are the trends on GH?",
|
||||
"Give me the GH trends",
|
||||
"What's trending on GH?"
|
||||
],
|
||||
"producthunt": [
|
||||
"What are the trends on Product Hunt?",
|
||||
"Give me the Product Hunt trends",
|
||||
"What's trending on Product Hunt?",
|
||||
"What are the trends on PH?",
|
||||
"Give me the PH trends",
|
||||
"What's trending on PH?",
|
||||
"What's trending on ProductHunt?"
|
||||
]
|
||||
"github": {
|
||||
"run": {
|
||||
"expressions": [
|
||||
"What are the trends on GitHub?",
|
||||
"Give me the GitHub trends",
|
||||
"What's trending on GitHub?",
|
||||
"What are the trends on GH?",
|
||||
"Give me the GH trends",
|
||||
"What's trending on GH?"
|
||||
]
|
||||
}
|
||||
},
|
||||
"producthunt": {
|
||||
"run": {
|
||||
"expressions": [
|
||||
"What are the trends on Product Hunt?",
|
||||
"Give me the Product Hunt trends",
|
||||
"What's trending on Product Hunt?",
|
||||
"What are the trends on PH?",
|
||||
"Give me the PH trends",
|
||||
"What's trending on PH?",
|
||||
"What's trending on ProductHunt?"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +1,25 @@
|
||||
{
|
||||
"github": [
|
||||
"Quelles sont les tendances sur GitHub ?",
|
||||
"Donne-moi les tendances GitHub",
|
||||
"Qu'est-ce qu'il y a en tendance sur GitHub ?",
|
||||
"Quelles sont les tendances sur GH ?",
|
||||
"Donne-moi les tendances GH",
|
||||
"Qu'est-ce qu'il y a en tendance sur GH ?"
|
||||
],
|
||||
"producthunt": [
|
||||
"Quelles sont les tendances sur Product Hunt ?",
|
||||
"Donne-moi les tendances Product Hunt",
|
||||
"Qu'est-ce qu'il y a en tendance sur Product Hunt ?",
|
||||
"Quelles sont les tendances sur PH ?",
|
||||
"Donne-moi les tendances PH",
|
||||
"Qu'est-ce qu'il y a en tendance sur PH ?"
|
||||
]
|
||||
"github": {
|
||||
"run": {
|
||||
"expressions": ["Quelles sont les tendances sur GitHub ?",
|
||||
"Donne-moi les tendances GitHub",
|
||||
"Qu'est-ce qu'il y a en tendance sur GitHub ?",
|
||||
"Quelles sont les tendances sur GH ?",
|
||||
"Donne-moi les tendances GH",
|
||||
"Qu'est-ce qu'il y a en tendance sur GH ?"
|
||||
]
|
||||
}
|
||||
},
|
||||
"producthunt": {
|
||||
"run": {
|
||||
"expressions": [
|
||||
"Quelles sont les tendances sur Product Hunt ?",
|
||||
"Donne-moi les tendances Product Hunt",
|
||||
"Qu'est-ce qu'il y a en tendance sur Product Hunt ?",
|
||||
"Quelles sont les tendances sur PH ?",
|
||||
"Donne-moi les tendances PH",
|
||||
"Qu'est-ce qu'il y a en tendance sur PH ?"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import packages.trend.github_lang as github_lang
|
||||
from re import search, escape
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
def github(string, entities):
|
||||
def run(string, entities):
|
||||
"""Grab the GitHub trends"""
|
||||
|
||||
# Number of repositories
|
||||
|
@ -4,7 +4,7 @@
|
||||
import requests
|
||||
import utils
|
||||
|
||||
def producthunt(string, entities):
|
||||
def run(string, entities):
|
||||
"""Grab the Product Hunt trends"""
|
||||
|
||||
# Developer token
|
||||
|
@ -1,5 +1,9 @@
|
||||
{
|
||||
"youtube": [
|
||||
"Download new videos from YouTube"
|
||||
]
|
||||
"youtube": {
|
||||
"run": {
|
||||
"expressions": [
|
||||
"Download new videos from YouTube"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,9 @@
|
||||
{
|
||||
"youtube": [
|
||||
"Télécharges les nouvelles vidéos depuis YouTube"
|
||||
]
|
||||
"youtube": {
|
||||
"run": {
|
||||
"expressions": [
|
||||
"Télécharges les nouvelles vidéos depuis YouTube"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import utils
|
||||
from time import time
|
||||
from pytube import YouTube
|
||||
|
||||
def youtube(string, entities):
|
||||
def run(string, entities):
|
||||
"""Download new videos from a YouTube playlist"""
|
||||
|
||||
db = utils.db()['db']
|
||||
|
@ -1 +1 @@
|
||||
{"lang":"en","package":"leon","module":"randomnumber","query":"Give me a random number","entities":[]}
|
||||
{"lang":"en","package":"leon","module":"randomnumber","action":"run","query":"Give me a random number","entities":[]}
|
||||
|
@ -39,21 +39,30 @@ export default () => new Promise(async (resolve, reject) => {
|
||||
const packages = fs.readdirSync(packagesDir)
|
||||
.filter(entity =>
|
||||
fs.statSync(path.join(packagesDir, entity)).isDirectory())
|
||||
let expressions = { }
|
||||
let expressionsObj = { }
|
||||
|
||||
for (let i = 0; i < packages.length; i += 1) {
|
||||
log.info(`Training "${string.ucfirst(packages[i])}" package modules expressions...`)
|
||||
|
||||
expressions = JSON.parse(fs.readFileSync(`${packagesDir}/${packages[i]}/data/expressions/${lang}.json`, 'utf8'))
|
||||
expressionsObj = JSON.parse(fs.readFileSync(`${packagesDir}/${packages[i]}/data/expressions/${lang}.json`, 'utf8'))
|
||||
|
||||
const modules = Object.keys(expressions)
|
||||
const modules = Object.keys(expressionsObj)
|
||||
for (let j = 0; j < modules.length; j += 1) {
|
||||
const exprs = expressions[modules[j]]
|
||||
for (let k = 0; k < exprs.length; k += 1) {
|
||||
manager.addDocument(lang, exprs[k], `${packages[i]}:${modules[j]}`)
|
||||
const module = modules[j]
|
||||
const actions = Object.keys(expressionsObj[module])
|
||||
|
||||
for (let k = 0; k < actions.length; k += 1) {
|
||||
const action = actions[k]
|
||||
const exprs = expressionsObj[module][action].expressions
|
||||
|
||||
manager.assignDomain(lang, `${module}.${action}`, packages[i])
|
||||
|
||||
for (let l = 0; l < exprs.length; l += 1) {
|
||||
manager.addDocument(lang, exprs[l], `${module}.${action}`)
|
||||
}
|
||||
}
|
||||
|
||||
log.success(`"${string.ucfirst(modules[j])}" module expressions trained`)
|
||||
log.success(`"${string.ucfirst(module)}" module expressions trained`)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -121,6 +121,7 @@ class Brain {
|
||||
lang: langs[process.env.LEON_LANG].short,
|
||||
package: obj.classification.package,
|
||||
module: obj.classification.module,
|
||||
action: obj.classification.action,
|
||||
query: obj.query,
|
||||
entities: obj.entities
|
||||
}
|
||||
|
@ -70,15 +70,15 @@ class Nlu {
|
||||
}
|
||||
|
||||
const result = await this.classifier.process(langs[process.env.LEON_LANG].short, query)
|
||||
const { intent, score, entities } = result
|
||||
const packageName = intent.substr(0, intent.indexOf(':'))
|
||||
const moduleName = intent.substr(intent.indexOf(':') + 1)
|
||||
const { domain, intent, score, entities } = result
|
||||
const [moduleName, actionName] = intent.split('.')
|
||||
let obj = {
|
||||
query,
|
||||
entities,
|
||||
classification: {
|
||||
package: packageName,
|
||||
package: domain,
|
||||
module: moduleName,
|
||||
action: actionName,
|
||||
confidence: score
|
||||
}
|
||||
}
|
||||
@ -148,6 +148,7 @@ class Nlu {
|
||||
if (JSON.stringify(tmpWords) === JSON.stringify(fallbacks[i].words)) {
|
||||
obj.classification.package = fallbacks[i].package
|
||||
obj.classification.module = fallbacks[i].module
|
||||
obj.classification.action = fallbacks[i].action
|
||||
obj.classification.confidence = 1
|
||||
|
||||
log.success('Fallback found')
|
||||
|
@ -43,7 +43,8 @@ class Synchronizer {
|
||||
return new Promise((resolve) => {
|
||||
this.brain.socket.emit('download', {
|
||||
package: this.classification.package,
|
||||
module: this.classification.module
|
||||
module: this.classification.module,
|
||||
action: this.classification.action
|
||||
})
|
||||
|
||||
resolve()
|
||||
|
@ -2,6 +2,7 @@
|
||||
"lang": "en",
|
||||
"package": "checker",
|
||||
"module": "isitdown",
|
||||
"action": "run",
|
||||
"query": "Check if github.com, mozilla.org and twitter.com are up",
|
||||
"entities": [
|
||||
{
|
||||
|
@ -30,7 +30,7 @@ describe('NLU modules', () => {
|
||||
const lang = langs[langKeys[i]]
|
||||
const nlu = new Nlu()
|
||||
const brain = new Brain({ emit: jest.fn() }, lang.short)
|
||||
let expressions = { }
|
||||
let expressionsObj = { }
|
||||
|
||||
nlu.brain = { wernicke: jest.fn(), talk: jest.fn(), socket: { emit: jest.fn() } }
|
||||
brain.talk = jest.fn()
|
||||
@ -48,26 +48,32 @@ describe('NLU modules', () => {
|
||||
// eslint-disable-next-line no-loop-func
|
||||
describe(`${packages[j]} package`, () => {
|
||||
const expressionsFile = `${global.paths.packages}/${packages[j]}/data/expressions/${lang.short}.json`
|
||||
expressions = JSON.parse(fs.readFileSync(expressionsFile, 'utf8'))
|
||||
expressionsObj = JSON.parse(fs.readFileSync(expressionsFile, 'utf8'))
|
||||
|
||||
const modules = Object.keys(expressions)
|
||||
const modules = Object.keys(expressionsObj)
|
||||
for (let k = 0; k < modules.length; k += 1) {
|
||||
const module = modules[k]
|
||||
const actions = Object.keys(expressionsObj[module])
|
||||
|
||||
// eslint-disable-next-line no-loop-func
|
||||
describe(`${modules[k]} module`, () => {
|
||||
const exprs = expressions[modules[k]]
|
||||
describe(`${module} module`, () => {
|
||||
for (let l = 0; l < actions.length; l += 1) {
|
||||
const action = actions[l]
|
||||
const exprs = expressionsObj[module][action].expressions
|
||||
|
||||
for (let l = 0; l < exprs.length; l += 1) {
|
||||
// eslint-disable-next-line no-loop-func
|
||||
test(`"${exprs[l]}" queries this module`, async () => {
|
||||
// Need to redefine the NLU brain execution to update the mocking
|
||||
nlu.brain.execute = jest.fn()
|
||||
for (let m = 0; m < exprs.length; m += 1) {
|
||||
// eslint-disable-next-line no-loop-func
|
||||
test(`"${exprs[m]}" queries this module`, async () => {
|
||||
// Need to redefine the NLU brain execution to update the mocking
|
||||
nlu.brain.execute = jest.fn()
|
||||
|
||||
await nlu.process(exprs[l])
|
||||
const [obj] = nlu.brain.execute.mock.calls
|
||||
await nlu.process(exprs[m])
|
||||
const [obj] = nlu.brain.execute.mock.calls
|
||||
|
||||
expect(obj[0].classification.package).toBe(packages[j])
|
||||
expect(obj[0].classification.module).toBe(modules[k])
|
||||
})
|
||||
expect(obj[0].classification.package).toBe(packages[j])
|
||||
expect(obj[0].classification.module).toBe(module)
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -71,6 +71,7 @@ describe('brain', () => {
|
||||
classification: {
|
||||
package: 'leon',
|
||||
module: 'greeting',
|
||||
action: 'run',
|
||||
confidence: 0.9
|
||||
}
|
||||
}
|
||||
@ -97,6 +98,7 @@ describe('brain', () => {
|
||||
classification: {
|
||||
package: 'checker',
|
||||
module: 'isitdown',
|
||||
action: 'run',
|
||||
confidence: 0.9
|
||||
}
|
||||
}
|
||||
@ -116,6 +118,7 @@ describe('brain', () => {
|
||||
classification: {
|
||||
package: 'leon',
|
||||
module: 'greeting',
|
||||
action: 'run',
|
||||
confidence: 0.9
|
||||
}
|
||||
}
|
||||
|
@ -94,8 +94,8 @@ describe('NLU', () => {
|
||||
}
|
||||
|
||||
expect(Nlu.fallback(obj, [
|
||||
{ words: ['query', 'example', 'test', 'fallbacks'], package: 'fake-pkg', module: 'fake-module' }
|
||||
]).classification).toContainEntries([['package', 'fake-pkg'], ['module', 'fake-module'], ['confidence', 1]])
|
||||
{ words: ['query', 'example', 'test', 'fallbacks'], package: 'fake-pkg', module: 'fake-module', action: 'fake-action' }
|
||||
]).classification).toContainEntries([['package', 'fake-pkg'], ['module', 'fake-module'], ['action', 'fake-action'], ['confidence', 1]])
|
||||
})
|
||||
})
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user