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
SOFT Core
SOFT 161 and 162
sentiment
Merge requests
!1
Ians branch
Code
Review changes
Check out branch
Download
Patches
Plain diff
Closed
Ians branch
courtneymflohr/sentiment:ians_branch
into
master
Overview
0
Commits
8
Changes
2
Closed
courtneymflohr
requested to merge
courtneymflohr/sentiment:ians_branch
into
master
3 years ago
Overview
0
Commits
8
Changes
2
Expand
Look up reviews by number
0
0
Merge request reports
Compare
master
master (base)
and
latest version
latest version
f96ecbc3
8 commits,
3 years ago
2 files
+
74
−
1
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
Search (e.g. *.vue) (Ctrl+P)
sentiment.py
+
63
−
1
Options
@@ -12,8 +12,70 @@ class MenuOption(Enum):
EXIT
=
'
Exit the program
'
with
open
(
'
sentiment.txt
'
)
as
a_file
:
try
:
reviews
=
[]
tokens
=
set
()
for
line
in
a_file
:
stripped_line
=
line
.
strip
()
stripped_line_tokens
=
stripped_line
[
2
:].
split
()
for
element
in
stripped_line_tokens
:
tokens
.
add
(
element
)
reviews
.
append
(
stripped_line
)
except
FileNotFoundError
:
print
(
"
File could not be read.
"
)
print
(
reviews
[
0
])
def
display_menu
(
options
):
print
(
'
Choose an option:
'
)
for
i
in
range
(
len
(
options
)):
print
(
'
\t\t
'
+
str
(
i
+
1
)
+
'
.
'
+
options
[
i
].
value
)
def
show_reviews
():
beginning
=
int
(
input
(
'
Enter a beginning review number from 1 to 8529:
'
))
-
1
ending
=
int
(
input
(
'
Enter an ending review number from 2 to 8529:
'
))
-
1
while
beginning
<=
ending
:
print
(
'
Review #
'
+
str
(
beginning
+
1
)
+
"
:
"
+
reviews
[
beginning
])
beginning
+=
1
def
show_tokens
():
token
=
str
(
input
(
'
Enter a Token:
'
))
token
=
token
.
lower
()
print
()
if
token
in
tokens
:
print
(
f
'
The token
{
token
}
is one of the
{
len
(
tokens
)
}
unique tokens that appear in the training data.
'
)
else
:
print
(
f
'
The token
{
token
}
is not one of the
{
len
(
tokens
)
}
unique tokens that appear in the training data.
'
)
print
()
def
choose_option
(
options
):
x
=
2
while
x
>
0
:
display_menu
(
options
)
try
:
choice
=
int
(
input
(
'
Enter a number from 1 to 8:
'
))
if
choice
is
8
:
break
elif
1
>
choice
>
8
:
raise
ValueError
elif
choice
is
1
:
show_reviews
()
elif
choice
is
2
:
show_tokens
()
else
:
print
(
options
[
choice
-
1
])
except
ValueError
:
print
(
'
Please enter a valid, in-range number.
'
)
def
main
():
pass
options
=
tuple
(
MenuOption
)
choose_option
(
options
)
if
__name__
==
'
__main__
'
:
Loading