Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
H
hubot-natural
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ar-noc
hubot-natural
Commits
5242fc77
Commit
5242fc77
authored
7 years ago
by
Matheus Faria
Browse files
Options
Downloads
Patches
Plain Diff
Fix non-root level interactions being trained on root level
parent
b16e3b60
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/bot/classifier.coffee
+35
-30
35 additions, 30 deletions
scripts/bot/classifier.coffee
with
35 additions
and
30 deletions
scripts/bot/classifier.coffee
+
35
−
30
View file @
5242fc77
...
...
@@ -17,34 +17,38 @@ actionHandler = require './action-handler'
root_classifier
=
{}
error_count
=
0
ROOT_LEVEL_NAME
=
"root"
classifyInteraction
=
(
interaction
,
classifier
)
->
if
Array
.
isArray
interaction
.
expect
for
doc
in
interaction
.
expect
if
interaction
.
multi
==
true
classifier
.
addDocument
(
doc
,
interaction
.
name
+
'|'
+
doc
)
else
classifier
.
addDocument
(
doc
,
interaction
.
name
)
if
Array
.
isArray
interaction
.
next
?
.
interactions
interaction
.
next
.
classifier
=
new
natural
.
LogisticRegressionClassifier
(
PorterStemmer
)
for
nextInteractionName
in
interaction
.
next
.
interactions
nextInteraction
=
global
.
config
.
interactions
.
find
(
n
)
->
return
n
.
name
is
nextInteractionName
if
not
nextInteraction
?
console
.
log
'No valid interaction for'
,
nextInteractionName
continue
classifyInteraction
nextInteraction
,
interaction
.
next
.
classifier
interaction
.
next
.
classifier
.
train
()
if
interaction
.
multi
==
true
interaction
.
classifier
=
new
natural
.
LogisticRegressionClassifier
(
PorterStemmer
)
for
doc
in
interaction
.
expect
interaction
.
classifier
.
addDocument
(
doc
,
doc
)
interaction
.
classifier
.
train
()
if
not
interaction
.
expect
?
console
.
warn
(
"
\t
!! Interaction with no expects: "
+
interaction
.
name
)
return
console
.
log
(
'
\t
Processing interaction: '
+
interaction
.
name
)
if
not
Array
.
isArray
interaction
.
expect
interaction
.
expect
=
[
interaction
.
expect
]
for
doc
in
interaction
.
expect
if
typeof
(
doc
)
!=
'string'
doc
=
''
+
doc
classifier
.
addDocument
(
doc
,
interaction
.
name
)
if
interaction
.
next
?
.
interactions
?
and
not
interaction
.
next
?
.
classifier
?
if
not
Array
.
isArray
interaction
.
next
.
interactions
interactions
.
next
.
interactions
=
[
interactions
.
next
.
interactions
]
interaction
.
next
.
classifier
=
new
natural
.
LogisticRegressionClassifier
(
PorterStemmer
)
for
nextInteractionName
in
interaction
.
next
.
interactions
nextInteraction
=
global
.
config
.
interactions
.
find
(
n
)
->
return
n
.
name
is
nextInteractionName
if
not
nextInteraction
?
console
.
log
'No valid interaction for'
,
nextInteractionName
continue
classifyInteraction
nextInteraction
,
interaction
.
next
.
classifier
interaction
.
next
.
classifier
.
train
()
classifier
.
train
=
()
->
console
.
log
'Processing interactions'
...
...
@@ -53,11 +57,12 @@ classifier.train = () ->
root_classifier
=
new
natural
.
LogisticRegressionClassifier
(
PorterStemmer
)
for
interaction
in
global
.
config
.
interactions
if
interaction
.
level
!=
'context'
if
(
not
interaction
.
level
?
or
(
Array
.
isArray
(
interaction
.
level
)
and
interaction
.
level
.
includes
(
ROOT_LEVEL_NAME
))
or
interaction
.
level
==
ROOT_LEVEL_NAME
)
classifyInteraction
interaction
,
root_classifier
console
.
log
(
'
\t
Processing interaction: '
+
interaction
.
name
)
console
.
log
'Training Bot (This could be take a while...)'
root_classifier
.
train
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment