Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Noah Brackenbury
erp5
Commits
592ad8ff
Commit
592ad8ff
authored
Sep 07, 2017
by
Noah Brackenbury
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed unit test, now ready for merge again
parent
18696b5a
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
75 additions
and
55 deletions
+75
-55
bt5/erp5_ai_business_bot/ExtensionTemplateItem/portal_components/extension.erp5.ParseWebMessage.py
...eItem/portal_components/extension.erp5.ParseWebMessage.py
+2
-3
bt5/erp5_ai_business_bot/ExtensionTemplateItem/portal_components/extension.erp5.ParseWebMessage.xml
...Item/portal_components/extension.erp5.ParseWebMessage.xml
+12
-4
bt5/erp5_ai_business_bot/ExtensionTemplateItem/portal_components/extension.erp5.SetWebMessageModel.py
...em/portal_components/extension.erp5.SetWebMessageModel.py
+0
-3
bt5/erp5_ai_business_bot/ExtensionTemplateItem/portal_components/extension.erp5.TestWebMessageModel.py
...m/portal_components/extension.erp5.TestWebMessageModel.py
+2
-10
bt5/erp5_ai_business_bot/ExtensionTemplateItem/portal_components/extension.erp5.TestWebMessageModel.xml
.../portal_components/extension.erp5.TestWebMessageModel.xml
+15
-4
bt5/erp5_ai_business_bot/ExtensionTemplateItem/portal_components/extension.erp5.TrainOnWebMessage.py
...tem/portal_components/extension.erp5.TrainOnWebMessage.py
+2
-0
bt5/erp5_ai_business_bot/ExtensionTemplateItem/portal_components/extension.erp5.TrainOnWebMessage.xml
...em/portal_components/extension.erp5.TrainOnWebMessage.xml
+12
-4
bt5/erp5_ai_business_bot/TestTemplateItem/portal_components/test.erp5.testBusinessBot.py
...mplateItem/portal_components/test.erp5.testBusinessBot.py
+15
-18
bt5/erp5_ai_business_bot/TestTemplateItem/portal_components/test.erp5.testBusinessBot.xml
...plateItem/portal_components/test.erp5.testBusinessBot.xml
+14
-4
bt5/erp5_ai_business_bot/bt/dependency_list
bt5/erp5_ai_business_bot/bt/dependency_list
+1
-5
No files found.
bt5/erp5_ai_business_bot/ExtensionTemplateItem/portal_components/extension.erp5.ParseWebMessage.py
View file @
592ad8ff
...
@@ -8,6 +8,8 @@ def WebMessage_parseWebMessage(self):
...
@@ -8,6 +8,8 @@ def WebMessage_parseWebMessage(self):
portal
=
self
.
getPortalObject
()
portal
=
self
.
getPortalObject
()
people
=
portal
.
person_module
people
=
portal
.
person_module
text_content
=
message
.
getTextContent
()
text_content
=
message
.
getTextContent
()
if
text_content
is
None
:
return
()
suggested_subject_list
=
[]
suggested_subject_list
=
[]
sender_info
=
False
sender_info
=
False
...
@@ -40,11 +42,8 @@ def WebMessage_parseWebMessage(self):
...
@@ -40,11 +42,8 @@ def WebMessage_parseWebMessage(self):
reference
=
'ai_business_bot'
,
reference
=
'ai_business_bot'
,
title
=
"AI Business Bot"
)
title
=
"AI Business Bot"
)
erp5_file
=
portal
.
portal_catalog
.
getResultValue
(
**
kw
)
erp5_file
=
portal
.
portal_catalog
.
getResultValue
(
**
kw
)
<<<<<<<
HEAD
if
not
erp5_file
:
if
not
erp5_file
:
return
"No model found to be applied to this Web Message. Run Set Web Message Model in Event Module first."
return
"No model found to be applied to this Web Message. Run Set Web Message Model in Event Module first."
=======
>>>>>>>
2e83
d650106eb861a0c38350ab16aa6d13caea36
model_as_string
=
erp5_file
.
getData
()
model_as_string
=
erp5_file
.
getData
()
model
=
pickle
.
loads
(
model_as_string
)
model
=
pickle
.
loads
(
model_as_string
)
language_arrays
=
model
[
0
]
language_arrays
=
model
[
0
]
...
...
bt5/erp5_ai_business_bot/ExtensionTemplateItem/portal_components/extension.erp5.ParseWebMessage.xml
View file @
592ad8ff
...
@@ -36,6 +36,18 @@
...
@@ -36,6 +36,18 @@
<none/>
<none/>
</value>
</value>
</item>
</item>
<item>
<key>
<string>
text_content_error_message
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
text_content_warning_message
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<item>
<key>
<string>
version
</string>
</key>
<key>
<string>
version
</string>
</key>
<value>
<string>
erp5
</string>
</value>
<value>
<string>
erp5
</string>
</value>
...
@@ -99,10 +111,6 @@
...
@@ -99,10 +111,6 @@
<key>
<string>
action
</string>
</key>
<key>
<string>
action
</string>
</key>
<value>
<string>
validate
</string>
</value>
<value>
<string>
validate
</string>
</value>
</item>
</item>
<item>
<key>
<string>
error_message
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<item>
<key>
<string>
validation_state
</string>
</key>
<key>
<string>
validation_state
</string>
</key>
<value>
<string>
validated
</string>
</value>
<value>
<string>
validated
</string>
</value>
...
...
bt5/erp5_ai_business_bot/ExtensionTemplateItem/portal_components/extension.erp5.SetWebMessageModel.py
View file @
592ad8ff
...
@@ -27,11 +27,8 @@ def WebMessage_setModel(self):
...
@@ -27,11 +27,8 @@ def WebMessage_setModel(self):
portal_type
=
"Web Message"
,
portal_type
=
"Web Message"
,
query
=
NegatedQuery
(
Query
(
subject
=
None
)),
query
=
NegatedQuery
(
Query
(
subject
=
None
)),
)
)
<<<<<<<
HEAD
if
not
training_messages
:
if
not
training_messages
:
return
"No Web Messages to train on"
return
"No Web Messages to train on"
=======
>>>>>>>
2e83
d650106eb861a0c38350ab16aa6d13caea36
for
message
in
training_messages
:
for
message
in
training_messages
:
(
language_arrays
,
tag_arrays
)
=
message
.
WebMessage_trainOnWebMessage
(
language_arrays
,
tag_arrays
,
stopwords_arrays
)
(
language_arrays
,
tag_arrays
)
=
message
.
WebMessage_trainOnWebMessage
(
language_arrays
,
tag_arrays
,
stopwords_arrays
)
end_time
=
time
.
time
()
end_time
=
time
.
time
()
...
...
bt5/erp5_ai_business_bot/ExtensionTemplateItem/portal_components/extension.erp5.TestWebMessageModel.py
View file @
592ad8ff
...
@@ -27,11 +27,8 @@ def WebMessage_testModel(self):
...
@@ -27,11 +27,8 @@ def WebMessage_testModel(self):
portal_type
=
"Web Message"
,
portal_type
=
"Web Message"
,
query
=
NegatedQuery
(
Query
(
subject
=
None
)),
query
=
NegatedQuery
(
Query
(
subject
=
None
)),
)
)
<<<<<<<
HEAD
if
not
training_messages
:
if
not
training_messages
:
return
"No Web Messages found to train on"
return
"No Web Messages found to train on"
=======
>>>>>>>
2e83
d650106eb861a0c38350ab16aa6d13caea36
for
index
,
message
in
enumerate
(
training_messages
):
for
index
,
message
in
enumerate
(
training_messages
):
if
random
.
random
()
<=
0.2
:
if
random
.
random
()
<=
0.2
:
test_messages
.
append
(
message
)
test_messages
.
append
(
message
)
...
@@ -51,6 +48,8 @@ def WebMessage_testModel(self):
...
@@ -51,6 +48,8 @@ def WebMessage_testModel(self):
# clean up header from contact form, if there is one
# clean up header from contact form, if there is one
text
=
message
.
getTextContent
()
text
=
message
.
getTextContent
()
if
text
is
None
:
pass
line_array
=
[
line
for
line
in
text
.
splitlines
()
if
line
.
strip
()
!=
''
]
line_array
=
[
line
for
line
in
text
.
splitlines
()
if
line
.
strip
()
!=
''
]
if
line_array
[
0
][:
6
]
==
" Name"
:
if
line_array
[
0
][:
6
]
==
" Name"
:
line_array
=
line_array
[
4
:]
line_array
=
line_array
[
4
:]
...
@@ -119,18 +118,11 @@ def WebMessage_testModel(self):
...
@@ -119,18 +118,11 @@ def WebMessage_testModel(self):
if
not
suggested_tags_set
.
intersection
(
sr
)
and
not
suggested_tags_set
.
intersection
(
so
):
if
not
suggested_tags_set
.
intersection
(
sr
)
and
not
suggested_tags_set
.
intersection
(
so
):
type_accuracy
+=
1
type_accuracy
+=
1
<<<<<<<
HEAD
if
not
len
(
test_messages
)
==
0
:
if
not
len
(
test_messages
)
==
0
:
correct_tags
=
float
(
correct_tags
)
/
float
(
len
(
test_messages
))
correct_tags
=
float
(
correct_tags
)
/
float
(
len
(
test_messages
))
excess_tags
=
float
(
excess_tags
)
/
float
(
len
(
test_messages
))
excess_tags
=
float
(
excess_tags
)
/
float
(
len
(
test_messages
))
language_accuracy
=
float
(
language_accuracy
)
/
float
(
len
(
test_messages
))
language_accuracy
=
float
(
language_accuracy
)
/
float
(
len
(
test_messages
))
type_accuracy
=
float
(
type_accuracy
)
/
float
(
len
(
test_messages
))
type_accuracy
=
float
(
type_accuracy
)
/
float
(
len
(
test_messages
))
=======
correct_tags
=
float
(
correct_tags
)
/
float
(
len
(
test_messages
))
excess_tags
=
float
(
excess_tags
)
/
float
(
len
(
test_messages
))
language_accuracy
=
float
(
language_accuracy
)
/
float
(
len
(
test_messages
))
type_accuracy
=
float
(
type_accuracy
)
/
float
(
len
(
test_messages
))
>>>>>>>
2e83
d650106eb861a0c38350ab16aa6d13caea36
end_time
=
time
.
time
()
end_time
=
time
.
time
()
uptime
=
end_time
-
start_time
uptime
=
end_time
-
start_time
human_uptime
=
str
(
datetime
.
timedelta
(
seconds
=
int
(
uptime
)))
human_uptime
=
str
(
datetime
.
timedelta
(
seconds
=
int
(
uptime
)))
...
...
bt5/erp5_ai_business_bot/ExtensionTemplateItem/portal_components/extension.erp5.TestWebMessageModel.xml
View file @
592ad8ff
...
@@ -36,6 +36,21 @@
...
@@ -36,6 +36,21 @@
<none/>
<none/>
</value>
</value>
</item>
</item>
<item>
<key>
<string>
text_content_error_message
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
text_content_warning_message
</string>
</key>
<value>
<tuple>
<string>
W: 32, 6: Unused variable \'index\' (unused-variable)
</string>
<string>
W: 40, 2: Unused variable \'m\' (unused-variable)
</string>
</tuple>
</value>
</item>
<item>
<item>
<key>
<string>
version
</string>
</key>
<key>
<string>
version
</string>
</key>
<value>
<string>
erp5
</string>
</value>
<value>
<string>
erp5
</string>
</value>
...
@@ -99,10 +114,6 @@
...
@@ -99,10 +114,6 @@
<key>
<string>
action
</string>
</key>
<key>
<string>
action
</string>
</key>
<value>
<string>
validate
</string>
</value>
<value>
<string>
validate
</string>
</value>
</item>
</item>
<item>
<key>
<string>
error_message
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<item>
<key>
<string>
validation_state
</string>
</key>
<key>
<string>
validation_state
</string>
</key>
<value>
<string>
validated
</string>
</value>
<value>
<string>
validated
</string>
</value>
...
...
bt5/erp5_ai_business_bot/ExtensionTemplateItem/portal_components/extension.erp5.TrainOnWebMessage.py
View file @
592ad8ff
...
@@ -5,6 +5,8 @@ def WebMessage_trainOnWebMessage(self, language_arrays, tag_arrays, stopwords_ar
...
@@ -5,6 +5,8 @@ def WebMessage_trainOnWebMessage(self, language_arrays, tag_arrays, stopwords_ar
# clean up header from contact form, if there is one
# clean up header from contact form, if there is one
text
=
self
.
getTextContent
()
text
=
self
.
getTextContent
()
if
text
is
None
:
return
(
language_arrays
,
tag_arrays
)
line_array
=
[
line
for
line
in
text
.
splitlines
()
if
line
.
strip
()
!=
''
]
line_array
=
[
line
for
line
in
text
.
splitlines
()
if
line
.
strip
()
!=
''
]
if
line_array
[
0
][:
6
]
==
" Name"
:
if
line_array
[
0
][:
6
]
==
" Name"
:
line_array
=
line_array
[
4
:]
line_array
=
line_array
[
4
:]
...
...
bt5/erp5_ai_business_bot/ExtensionTemplateItem/portal_components/extension.erp5.TrainOnWebMessage.xml
View file @
592ad8ff
...
@@ -36,6 +36,18 @@
...
@@ -36,6 +36,18 @@
<none/>
<none/>
</value>
</value>
</item>
</item>
<item>
<key>
<string>
text_content_error_message
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
text_content_warning_message
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<item>
<key>
<string>
version
</string>
</key>
<key>
<string>
version
</string>
</key>
<value>
<string>
erp5
</string>
</value>
<value>
<string>
erp5
</string>
</value>
...
@@ -99,10 +111,6 @@
...
@@ -99,10 +111,6 @@
<key>
<string>
action
</string>
</key>
<key>
<string>
action
</string>
</key>
<value>
<string>
validate
</string>
</value>
<value>
<string>
validate
</string>
</value>
</item>
</item>
<item>
<key>
<string>
error_message
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<item>
<key>
<string>
validation_state
</string>
</key>
<key>
<string>
validation_state
</string>
</key>
<value>
<string>
validated
</string>
</value>
<value>
<string>
validated
</string>
</value>
...
...
bt5/erp5_ai_business_bot/TestTemplateItem/portal_components/test.erp5.testBusinessBot.py
View file @
592ad8ff
...
@@ -14,22 +14,19 @@ class Test(ERP5TypeTestCase):
...
@@ -14,22 +14,19 @@ class Test(ERP5TypeTestCase):
"""
"""
return
(
'erp5_base'
,
'erp5_web'
,
'erp5_ingestion_mysql_innodb_catalog'
,
'erp5_crm'
,
'erp5_dms'
,
'erp5_business_bot'
)
return
(
'erp5_base'
,
'erp5_web'
,
'erp5_ingestion_mysql_innodb_catalog'
,
'erp5_crm'
,
'erp5_dms'
,
'erp5_business_bot'
)
message_reference_dict
=
{}
def
afterSetUp
(
self
):
def
afterSetUp
(
self
):
"""
"""
This is ran before anything, used to set the environment
This is ran before anything, used to set the environment
"""
"""
message_list
=
[
message_list
=
[
dict
(
title
=
'Tagged Message'
,
subject_list
=
[
'ERP5'
,
'pricing'
],
text_content
=
"ERP5 pricing"
),
dict
(
title
=
'Tagged Message'
,
subject_list
=
[
'ERP5'
,
'pricing'
],
text_content
=
"ERP5 pricing"
),
dict
(
title
=
'Untagged Message'
,
text_content
=
"ERP5 pricing"
),
dict
(
title
=
'Untagged Message'
,
subject_list
=
[],
text_content
=
"ERP5 pricing"
),
]
]
for
message
in
message_list
:
for
index
,
message
in
enumerate
(
message_list
)
:
kw
=
dict
(
portal_type
=
'Web Message'
,
title
=
message_list
[
title
],
text_content
=
message_list
[
text_content
])
kw
=
dict
(
portal_type
=
'Web Message'
,
title
=
message_list
[
index
][
"title"
],
subject
=
message_list
[
index
][
"subject_list"
])
existing
=
self
.
portal_catalog
.
getResultValue
(
**
kw
)
existing
=
self
.
portal
.
portal
_catalog
.
getResultValue
(
**
kw
)
if
existing
is
None
:
if
existing
is
None
:
self
.
message_reference_dict
[
message
[
'reference'
]]
=
self
.
event_module
.
newContent
(
**
kw
).
getReference
()
self
.
portal
.
event_module
.
newContent
(
**
kw
)
else
:
self
.
message_reference_dict
[
message
[
'reference'
]]
=
existing
.
getReference
()
self
.
commit
()
self
.
commit
()
self
.
tic
()
self
.
tic
()
...
@@ -41,11 +38,11 @@ class Test(ERP5TypeTestCase):
...
@@ -41,11 +38,11 @@ class Test(ERP5TypeTestCase):
exists in the document module.
exists in the document module.
"""
"""
set_model_result
=
self
.
event_module
.
set_m
odel
().
split
()
set_model_result
=
self
.
portal
.
event_module
.
WebMessage_setM
odel
().
split
()
self
.
assertEqual
(
set_model_result
[
0
],
"Model"
)
self
.
assertEqual
(
set_model_result
[
0
],
"Model"
)
kw
=
dict
(
portal_type
=
'
Document
'
,
title
=
"AI Business Bot"
)
kw
=
dict
(
portal_type
=
'
File
'
,
title
=
"AI Business Bot"
)
document
=
self
.
portal_catalog
.
getResultValue
(
**
kw
)
document
=
self
.
portal
.
portal
_catalog
.
getResultValue
(
**
kw
)
self
.
assertEqual
(
set_model_result
[
3
],
document
.
getRelativeUrl
())
self
.
assertEqual
(
set_model_result
[
3
],
"/erp5/"
+
document
.
getRelativeUrl
())
def
test_testWebMessageModel
(
self
):
def
test_testWebMessageModel
(
self
):
"""
"""
...
@@ -53,7 +50,7 @@ class Test(ERP5TypeTestCase):
...
@@ -53,7 +50,7 @@ class Test(ERP5TypeTestCase):
would be given the current algorithm for the model and
would be given the current algorithm for the model and
the current tagged messages. Data is returned to user.
the current tagged messages. Data is returned to user.
"""
"""
self
.
assertEqual
(
self
.
event_module
.
test_m
odel
().
split
()[
0
]
,
"Model"
)
self
.
assertEqual
(
self
.
portal
.
event_module
.
WebMessage_testM
odel
().
split
()[
0
]
,
"Model"
)
def
test_followUpAutomatically
(
self
):
def
test_followUpAutomatically
(
self
):
"""
"""
...
@@ -61,8 +58,8 @@ class Test(ERP5TypeTestCase):
...
@@ -61,8 +58,8 @@ class Test(ERP5TypeTestCase):
wish would be handled by the model. This message now
wish would be handled by the model. This message now
has tags.
has tags.
"""
"""
self
.
event_module
.
set_m
odel
()
self
.
portal
.
event_module
.
WebMessage_setM
odel
()
kw
=
dict
(
portal_type
=
'Web Message'
,
title
=
'Untagged Message'
,
text_content
=
"ERP5 pricing"
)
kw
=
dict
(
portal_type
=
'Web Message'
,
title
=
'Untagged Message'
)
message
=
self
.
portal_catalog
.
getResultValue
(
**
kw
)
message
=
self
.
portal
.
portal
_catalog
.
getResultValue
(
**
kw
)
message
.
follow_up_automatically
()
message
.
WebMessage_parseWebMessage
()
self
.
assert
Equal
(
message
.
getSubjectList
(),
[
'ERP5'
,
'pricing'
]
)
self
.
assert
False
(
message
.
getSubjectList
()
==
"[]"
)
\ No newline at end of file
bt5/erp5_ai_business_bot/TestTemplateItem/portal_components/test.erp5.testBusinessBot.xml
View file @
592ad8ff
...
@@ -34,6 +34,20 @@
...
@@ -34,6 +34,20 @@
<none/>
<none/>
</value>
</value>
</item>
</item>
<item>
<key>
<string>
text_content_error_message
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
text_content_warning_message
</string>
</key>
<value>
<tuple>
<string>
W: 25, 15: Unused variable \'message\' (unused-variable)
</string>
</tuple>
</value>
</item>
<item>
<item>
<key>
<string>
version
</string>
</key>
<key>
<string>
version
</string>
</key>
<value>
<string>
erp5
</string>
</value>
<value>
<string>
erp5
</string>
</value>
...
@@ -97,10 +111,6 @@
...
@@ -97,10 +111,6 @@
<key>
<string>
action
</string>
</key>
<key>
<string>
action
</string>
</key>
<value>
<string>
validate
</string>
</value>
<value>
<string>
validate
</string>
</value>
</item>
</item>
<item>
<key>
<string>
error_message
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<item>
<key>
<string>
validation_state
</string>
</key>
<key>
<string>
validation_state
</string>
</key>
<value>
<string>
validated
</string>
</value>
<value>
<string>
validated
</string>
</value>
...
...
bt5/erp5_ai_business_bot/bt/dependency_list
View file @
592ad8ff
erp5_base
erp5_base
erp5_web
erp5_web
erp5_dms
erp5_dms
<<<<<<< HEAD
erp5_crm
erp5_crm
erp5_ingestion_mysql_innodb_catalog
erp5_ingestion_mysql_innodb_catalog
\ No newline at end of file
=======
erp5_crm
>>>>>>> 2e83d650106eb861a0c38350ab16aa6d13caea36
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment