Skip to content

Commit

Permalink
Merge f9a3e5b into 50bc432
Browse files Browse the repository at this point in the history
  • Loading branch information
Scar26 committed Sep 6, 2020
2 parents 50bc432 + f9a3e5b commit 8cb8bd0
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 55 deletions.
12 changes: 7 additions & 5 deletions factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ var users = {
}

function train () {
trainingSet.intents.map((query) => {
model.addDocument(trainingSet.lang, query.question, query.intent)
})
trainingSet.answers.map((query) => {
model.addAnswer(trainingSet.lang, query.intent, query.answer)
trainingSet.data.map((query) => {
query.utterances.map((utterance) => {
model.addDocument(trainingSet.lang, utterance, query.intent)
})
query.answers.map((answer) => {
model.addAnswer(trainingSet.lang, query.intent, answer)
})
})
return model.train().then(() => { training.state = true })
}
Expand Down
75 changes: 25 additions & 50 deletions test/initialize-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,59 +3,34 @@ const expect = chai.expect
const juice = require('../index')

const trainingSet = {
lang: 'en',
intents: [
"lang": "en",
"data": [
{
question: 'goodbye for now',
intent: 'greetings.bye'
"intent": "greetings.bye",
"utterances": [
"goodbye for now",
"bye bye take care"
],
"answers": [
{
"action": "response",
"body": "Ok Cya"
}
]
},
{
question: 'bye bye take care',
intent: 'greetings.bye'
},
{
question: 'hello',
intent: 'greetings.hello'
},
{
question: 'hi',
intent: 'greetings.hello'
},
{
question: 'howdy',
intent: 'greetings.hello'
},
{
question: 'how much is X',
intent: 'queries.productprice'
},
{
question: 'how much does X cost',
intent: 'queries.productprice'
}
],
answers: [
{
intent: 'greetings.bye',
answer: {
action: 'response',
body: 'Ok Cya'
}
},
{
intent: 'greetings.hello',
answer: {
action: 'response',
body: 'Hello <customer-name>'
}
},
{
intent: 'queries.productprice',
answer: {
action: 'function',
handler: 'productPrice',
body: ''
}
"intent": "greetings.hello",
"utterances": [
"hello",
"hi",
"howdy"
],
"answers": [
{
"action": "response",
"body": "Hello <customer-name>"
}
]
}
]
}
Expand Down

0 comments on commit 8cb8bd0

Please sign in to comment.