Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
sentiment
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cfisicaro2
sentiment
Commits
ee8dcb95
Commit
ee8dcb95
authored
2 months ago
by
bjuradotorres2
Browse files
Options
Downloads
Patches
Plain Diff
Coverage report and related files finalized
parent
09f4b8a3
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
test_main.py
+9
-5
9 additions, 5 deletions
test_main.py
with
9 additions
and
5 deletions
test_main.py
+
9
−
5
View file @
ee8dcb95
...
@@ -3,6 +3,7 @@ import sentiment
...
@@ -3,6 +3,7 @@ import sentiment
from
sentiment
import
get_tokens
,
score_compute
,
save_stop_words
from
sentiment
import
get_tokens
,
score_compute
,
save_stop_words
import
os
import
os
class
TestGetTokens
(
unittest
.
TestCase
):
class
TestGetTokens
(
unittest
.
TestCase
):
# creates file path to sentiment.txt file
# creates file path to sentiment.txt file
...
@@ -47,8 +48,10 @@ class TestGetTokens(unittest.TestCase):
...
@@ -47,8 +48,10 @@ class TestGetTokens(unittest.TestCase):
manual_count
=
sum
(
1
for
token
in
self
.
review_tokens_list
if
token
==
target_token
)
manual_count
=
sum
(
1
for
token
in
self
.
review_tokens_list
if
token
==
target_token
)
self
.
assertEqual
(
manual_count
,
expected_count
,
f
"
Expected
{
expected_count
}
occurrences of
'
{
target_token
}
'
, but got
{
manual_count
}
.
"
)
self
.
assertEqual
(
manual_count
,
expected_count
,
print
(
f
"""
\n
Test 2 - Word Frequencies:
\n
The training data contains
{
manual_count
}
appearances of the token
"
too
"
.
"""
)
f
"
Expected
{
expected_count
}
occurrences of
'
{
target_token
}
'
, but got
{
manual_count
}
.
"
)
print
(
f
"""
\n
Test 2 - Word Frequencies:
\n
The training data contains
{
manual_count
}
appearances of the token
"
too
"
.
"""
)
def
test_03_token_statistics
(
self
):
def
test_03_token_statistics
(
self
):
target_token
=
"
too
"
target_token
=
"
too
"
...
@@ -162,7 +165,8 @@ class TestGetTokens(unittest.TestCase):
...
@@ -162,7 +165,8 @@ class TestGetTokens(unittest.TestCase):
avg_score
=
total_score
/
valid_tokens
if
valid_tokens
>
0
else
0
avg_score
=
total_score
/
valid_tokens
if
valid_tokens
>
0
else
0
self
.
assertAlmostEqual
(
avg_score
,
expected_score
,
places
=
10
,
msg
=
"
Incorrect average tf-idf score for sentence.
"
)
self
.
assertAlmostEqual
(
avg_score
,
expected_score
,
places
=
10
,
msg
=
"
Incorrect average tf-idf score for sentence.
"
)
print
(
f
'
\n
Test 7 - Sentence Statistics Score:
\n
The sentence
"
{
target_sentence
}
"
has an average tf-idf score of
{
avg_score
}
.
'
)
print
(
f
'
\n
Test 7 - Sentence Statistics Score:
\n
The sentence
"
{
target_sentence
}
"
has an average tf-idf score of
{
avg_score
}
.
'
)
def
test_08_save_stop_words
(
self
):
def
test_08_save_stop_words
(
self
):
save_stop_words
(
self
.
negative_reviews_list
,
self
.
neutral_reviews_list
,
self
.
positive_reviews_list
)
save_stop_words
(
self
.
negative_reviews_list
,
self
.
neutral_reviews_list
,
self
.
positive_reviews_list
)
...
@@ -263,8 +267,8 @@ class TestGetTokens(unittest.TestCase):
...
@@ -263,8 +267,8 @@ class TestGetTokens(unittest.TestCase):
self
.
assertAlmostEqual
(
avg_score
,
expected_avg_tfidf
,
places
=
5
,
msg
=
"
Incorrect adjusted average tf-idf score.
"
)
self
.
assertAlmostEqual
(
avg_score
,
expected_avg_tfidf
,
places
=
5
,
msg
=
"
Incorrect adjusted average tf-idf score.
"
)
print
(
f
'
\n
Test 10 - Non-Stop-Words Statistics Score:
\n
The sentence
"
{
target_sentence
}
"
has an adjusted average tf-idf score of
{
avg_score
}
.
'
)
print
(
f
'
\n
Test 10 - Non-Stop-Words Statistics Score:
\n
The sentence
"
{
target_sentence
}
"
has an adjusted average tf-idf score of
{
avg_score
}
.
'
)
if
__name__
==
'
__main__
'
:
if
__name__
==
'
__main__
'
:
...
...
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