mirror of
https://github.com/leon-ai/leon.git
synced 2024-09-11 10:25:40 +03:00
feat(server): introduce actions module
This commit is contained in:
parent
e5f2996e5f
commit
b449376f61
@ -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'],
|
||||
|
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
13
packages/calendar/data/answers/en.json
Normal file
13
packages/calendar/data/answers/en.json
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
"todolist": {
|
||||
"list_created": [
|
||||
"I created the %list% list."
|
||||
],
|
||||
"todo_added": [
|
||||
"I added %todo% to your %list% list."
|
||||
],
|
||||
"todo_deleted": [
|
||||
"I deleted %todo% from your %list% list."
|
||||
]
|
||||
}
|
||||
}
|
10
packages/calendar/data/answers/fr.json
Normal file
10
packages/calendar/data/answers/fr.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"todolist": {
|
||||
"added": [
|
||||
"J'ai ajouté %thing% à votre liste %list%."
|
||||
],
|
||||
"deleted": [
|
||||
"J'ai retiré %thing% 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
26
packages/calendar/data/expressions/en.json
Normal file
26
packages/calendar/data/expressions/en.json
Normal file
@ -0,0 +1,26 @@
|
||||
{
|
||||
"todolist": {
|
||||
"create_list": {
|
||||
"expressions": [
|
||||
"Create the named list"
|
||||
]
|
||||
},
|
||||
"add_todo": {
|
||||
"expressions": [
|
||||
"Add something to my named list"
|
||||
],
|
||||
"conditions": {
|
||||
"between": [
|
||||
{
|
||||
"test": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"delete_todo": {
|
||||
"expressions": [
|
||||
"Delete something from my named list"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
5
packages/calendar/data/expressions/fr.json
Normal file
5
packages/calendar/data/expressions/fr.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"todolist": [
|
||||
"Ajoute quelque chose à ma liste nommée"
|
||||
]
|
||||
}
|
23
packages/calendar/test/haveibeenpwned.spec.js
Normal file
23
packages/calendar/test/haveibeenpwned.spec.js
Normal file
@ -0,0 +1,23 @@
|
||||
'use strict'
|
||||
|
||||
describe('checker:haveibeenpwned', async () => {
|
||||
test('checks if an email address has been pwned', async () => {
|
||||
global.nlu.brain.execute = jest.fn()
|
||||
await global.nlu.process('Has supercleanemailaddress@supercleandomainname.com been pwned?')
|
||||
|
||||
const [obj] = global.nlu.brain.execute.mock.calls
|
||||
await global.brain.execute(obj[0])
|
||||
|
||||
expect(global.brain.finalOutput.codes).toIncludeSameMembers(['checking', 'no-pwnage'])
|
||||
})
|
||||
|
||||
test('checks if multiple email addresses have been pwned', async () => {
|
||||
global.nlu.brain.execute = jest.fn()
|
||||
await global.nlu.process('Verify the pwnage status of supercleanemailaddress@supercleandomainname.com and test@toto.com')
|
||||
|
||||
const [obj] = global.nlu.brain.execute.mock.calls
|
||||
await global.brain.execute(obj[0])
|
||||
|
||||
expect(global.brain.finalOutput.codes).toIncludeSameMembers(['checking', 'no-pwnage', 'pwned'])
|
||||
})
|
||||
})
|
57
packages/calendar/test/isitdown.spec.js
Normal file
57
packages/calendar/test/isitdown.spec.js
Normal file
@ -0,0 +1,57 @@
|
||||
'use strict'
|
||||
|
||||
describe('checker:isitdown', async () => {
|
||||
test('detects invalid domain name', async () => {
|
||||
global.nlu.brain.execute = jest.fn()
|
||||
await global.nlu.process('Check if github is up')
|
||||
|
||||
const [obj] = global.nlu.brain.execute.mock.calls
|
||||
await global.brain.execute(obj[0])
|
||||
|
||||
expect(global.brain.finalOutput.codes).toIncludeSameMembers(['invalid_domain_name'])
|
||||
})
|
||||
|
||||
test('detects down domain name', async () => {
|
||||
global.nlu.brain.execute = jest.fn()
|
||||
await global.nlu.process('Check if fakedomainnametotestleon.fr is up')
|
||||
|
||||
const [obj] = global.nlu.brain.execute.mock.calls
|
||||
await global.brain.execute(obj[0])
|
||||
|
||||
expect(global.brain.finalOutput.codes).toIncludeSameMembers([
|
||||
'checking',
|
||||
'down',
|
||||
'done'
|
||||
])
|
||||
})
|
||||
|
||||
test('detects up domain name', async () => {
|
||||
global.nlu.brain.execute = jest.fn()
|
||||
await global.nlu.process('Check if github.com is up')
|
||||
|
||||
const [obj] = global.nlu.brain.execute.mock.calls
|
||||
await global.brain.execute(obj[0])
|
||||
|
||||
expect(global.brain.finalOutput.codes).toIncludeSameMembers([
|
||||
'checking',
|
||||
'up',
|
||||
'done'
|
||||
])
|
||||
})
|
||||
|
||||
test('detects up domain names', async () => {
|
||||
global.nlu.brain.execute = jest.fn()
|
||||
await global.nlu.process('Check if github.com and nodejs.org are up')
|
||||
|
||||
const [obj] = global.nlu.brain.execute.mock.calls
|
||||
await global.brain.execute(obj[0])
|
||||
|
||||
expect(global.brain.finalOutput.codes).toIncludeSameMembers([
|
||||
'checking',
|
||||
'up',
|
||||
'checking',
|
||||
'up',
|
||||
'done'
|
||||
])
|
||||
})
|
||||
})
|
26
packages/calendar/todolist.py
Normal file
26
packages/calendar/todolist.py
Normal file
@ -0,0 +1,26 @@
|
||||
#!/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': 'test' }))
|
||||
|
||||
def add_todo(string, entities):
|
||||
"""WIP"""
|
||||
|
||||
return utils.output('end', 'todo_added', utils.translate('todo_added', {
|
||||
'list': 'test',
|
||||
'todo': 'todo 1'
|
||||
}))
|
||||
|
||||
def delete_todo(string, entities):
|
||||
"""WIP"""
|
||||
|
||||
return utils.output('end', 'todo_deleted', utils.translate('todo_deleted', {
|
||||
'list': 'test',
|
||||
'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
|
||||
}
|
||||
}
|
||||
|
@ -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": [
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user