1
1
mirror of https://github.com/leon-ai/leon.git synced 2024-11-28 04:04:58 +03:00

build: merge To-Do List module

This commit is contained in:
Louistiti 2019-06-08 15:18:24 +08:00
commit d91a62ea7e
16 changed files with 1018 additions and 94 deletions

View File

@ -50,6 +50,10 @@ a {
color: inherit;
}
ul li {
margin-left: 20px;
}
body {
color: #FFF;
background-color: #151718;

View File

@ -116,5 +116,6 @@ def db(dbtype = 'tinydb'):
for a specific package"""
if dbtype == 'tinydb':
db = TinyDB(dirname + '/../../packages/' + queryobj['package'] + '/data/db/' + queryobj['package'] + '.json')
ext = '.json' if environ.get('LEON_NODE_ENV') != 'testing' else '.spec.json'
db = TinyDB(dirname + '/../../packages/' + queryobj['package'] + '/data/db/' + queryobj['package'] + ext)
return { 'db': db, 'query': Query, 'operations': operations }

View File

@ -1,19 +1,52 @@
# Calendar Package
WIP...
The calendar package contains modules related to your plans (what's next, schedule, things need to be done, etc.).
## Modules
### To-Do List
WIP...
Manage your to-do lists:
- Create a list
- View your lists
- View a specific list
- Rename a list
- Delete a list
- Add todos
- Complete todos
- Uncheck todos
#### Usage
WIP...
```
(en-US) "..."
(en-US) "Show all my lists"
(en-US) "Add 7 potatoes, 1kg of rice, bread to the shopping list"
(en-US) "Complete rice from my shopping list"
(en-US) "Check bread from the shopping list"
(en-US) "What is in my shopping list?"
(en-US) "Create a movies list"
(en-US) "Add Captain America: Civil War to my movies list"
(en-US) "What are my lists?"
(en-US) "Rename the movies list to cinema"
(en-US) "Check Captain America from the cinema list"
(en-US) "What is in my cinema list?"
(en-US) "Uncheck Captain America from my cinema list"
(en-US) "Please tell me what is in my cinema list"
(en-US) "Delete my cinema list"
(en-US) "Show my lists"
(fr-FR) "..."
(fr-FR) "Show my lists"
(fr-FR) "Ajoute 7 pommes de terre, 1kg de riz, pain à la liste courses"
(fr-FR) "Complète riz de la liste courses"
(fr-FR) "Coche pain de la liste courses"
(fr-FR) "Qu'est-ce qu'il y a dans ma liste courses ?"
(fr-FR) "Crée une liste films"
(fr-FR) "Ajoute Captain America : Guerre Civile à ma liste films"
(fr-FR) "Quelles sont mes listes ?"
(fr-FR) "Renomme la liste films en cinéma"
(fr-FR) "Qu'est-ce qu'il y a dans ma liste cinéma ?"
(fr-FR) "Décoche Captain America de ma liste cinéma"
(fr-FR) "Montre ma liste cinéma"
(fr-FR) "Supprime ma liste cinéma"
(fr-FR) "Montre mes listes"
```

View File

@ -1,25 +1,81 @@
{
"todolist": {
"list_created": [
"I created the \"%list%\" list."
"Alright, I've created the \"%list%\" list.",
"Done, I created your \"%list%\" list."
],
"list_not_provided": [
"Please provide me a list name.",
"Please provide the name of the list you wish to create."
],
"todos_not_provided": [
"Please provide me items I should add to your list.",
"Please provide elements you want to add to the list."
],
"new_or_old_list_not_provided": [
"Please make sure you provide the list name to rename and its new list name.",
"Please provide the list name to rename and its new list name."
],
"no_list": [
"You do not have any list.",
"There is no list to show."
],
"empty_list": [
"Your \"%list%\" list is empty.",
"There is nothing in your \"%list%\" list."
],
"list_does_not_exist": [
"Sorry I can't because the \"%list%\" does not exist.",
"I cannot do that because the \"%list%\" does not exist."
],
"list_already_exists": [
"You already have a list named \"%list%\"."
],
"list_renamed": [
"I renamed the \"%old_list%\" list to \"%new_list%\" list."
"I renamed the \"%old_list%\" list to \"%new_list%\"."
],
"list_deleted": [
"I deleted the \"%list%\" list and all the todos it contained."
"I deleted the \"%list%\" list and all the todos it was containing."
],
"todo_added": [
"I added \"%todo%\" to your \"%list%\" list."
"lists_listed": [
"You have %lists_nb% lists. Please let me list them below for you:<br><br><ul>%result%</ul>"
],
"todo_completed": [
"I completed \"%todo%\" from your \"%list%\" list, congrats!"
"list_list_element": [
"<li>\"%list%\", with %todos_nb% elements in it.</li>",
"<li>\"%list%\", that contains %todos_nb% items.</li>"
],
"todo_archived": [
"I archived \"%todo%\" from your \"%list%\" list."
"no_unchecked_todo": [
"You do not have in progress element in your \"%list%\" list.",
"You don't have any in progress element in your \"%list%\" list."
],
"no_completed_todo": [
"And you do not have completed element in your \"%list%\" list.",
"And you don't have any completed element in your \"%list%\" list."
],
"unchecked_todos_listed": [
"Here are the in progress elements of your \"%list%\" list:<br><br><ul>%result%</ul><br>Stay motivated!",
"Please find the in progress elements of your \"%list%\" list below:<br><br><ul>%result%</ul><br>Keep going!"
],
"completed_todos_listed": [
"And here are the completed elements of your \"%list%\" list:<br><br><ul>%result%</ul>"
],
"list_todo_element": [
"<li>%todo%.</li>"
],
"list_completed_todo_element": [
"<li><strike>%todo%</strike>.</li>"
],
"todos_added": [
"Alright, I added the following to your \"%list%\" list:<br><br><ul>%result%</ul>",
"The following have been added to your \"%list%\" list:<br><br><ul>%result%</ul>"
],
"todos_unchecked": [
"I unchecked the following from your \"%list%\" list:<br><br><ul>%result%</ul>",
"The following have been unchecked from your \"%list%\" list:<br><br><ul>%result%</ul>"
],
"todos_completed": [
"Keep going! I completed the following from your \"%list%\" list:<br><br><ul>%result%</ul>",
"Well done! The following have been completed from your \"%list%\" list:<br><br><ul>%result%</ul>"
]
}
}

View File

@ -1,25 +1,81 @@
{
"todolist": {
"list_created": [
"J'ai créé la liste \"%list%\"."
"Entendu, j'ai créé la liste \"%list%\".",
"C'est fait, j'ai créé votre liste \"%list%\"."
],
"list_not_provided": [
"Merci de me fournir un nom de liste.",
"Merci de fournir le nom de la liste que vous souhaitez créer."
],
"todos_not_provided": [
"Merci de me fournir les éléments que je dois ajouter à votre liste.",
"Merci de fournir les éléments que vous souhaitez ajouter à la liste."
],
"new_or_old_list_not_provided": [
"Merci de vous assurer d'avoir fourni le nom de la liste à renommer et son nouveau nom.",
"Merci de fournir le nom de la liste à renommer ainsi que son nouveau nom."
],
"no_list": [
"Je n'ai trouvé aucune liste.",
"Il n'y a pas de liste à montrer."
],
"empty_list": [
"Votre liste \"%list%\" est vide.",
"Il n'y a rien dans votre liste \"%list%\"."
],
"list_does_not_exist": [
"Désolé je ne peux pas car la liste \"%list%\" n'éxiste pas.",
"Je ne peux pas parce que la liste \"%list%\" n'éxiste pas."
],
"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%\"."
"J'ai renommé la liste \"%old_list%\" en \"%new_list%\"."
],
"list_deleted": [
"J'ai supprimé la liste \"%list%\" et toutes les tâches qu'elle contenait."
"J'ai supprimé la liste \"%list%\" et tous les éléments qu'elle contenait."
],
"todo_added": [
"J'ai ajouté la tâche \"%todo%\" à votre liste \"%list%\"."
"lists_listed": [
"Vous avez %lists_nb% listes. Permettez-moi de vous les lister :<br><br><ul>%result%</ul>"
],
"todo_completed": [
"J'ai complété la tâche \"%todo%\" de votre liste \"%list%\", bravo !"
"list_list_element": [
"<li>\"%list%\", avec %todos_nb% éléments.</li>",
"<li>\"%list%\", contenant %todos_nb% éléments.</li>"
],
"todo_archived": [
"J'ai archivé la tâche \"%todo%\" de votre liste \"%list%\"."
"no_unchecked_todo": [
"Vous n'avez pas d'élément en attente dans votre liste \"%list%\".",
"Vous n'avez aucun élément en attente dans votre liste \"%list%\"."
],
"no_completed_todo": [
"Et vous n'avez pas d'élément complété dans votre liste \"%list%\".",
"Et vous n'avez aucun élément complété dans votre liste \"%list%\"."
],
"unchecked_todos_listed": [
"Voici les éléments en attente de votre liste \"%list%\" :<br><br><ul>%result%</ul><br>Restez motivé !",
"Voici les éléments en attente de votre liste \"%list%\" :<br><br><ul>%result%</ul><br>Continuez ainsi !"
],
"completed_todos_listed": [
"Et voici les éléments complétés de votre liste \"%list%\" :<br><br><ul>%result%</ul>"
],
"list_todo_element": [
"<li>%todo%.</li>"
],
"list_completed_todo_element": [
"<li><strike>%todo%</strike>.</li>"
],
"todos_added": [
"Entendu, j'ai ajouté ceci à votre liste \"%list%\" :<br><br><ul>%result%</ul>",
"Ce qui suit vient d'être ajouté à votre liste \"%list%\" :<br><br><ul>%result%</ul>"
],
"todos_unchecked": [
"J'ai décomplété ceci de votre liste \"%list%\" :<br><br><ul>%result%</ul>",
"Ce qui suit vient d'être décomplété de votre liste \"%list%\" :<br><br><ul>%result%</ul>"
],
"todos_completed": [
"Continue ainsi ! J'ai complété ceci de votre liste \"%list%\" :<br><br><ul>%result%</ul>",
"Bien joué ! Ce qui suit vient d'être complété de votre liste \"%list%\" :<br><br><ul>%result%</ul>"
]
}
}

View File

@ -34,34 +34,219 @@
}
]
},
"view_lists": {
"expressions": [
"Show all the lists",
"Show all my lists",
"What are the lists?",
"What are my lists?"
]
},
"view_list": {
"expressions": [
"Show my list",
"Show the list",
"What is in my list?",
"What is in the list?"
],
"entities": [
{
"type": "trim",
"name": "list",
"conditions": [
{
"type": "between",
"from": "the",
"to": "list"
},
{
"type": "between",
"from": "my",
"to": "list"
}
]
}
]
},
"rename_list": {
"expressions": [
"Rename the list to list",
"Rename my list to list"
"Rename the list to",
"Rename my list to"
],
"entities": [
{
"type": "trim",
"name": "old_list",
"conditions": [
{
"type": "between",
"from": "the",
"to": "list"
},
{
"type": "between",
"from": "my",
"to": "list"
}
]
},
{
"type": "trim",
"name": "new_list",
"conditions": [
{
"type": "after",
"from": "to"
}
]
}
]
},
"delete_list": {
"expressions": [
"Delete the list",
"Delete my list"
],
"entities": [
{
"type": "trim",
"name": "list",
"conditions": [
{
"type": "between",
"from": "the",
"to": "list"
},
{
"type": "between",
"from": "my",
"to": "list"
}
]
}
]
},
"add_todo": {
"add_todos": {
"expressions": [
"Add to the list",
"Add to my list"
],
"entities": [
{
"type": "trim",
"name": "todos",
"conditions": [
{
"type": "between",
"from": "add",
"to": "to"
}
]
},
{
"type": "trim",
"name": "list",
"conditions": [
{
"type": "between",
"from": "the",
"to": "list"
},
{
"type": "between",
"from": "my",
"to": "list"
}
]
}
]
},
"complete_todo": {
"complete_todos": {
"expressions": [
"Complete from the list",
"Complete from my list"
"Check from the list",
"Check from my list",
"Complete from my list",
"Tick from my list"
],
"entities": [
{
"type": "trim",
"name": "todos",
"conditions": [
{
"type": "between",
"from": "check",
"to": "from"
},
{
"type": "between",
"from": "complete",
"to": "from"
},
{
"type": "between",
"from": "tick",
"to": "from"
}
]
},
{
"type": "trim",
"name": "list",
"conditions": [
{
"type": "between",
"from": "the",
"to": "list"
},
{
"type": "between",
"from": "my",
"to": "list"
}
]
}
]
},
"archive_todo": {
"uncheck_todos": {
"expressions": [
"Archive from the list",
"Archive from my list"
"Uncheck from the list",
"Uncheck from my list",
"Untick from my list"
],
"entities": [
{
"type": "trim",
"name": "todos",
"conditions": [
{
"type": "between",
"from": "uncheck",
"to": "from"
},
{
"type": "between",
"from": "untick",
"to": "from"
}
]
},
{
"type": "trim",
"name": "list",
"conditions": [
{
"type": "between",
"from": "the",
"to": "list"
},
{
"type": "between",
"from": "my",
"to": "list"
}
]
}
]
}
}

View File

@ -4,36 +4,201 @@
"expressions": [
"Crée la liste",
"Crée une liste"
],
"entities": [
{
"type": "trim",
"name": "list",
"conditions": [
{
"type": "after_last",
"from": "liste"
}
]
}
]
},
"view_lists": {
"expressions": [
"Montre les listes",
"Montre mes listes",
"Quelles sont les listes ?",
"Quelles sont mes listes ?"
]
},
"view_list": {
"expressions": [
"Montre ma liste",
"Montre la liste",
"Qu'est-ce qu'il y a dans ma liste ?",
"Qu'est-ce qu'il y a dans la liste ?"
],
"entities": [
{
"type": "trim",
"name": "list",
"conditions": [
{
"type": "after_last",
"from": "liste"
}
]
}
]
},
"rename_list": {
"expressions": [
"Renomme la liste en liste",
"Renomme ma liste en liste"
"Renomme la liste en",
"Renomme ma liste en"
],
"entities": [
{
"type": "trim",
"name": "old_list",
"conditions": [
{
"type": "between",
"from": "liste",
"to": "en"
}
]
},
{
"type": "trim",
"name": "new_list",
"conditions": [
{
"type": "after_last",
"from": "en"
}
]
}
]
},
"delete_list": {
"expressions": [
"Supprime la liste",
"Supprime ma liste"
],
"entities": [
{
"type": "trim",
"name": "list",
"conditions": [
{
"type": "after_last",
"from": "liste"
}
]
}
]
},
"add_todo": {
"add_todos": {
"expressions": [
"Ajoute à la liste",
"Ajoute à ma liste"
],
"entities": [
{
"type": "trim",
"name": "todos",
"conditions": [
{
"type": "between",
"from": "ajoute",
"to": "à"
},
{
"type": "between",
"from": "ajoute",
"to": "a"
}
]
},
{
"type": "trim",
"name": "list",
"conditions": [
{
"type": "after_last",
"from": "liste"
}
]
}
]
},
"complete_todo": {
"complete_todos": {
"expressions": [
"Complète de la liste",
"Complete de ma liste"
"Coche de la liste",
"Coche de ma liste",
"Complète de ma liste"
],
"entities": [
{
"type": "trim",
"name": "todos",
"conditions": [
{
"type": "between",
"from": "coche",
"to": "de"
},
{
"type": "between",
"from": "complète",
"to": "de"
},
{
"type": "between",
"from": "complete",
"to": "de"
}
]
},
{
"type": "trim",
"name": "list",
"conditions": [
{
"type": "after_last",
"from": "liste"
}
]
}
]
},
"archive_todo": {
"uncheck_todos": {
"expressions": [
"Archive de la liste",
"Archive de ma liste"
"Décoche de la liste",
"Décoche de ma liste"
],
"entities": [
{
"type": "trim",
"name": "todos",
"conditions": [
{
"type": "between",
"from": "décoche",
"to": "de"
},
{
"type": "between",
"from": "decoche",
"to": "de"
}
]
},
{
"type": "trim",
"name": "list",
"conditions": [
{
"type": "after_last",
"from": "liste"
}
]
}
]
}
}

View File

@ -1,13 +0,0 @@
'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'])
})
})

View File

@ -0,0 +1,132 @@
'use strict'
import path from 'path'
import fs from 'fs'
describe('calendar:todolist', async () => {
// Once the tests are done, delete test DB file if it exists
afterAll(() => {
const pkgName = 'calendar'
const dbFile = path.join(__dirname, `../data/db/${pkgName}.spec.json`)
if (fs.existsSync(dbFile)) {
fs.unlinkSync(dbFile)
}
})
test('no list', async () => {
global.nlu.brain.execute = jest.fn()
await global.nlu.process('Show all my lists')
const [obj] = global.nlu.brain.execute.mock.calls
await global.brain.execute(obj[0])
expect(global.brain.finalOutput.codes).toIncludeSameMembers(['no_list'])
})
test('adds 3 todos and create a list', async () => {
global.nlu.brain.execute = jest.fn()
await global.nlu.process('Add 7 potatoes, 1kg of rice, bread to the shopping list')
const [obj] = global.nlu.brain.execute.mock.calls
await global.brain.execute(obj[0])
expect(global.brain.finalOutput.speech.split('</li>').length - 1).toBe(3)
expect(global.brain.finalOutput.speech.indexOf('"shopping" list')).not.toBe(-1)
expect(global.brain.finalOutput.codes).toIncludeSameMembers(['todos_added'])
})
test('completes a todo', async () => {
global.nlu.brain.execute = jest.fn()
await global.nlu.process('Complete rice from my shopping list')
const [obj] = global.nlu.brain.execute.mock.calls
await global.brain.execute(obj[0])
expect(global.brain.finalOutput.speech.split('</li>').length - 1).toBe(1)
expect(global.brain.finalOutput.speech.indexOf('"shopping" list')).not.toBe(-1)
expect(global.brain.finalOutput.speech.indexOf('<strike>1kg of rice</strike>')).not.toBe(-1)
expect(global.brain.finalOutput.codes).toIncludeSameMembers(['todos_completed'])
})
test('views a list', async () => {
global.nlu.brain.execute = jest.fn()
await global.nlu.process('What is in my shopping list?')
const [obj] = global.nlu.brain.execute.mock.calls
await global.brain.execute(obj[0])
expect(global.brain.interOutput.codes).toIncludeSameMembers(['unchecked_todos_listed'])
expect(global.brain.interOutput.speech.split('</li>').length - 1).toBe(2)
expect(global.brain.interOutput.speech.indexOf('"shopping" list')).not.toBe(-1)
expect(global.brain.interOutput.speech.indexOf('7 potatoes')).not.toBe(-1)
expect(global.brain.interOutput.speech.indexOf('bread')).not.toBe(-1)
expect(global.brain.finalOutput.speech.split('</li>').length - 1).toBe(1)
expect(global.brain.finalOutput.speech.indexOf('"shopping" list')).not.toBe(-1)
expect(global.brain.finalOutput.speech.indexOf('<strike>1kg of rice</strike>')).not.toBe(-1)
expect(global.brain.finalOutput.codes).toIncludeSameMembers([
'unchecked_todos_listed',
'completed_todos_listed'
])
})
test('creates a list', async () => {
global.nlu.brain.execute = jest.fn()
await global.nlu.process('Create the movies list')
const [obj] = global.nlu.brain.execute.mock.calls
await global.brain.execute(obj[0])
expect(global.brain.finalOutput.speech.indexOf('"movies" list')).not.toBe(-1)
expect(global.brain.finalOutput.codes).toIncludeSameMembers(['list_created'])
})
test('renames a list', async () => {
global.nlu.brain.execute = jest.fn()
await global.nlu.process('Rename the movies list to cinema')
const [obj] = global.nlu.brain.execute.mock.calls
await global.brain.execute(obj[0])
expect(global.brain.finalOutput.speech.indexOf('"movies" list')).not.toBe(-1)
expect(global.brain.finalOutput.speech.indexOf('to "cinema"')).not.toBe(-1)
expect(global.brain.finalOutput.codes).toIncludeSameMembers(['list_renamed'])
})
test('unchecks a todo', async () => {
global.nlu.brain.execute = jest.fn()
await global.nlu.process('Uncheck rice from the shopping list')
const [obj] = global.nlu.brain.execute.mock.calls
await global.brain.execute(obj[0])
expect(global.brain.finalOutput.speech.split('</li>').length - 1).toBe(1)
expect(global.brain.finalOutput.speech.indexOf('"shopping" list')).not.toBe(-1)
expect(global.brain.finalOutput.speech.indexOf('1kg of rice')).not.toBe(-1)
expect(global.brain.finalOutput.codes).toIncludeSameMembers(['todo_unchecked'])
})
test('deletes a list', async () => {
global.nlu.brain.execute = jest.fn()
await global.nlu.process('Delete the cinema list')
const [obj] = global.nlu.brain.execute.mock.calls
await global.brain.execute(obj[0])
expect(global.brain.finalOutput.speech.indexOf('"cinema" list')).not.toBe(-1)
expect(global.brain.finalOutput.codes).toIncludeSameMembers(['list_deleted'])
})
test('views all lists', async () => {
global.nlu.brain.execute = jest.fn()
await global.nlu.process('Show all my lists')
const [obj] = global.nlu.brain.execute.mock.calls
await global.brain.execute(obj[0])
expect(global.brain.finalOutput.speech.split('</li>').length - 1).toBe(1)
expect(global.brain.finalOutput.speech.indexOf('"shopping"')).not.toBe(-1)
expect(global.brain.finalOutput.speech.indexOf('3')).not.toBe(-1)
expect(global.brain.finalOutput.codes).toIncludeSameMembers(['lists_listed'])
})
})

View File

@ -3,45 +3,347 @@
import requests
import utils
from time import time
# Package database
db = utils.db()['db']
# Lists of the module table
db_lists = db.table('todo_lists')
# Todos of the module table
db_todos = db.table('todo_todos')
# Query
Query = utils.db()['query']()
# Time stamp
timestamp = int(time())
def create_list(string, entities):
"""WIP"""
"""Create a to-do list"""
return utils.output('end', 'list_created', utils.translate('list_created', { 'list': 'fake' }))
# List name
listname = ''
# Find entities
for item in entities:
if item['entity'] == 'list':
listname = item['sourceText'].lower()
# Verify if a list name has been provided
if not listname:
return utils.output('end', 'list_not_provided', utils.translate('list_not_provided'))
# Verify if list already exists or not
if db_lists.count(Query.name == listname) > 0:
return utils.output('end', 'list_already_exists', utils.translate('list_already_exists', { 'list': listname }))
dbCreateList(listname)
return utils.output('end', 'list_created', utils.translate('list_created', { 'list': listname }))
def view_lists(string, entities):
"""View to-do lists"""
# Lists number
lists_nb = len(db_lists)
# Verify if a list exists
if lists_nb == 0:
return utils.output('end', 'no_list', utils.translate('no_list'))
result = ''
# Fill end-result
for listelement in db_lists:
result += utils.translate('list_list_element', {
'list': listelement['name'],
'todos_nb': db_todos.count(Query.list == listelement['name'])
})
return utils.output('end', 'lists_listed', utils.translate('lists_listed', {
'lists_nb': lists_nb,
'result': result
}
)
)
def view_list(string, entities):
"""View a to-do list"""
# List name
listname = ''
# Find entities
for item in entities:
if item['entity'] == 'list':
listname = item['sourceText'].lower()
# Verify if the list exists
if db_lists.count(Query.name == listname) == 0:
return utils.output('end', 'list_does_not_exist', utils.translate('list_does_not_exist', { 'list': listname }))
# Grab todos of the list
todos = db_todos.search(Query.list == listname)
if len(todos) == 0:
return utils.output('end', 'empty_list', utils.translate('empty_list', { 'list': listname }))
unchecked_todos = db_todos.search((Query.list == listname) & (Query.is_completed == False))
completed_todos = db_todos.search((Query.list == listname) & (Query.is_completed == True))
result_unchecked_todos = ''
result_completed_todos = ''
if len(unchecked_todos) == 0:
utils.output('inter', 'no_unchecked_todo', utils.translate('no_unchecked_todo', { 'list': listname }))
else:
for todo in unchecked_todos:
result_unchecked_todos += utils.translate('list_todo_element', {
'todo': todo['name']
})
utils.output('inter', 'unchecked_todos_listed', utils.translate('unchecked_todos_listed', {
'list': listname,
'result': result_unchecked_todos
}
)
)
if len(completed_todos) == 0:
return utils.output('end', 'no_completed_todo', utils.translate('no_completed_todo', { 'list': listname }))
for todo in completed_todos:
result_completed_todos += utils.translate('list_completed_todo_element', {
'todo': todo['name']
})
return utils.output('end', 'completed_todos_listed', utils.translate('completed_todos_listed', {
'list': listname,
'result': result_completed_todos
}
)
)
def rename_list(string, entities):
"""WIP"""
"""Rename a to-do list"""
# Old list name
old_listname = ''
# New list name
new_listname = ''
# Find entities
for item in entities:
if item['entity'] == 'old_list':
old_listname = item['sourceText'].lower()
elif item['entity'] == 'new_list':
new_listname = item['sourceText'].lower()
# Verify if an old and new list name have been provided
if not old_listname or not new_listname:
return utils.output('end', 'new_or_old_list_not_provided', utils.translate('new_or_old_list_not_provided'))
# Verify if the old list exists
if db_lists.count(Query.name == old_listname) == 0:
return utils.output('end', 'list_does_not_exist', utils.translate('list_does_not_exist', { 'list': old_listname }))
# Verify if the new list name already exists
if db_lists.count(Query.name == new_listname) > 0:
return utils.output('end', 'list_already_exists', utils.translate('list_already_exists', { 'list': new_listname }))
# Rename the to-do list
db_lists.update({
'name': new_listname,
'updated_at': int(time())
}, Query.name == old_listname)
# Rename the list name of the todos
db_todos.update({
'list': new_listname,
'updated_at': int(time())
}, Query.list == old_listname)
return utils.output('end', 'list_renamed', utils.translate('list_renamed', {
'old_list': 'fake',
'new_list': 'new'
'old_list': old_listname,
'new_list': new_listname
}))
def delete_list(string, entities):
"""WIP"""
"""Delete a to-do list"""
return utils.output('end', 'list_deleted', utils.translate('list_deleted', { 'list': 'fake' }))
# List name
listname = ''
def add_todo(string, entities):
"""WIP"""
# Find entities
for item in entities:
if item['entity'] == 'list':
listname = item['sourceText'].lower()
return utils.output('end', 'todo_added', utils.translate('todo_added', {
'list': 'fake',
'todo': 'todo 1'
# Verify if a list name has been provided
if not listname:
return utils.output('end', 'list_not_provided', utils.translate('list_not_provided'))
# Verify if the list exists
if db_lists.count(Query.name == listname) == 0:
return utils.output('end', 'list_does_not_exist', utils.translate('list_does_not_exist', { 'list': listname }))
# Delete the to-do list
db_lists.remove(Query.name == listname)
# Delete todos of that to-do list
db_todos.remove(Query.list == listname)
return utils.output('end', 'list_deleted', utils.translate('list_deleted', { 'list': listname }))
def add_todos(string, entities):
"""Add todos to a to-do list"""
# List name
listname = ''
# Todos
todos = []
# Find entities
for item in entities:
if item['entity'] == 'list':
listname = item['sourceText'].lower()
elif item['entity'] == 'todos':
# Split todos into array and trim start/end-whitespaces
todos = [chunk.strip() for chunk in item['sourceText'].lower().split(',')]
# Verify if a list name has been provided
if not listname:
return utils.output('end', 'list_not_provided', utils.translate('list_not_provided'))
# Verify todos have been provided
if len(todos) == 0:
return utils.output('end', 'todos_not_provided', utils.translate('todos_not_provided'))
# Verify the list exists
if db_lists.count(Query.name == listname) == 0:
# Create the new to-do list
dbCreateList(listname)
result = ''
for todo in todos:
# Add to-do to DB
dbCreateTodo(listname, todo)
result += utils.translate('list_todo_element', { 'todo': todo })
return utils.output('end', 'todos_added', utils.translate('todos_added', {
'list': listname,
'result': result
}))
def complete_todo(string, entities):
"""WIP"""
def complete_todos(string, entities):
"""Complete todos"""
return utils.output('end', 'todo_completed', utils.translate('todo_completed', {
'list': 'fake',
'todo': 'todo 1'
# List name
listname = ''
# Todos
todos = []
# Find entities
for item in entities:
if item['entity'] == 'list':
listname = item['sourceText'].lower()
elif item['entity'] == 'todos':
# Split todos into array and trim start/end-whitespaces
todos = [chunk.strip() for chunk in item['sourceText'].lower().split(',')]
# Verify if a list name has been provided
if not listname:
return utils.output('end', 'list_not_provided', utils.translate('list_not_provided'))
# Verify todos have been provided
if len(todos) == 0:
return utils.output('end', 'todos_not_provided', utils.translate('todos_not_provided'))
# Verify the list exists
if db_lists.count(Query.name == listname) == 0:
# Create the new to-do list
dbCreateList(listname)
result = ''
for todo in todos:
for db_todo in db_todos.search(Query.list == listname):
# Rough matching (e.g. 1kg of rice = rice)
if db_todo['name'].find(todo) != -1:
db_todos.update({
'is_completed': True,
'updated_at': timestamp
}, (Query.list == listname) & (Query.name == db_todo['name']))
result += utils.translate('list_completed_todo_element', { 'todo': db_todo['name'] })
return utils.output('end', 'todos_completed', utils.translate('todos_completed', {
'list': listname,
'result': result
}))
def archive_todo(string, entities):
"""WIP"""
def uncheck_todos(string, entities):
"""Uncheck todos"""
return utils.output('end', 'todo_archived', utils.translate('todo_archived', {
'list': 'fake',
'todo': 'todo 1'
# List name
listname = ''
# Todos
todos = []
# Find entities
for item in entities:
if item['entity'] == 'list':
listname = item['sourceText'].lower()
elif item['entity'] == 'todos':
# Split todos into array and trim start/end-whitespaces
todos = [chunk.strip() for chunk in item['sourceText'].lower().split(',')]
# Verify if a list name has been provided
if not listname:
return utils.output('end', 'list_not_provided', utils.translate('list_not_provided'))
# Verify todos have been provided
if len(todos) == 0:
return utils.output('end', 'todos_not_provided', utils.translate('todos_not_provided'))
# Verify if the list exists
if db_lists.count(Query.name == listname) == 0:
return utils.output('end', 'list_does_not_exist', utils.translate('list_does_not_exist', { 'list': listname }))
result = ''
for todo in todos:
for db_todo in db_todos.search(Query.list == listname):
# Rough matching (e.g. 1kg of rice = rice)
if db_todo['name'].find(todo) != -1:
db_todos.update({
'is_completed': False,
'updated_at': timestamp
}, (Query.list == listname) & (Query.name == db_todo['name']))
result += utils.translate('list_todo_element', { 'todo': db_todo['name'] })
return utils.output('end', 'todo_unchecked', utils.translate('todos_unchecked', {
'list': listname,
'result': result
}))
def dbCreateList(listname):
"""Create list in DB"""
db_lists.insert({
'name': listname,
'created_at': timestamp,
'updated_at': timestamp
})
def dbCreateTodo(listname, todoname):
"""Create to-todo in list DB table"""
db_todos.insert({
'list': listname,
'name': todoname,
'is_completed': False,
'created_at': timestamp,
'updated_at': timestamp
})

View File

@ -7,13 +7,13 @@
"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"
"Vérifie si github.com en ligne ou hors ligne",
"Vérifie si github.com hors ligne",
"Vérifie si github.com en ligne",
"Vérifie si nodejs.org hors ligne",
"Vérifie si nodejs.org en ligne",
"Vérifie si nodejs.org fonctionne",
"Vérifie si amazon.com en ligne ou hors ligne"
]
}
},
@ -26,9 +26,9 @@
"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"
"Vérifie que iifeoluwa.ao@gmail.com et louis.grenard@gmail.com n'ont pas été compromise",
"Vérifie que iifeoluwa.ao@gmail.com et louis.grenard@gmail.com n'ont pas été pwned",
"Vérifie que iifeoluwa.ao@gmail.com et louis.grenard@gmail.com n'ont pas été exposées à une brèche"
]
}
}

View File

@ -7,6 +7,8 @@ from urllib import parse
from requests import codes, exceptions
def run(string, entities):
"""Verify if one or several email addresses have been pwned"""
emails = []
for item in entities:

View File

@ -5,10 +5,10 @@
"Quelle est ma vitesse Internet actuelle?",
"Peux-tu me faire un speedtest ?",
"Fais un speedtest",
"Lance-moi un test de vitesse",
"Lance un test de vitesse",
"Mon réseau Internet est-il bon ?",
"Ma connexion Internet est-elle bonne ?"
]
]
}
}
}

View File

@ -1,7 +1,8 @@
{
"github": {
"run": {
"expressions": ["Quelles sont les tendances sur GitHub ?",
"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 ?",

View File

@ -2,7 +2,7 @@
"youtube": {
"run": {
"expressions": [
"Télécharges les nouvelles vidéos depuis YouTube"
"Télécharge les nouvelles vidéos depuis YouTube"
]
}
}

View File

@ -1,7 +1,7 @@
import { shell } from 'execa'
import log from '@/helpers/log'
import loader from '@/helpers/loader';
import loader from '@/helpers/loader'
/**
* Specific module testing script
@ -17,7 +17,7 @@ import loader from '@/helpers/loader';
try {
loader.start()
await shell('npm run train expressions:en')
const cmd = await shell(`cross-env PIPENV_PIPFILE=bridges/python/Pipfile jest --silent --config=./test/e2e/modules/e2e.modules.jest.json packages/${pkg}/test/${module}.spec.js && npm run train expressions`)
const cmd = await shell(`cross-env PIPENV_PIPFILE=bridges/python/Pipfile LEON_NODE_ENV=testing jest --silent --config=./test/e2e/modules/e2e.modules.jest.json packages/${pkg}/test/${module}.spec.js && npm run train expressions`)
log.default(cmd.stdout)
log.default(cmd.stderr)