Skip to content

Commit

Permalink
Merge pull request #10 from bkimminich/training-format
Browse files Browse the repository at this point in the history
Update training data format
  • Loading branch information
bkimminich committed Sep 6, 2020
2 parents 50bc432 + 1568993 commit 4b3800f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 52 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
69 changes: 22 additions & 47 deletions test/initialize-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,58 +4,33 @@ const juice = require('../index')

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

0 comments on commit 4b3800f

Please sign in to comment.