mirror of
https://github.com/leon-ai/leon.git
synced 2024-10-26 18:18:46 +03:00
feat(server): support on-the-fly entity annotation for built-in entities
This commit is contained in:
parent
2ac1bc63cc
commit
567b030c4f
@ -21,8 +21,7 @@
|
||||
"That's right",
|
||||
"That works",
|
||||
"Go ahead",
|
||||
"Why not",
|
||||
"I do"
|
||||
"Why not"
|
||||
],
|
||||
"value": true
|
||||
},
|
||||
|
@ -64,6 +64,8 @@ export default () => new Promise(async (resolve, reject) => {
|
||||
const intentName = intentKeys[j]
|
||||
const intentObj = resolverIntents[intentName]
|
||||
|
||||
nlp.assignDomain(lang, intentName, 'system')
|
||||
|
||||
for (let k = 0; k < intentObj.utterance_samples.length; k += 1) {
|
||||
nlp.addDocument(lang, intentObj.utterance_samples[k], intentName)
|
||||
}
|
||||
|
@ -165,6 +165,10 @@ class Brain {
|
||||
const nextAction = action.next_action ? actions[action.next_action] : null
|
||||
|
||||
if (actionType === 'logic') {
|
||||
/**
|
||||
* "Logic" action skill execution
|
||||
*/
|
||||
|
||||
// Ensure the process is empty (to be able to execute other processes outside of Brain)
|
||||
if (Object.keys(this.process).length === 0) {
|
||||
/**
|
||||
@ -335,6 +339,10 @@ class Brain {
|
||||
// Reset the child process
|
||||
this.process = { }
|
||||
} else {
|
||||
/**
|
||||
* "Dialog" action skill execution
|
||||
*/
|
||||
|
||||
const nluFilePath = path.join(
|
||||
process.cwd(), 'skills', obj.classification.domain, obj.classification.skill, 'nlu', `${this._lang}.json`
|
||||
)
|
||||
@ -369,9 +377,9 @@ class Brain {
|
||||
*/
|
||||
if (utteranceHasEntities && answer.indexOf('{{') !== -1) {
|
||||
obj.entities.forEach((entityObj) => {
|
||||
answer = string.pnr(answer, { [`{{ ${entityObj.entity} }}`]: entityObj.option })
|
||||
answer = string.pnr(answer, { [`{{ ${entityObj.entity} }}`]: entityObj.resolution.value })
|
||||
|
||||
// Find matches and map deeper data from the NLU file
|
||||
// Find matches and map deeper data from the NLU file (global/custom entities)
|
||||
const matches = answer.match(/{{.+?}}/g)
|
||||
|
||||
matches?.forEach((match) => {
|
||||
|
@ -28,7 +28,7 @@
|
||||
"name": "date"
|
||||
},
|
||||
"questions": [
|
||||
"What's your birth date?"
|
||||
"What's your birth date {{ person }}?"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
@ -22,7 +22,7 @@
|
||||
"partner_assistant": {
|
||||
"options": {
|
||||
"Alexa": {
|
||||
"synonyms": ["alexa"],
|
||||
"synonyms": ["Alexa"],
|
||||
"data": {
|
||||
"thought": [
|
||||
"Alexa is very kind and Amazon is teaching it many things. It was born in November 2014.",
|
||||
@ -31,7 +31,7 @@
|
||||
}
|
||||
},
|
||||
"Cortana": {
|
||||
"synonyms": ["cortana"],
|
||||
"synonyms": ["Cortana"],
|
||||
"data": {
|
||||
"thought": [
|
||||
"Cortana is thoughtful and Microsoft is improving her day after day. She was born in April 2014.",
|
||||
@ -40,7 +40,7 @@
|
||||
}
|
||||
},
|
||||
"Siri": {
|
||||
"synonyms": ["siri"],
|
||||
"synonyms": ["Siri"],
|
||||
"data": {
|
||||
"thought": [
|
||||
"I consider Siri as a leader, it has a lot of experience and Apple is constantly improving it. It was born in October 2011.",
|
||||
@ -49,7 +49,7 @@
|
||||
}
|
||||
},
|
||||
"Google Assistant": {
|
||||
"synonyms": ["google assistant"],
|
||||
"synonyms": ["Google Assistant"],
|
||||
"data": {
|
||||
"thought": [
|
||||
"Google Assistant is smart and Google is doing a great job with it. It was born in May 2016.",
|
||||
|
Loading…
Reference in New Issue
Block a user