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
8d0de831
Commit
8d0de831
authored
Sep 06, 2017
by
Noah Brackenbury
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved TestWebMessageModel
parent
6d662f06
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
7 deletions
+9
-7
bt5/erp5_ai_business_bot/ExtensionTemplateItem/portal_components/extension.erp5.TestWebMessageModel.py
...m/portal_components/extension.erp5.TestWebMessageModel.py
+9
-7
No files found.
bt5/erp5_ai_business_bot/ExtensionTemplateItem/portal_components/extension.erp5.TestWebMessageModel.py
View file @
8d0de831
...
...
@@ -62,7 +62,8 @@ def WebMessage_testModel(self):
word_relevance
=
(
language_arrays
[
language
][
word
])
/
(
list
(
language_arrays
[
language
].
values
())[
0
])
language_relevance
[
language
]
=
language_relevance
[
language
]
+
word_relevance
message_language
=
max
(
language_relevance
,
key
=
language_relevance
.
get
)
suggested_subject_list
.
append
(
message_language
)
if
message_language
!=
"en"
:
suggested_subject_list
.
append
(
message_language
)
# clean up text for analysis
import
string
...
...
@@ -93,7 +94,8 @@ def WebMessage_testModel(self):
suggested_tags_set
=
set
(
suggested_subject_list
)
correct_tags
+=
len
(
suggested_tags_set
.
intersection
(
message_tags_set
))
/
len
(
message_tags_set
)
excess_tags
+=
len
(
suggested_tags_set
.
difference
(
message_tags_set
))
/
len
(
suggested_tags_set
)
if
len
(
suggested_tags_set
)
!=
0
:
excess_tags
+=
len
(
suggested_tags_set
.
difference
(
message_tags_set
))
/
len
(
suggested_tags_set
)
correct_language
=
True
for
language
in
languages
:
...
...
@@ -111,11 +113,11 @@ def WebMessage_testModel(self):
else
:
if
not
suggested_tags_set
.
intersection
(
sr
)
and
not
suggested_tags_set
.
intersection
(
so
):
type_accuracy
+=
1
correct_tags
/=
len
(
test_messages
)
excess_tags
/=
len
(
test_messages
)
language_accuracy
/=
len
(
test_messages
)
type_accuracy
/=
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
)
)
end_time
=
time
.
time
()
uptime
=
end_time
-
start_time
human_uptime
=
str
(
datetime
.
timedelta
(
seconds
=
int
(
uptime
)))
...
...
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