mirror of
https://github.com/leon-ai/leon.git
synced 2024-11-23 20:12:08 +03:00
feat: train affirmation and denial resolver
This commit is contained in:
parent
0acb31a9c6
commit
993d52e868
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "affirm_deny",
|
||||
"name": "Affirmation & Denial",
|
||||
"intents": {
|
||||
"system.affirm": {
|
||||
"system.resolver.affirmation": {
|
||||
"utterance_samples": [
|
||||
"Yes",
|
||||
"Yep",
|
||||
@ -26,7 +26,7 @@
|
||||
],
|
||||
"value": true
|
||||
},
|
||||
"system.deny": {
|
||||
"system.resolver.denial": {
|
||||
"utterance_samples": [
|
||||
"No",
|
||||
"No no don't",
|
@ -1,17 +0,0 @@
|
||||
{
|
||||
"name": "system.affirm",
|
||||
"utterance_samples": [
|
||||
"Oui",
|
||||
"Yep",
|
||||
"Yup",
|
||||
"Ouais",
|
||||
"Faisons ça",
|
||||
"Bien sûr",
|
||||
"Évidemment",
|
||||
"Tout à fait",
|
||||
"Correct",
|
||||
"OK",
|
||||
"C'est vrai",
|
||||
"En effet"
|
||||
]
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
{
|
||||
"name": "system.deny",
|
||||
"utterance_samples": [
|
||||
"Non",
|
||||
"Ne le fais pas",
|
||||
"Nope",
|
||||
"Non merci",
|
||||
"Non ça va",
|
||||
"C'est faux",
|
||||
"Bien sûr que non",
|
||||
"Fais pas ça"
|
||||
]
|
||||
}
|
40
core/data/fr/resolvers/affirmation_denial.json
Normal file
40
core/data/fr/resolvers/affirmation_denial.json
Normal file
@ -0,0 +1,40 @@
|
||||
{
|
||||
"name": "Affirmation & Denial",
|
||||
"intents": {
|
||||
"system.resolver.affirmation": {
|
||||
"utterance_samples": [
|
||||
"Oui",
|
||||
"Yep",
|
||||
"Yup",
|
||||
"Ouais",
|
||||
"Faisons ça",
|
||||
"Bien sûr",
|
||||
"Évidemment",
|
||||
"Tout à fait",
|
||||
"Correct",
|
||||
"OK",
|
||||
"C'est vrai",
|
||||
"En effet",
|
||||
"Entendu",
|
||||
"Ça marche",
|
||||
"Pourquoi pas",
|
||||
"Parfait",
|
||||
"Allez"
|
||||
],
|
||||
"value": true
|
||||
},
|
||||
"system.resolver.denial": {
|
||||
"utterance_samples": [
|
||||
"Non",
|
||||
"Ne le fais pas",
|
||||
"Nope",
|
||||
"Non merci",
|
||||
"Non ça va",
|
||||
"C'est faux",
|
||||
"Bien sûr que non",
|
||||
"Fais pas ça"
|
||||
],
|
||||
"value": false
|
||||
}
|
||||
}
|
||||
}
|
@ -46,9 +46,33 @@ export default () => new Promise(async (resolve, reject) => {
|
||||
|
||||
for (let h = 0; h < shortLangs.length; h += 1) {
|
||||
const lang = shortLangs[h]
|
||||
const resolversPath = path.join(process.cwd(), 'core/data', lang, 'resolvers')
|
||||
const resolverFiles = fs.readdirSync(resolversPath)
|
||||
|
||||
nlp.addLanguage(lang)
|
||||
|
||||
// Train resolvers
|
||||
for (let i = 0; i < resolverFiles.length; i += 1) {
|
||||
const resolverFileName = resolverFiles[i]
|
||||
const resolverPath = path.join(resolversPath, resolverFileName)
|
||||
const { name: resolverName, intents: resolverIntents } = JSON.parse(fs.readFileSync(resolverPath, 'utf8'))
|
||||
const intentKeys = Object.keys(resolverIntents)
|
||||
|
||||
log.info(`[${lang}] Training "${resolverName}" resolver...`)
|
||||
|
||||
for (let j = 0; j < intentKeys.length; j += 1) {
|
||||
const intentName = intentKeys[j]
|
||||
const intentObj = resolverIntents[intentName]
|
||||
|
||||
for (let k = 0; k < intentObj.utterance_samples.length; k += 1) {
|
||||
nlp.addDocument(lang, intentObj.utterance_samples[k], intentName)
|
||||
}
|
||||
}
|
||||
|
||||
log.success(`[${lang}] "${resolverName}" resolver trained`)
|
||||
}
|
||||
|
||||
// Train skills actions
|
||||
for (let i = 0; i < domainKeys.length; i += 1) {
|
||||
const currentDomain = domains[domainKeys[i]]
|
||||
const skillKeys = Object.keys(currentDomain.skills)
|
||||
|
@ -534,7 +534,7 @@ class Nlu {
|
||||
* 7. [OK] While in an action loop, if something other than an expected entity is sent
|
||||
* then break the loop. Need "loop" object in NLU skill config to describe
|
||||
* 8. [OK] Replay with the original utterance
|
||||
* 9. Be able to use the loop without necessarily need slots
|
||||
* 9. [OK] Be able to use the loop without necessarily need slots
|
||||
* 10. Split this process() method into several ones + clean nlu.js and brain.js
|
||||
* 11. Add logs in terminal about context switching, active context, etc.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user