Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2021-210
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2021-210
2021-210
Commits
828b798a
Commit
828b798a
authored
Oct 14, 2021
by
shalithadeshan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implement API configuration and and update ontology scripts
parent
0873ac50
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
4 deletions
+43
-4
NLTK_model/API.py
NLTK_model/API.py
+21
-0
NLTK_model/Most Informative Features.txt
NLTK_model/Most Informative Features.txt
+18
-0
NLTK_model/Ontology_scripts.py
NLTK_model/Ontology_scripts.py
+4
-4
No files found.
NLTK_model/API.py
0 → 100644
View file @
828b798a
import
numpy
from
flask
import
Flask
from
flask
import
request
from
flask_cors
import
CORS
,
cross_origin
import
Ontology_scripts
app
=
Flask
(
__name__
)
cors
=
CORS
(
app
)
@
app
.
route
(
"/predict"
,
methods
=
[
'POST'
])
@
cross_origin
()
def
predict
():
data
=
request
.
get_json
()
print
(
data
[
'title'
])
print
(
data
[
'content'
])
prediction
=
Ontology_scripts
.
analyzePost
(
data
[
'title'
],
data
[
'content'
],
data
[
'reviews'
])
return
{
"pred"
:
str
(
prediction
)}
if
__name__
==
'__main__'
:
app
.
run
(
debug
=
True
,
port
=
5002
,
host
=
"0.0.0.0"
)
NLTK_model/Most Informative Features.txt
0 → 100644
View file @
828b798a
:( = True Negati : Positi = 2647.8 : 1.0
:) = True Positi : Negati = 1272.4 : 1.0
follower = True Positi : Negati = 26.6 : 1.0
bam = True Positi : Negati = 26.3 : 1.0
sad = True Negati : Positi = 25.0 : 1.0
x15 = True Negati : Positi = 23.0 : 1.0
followed = True Negati : Positi = 19.8 : 1.0
appreciate = True Positi : Negati = 19.0 : 1.0
community = True Positi : Negati = 18.3 : 1.0
ugh = True Negati : Positi = 16.3 : 1.0
glad = True Positi : Negati = 15.8 : 1.0
goodnight = True Positi : Negati = 15.0 : 1.0
welcome = True Positi : Negati = 14.6 : 1.0
perfect = True Positi : Negati = 13.0 : 1.0
kill = True Negati : Positi = 13.0 : 1.0
What this tells you is the ratio of occurences in negative to positive, or visa versa, for every word. So here, we can see that the term ":(" appears 2647.8 more times as often in negative reviews as it does in positive reviews.
\ No newline at end of file
NLTK_model/Ontology_scripts.py
View file @
828b798a
...
...
@@ -97,13 +97,13 @@ def analyzePost(title, content, reviews):
if
titleSentiment
==
"Positive"
:
points
+=
2
else
:
points
-=
2
points
-=
0
content_tokens
=
remove_noise
(
word_tokenize
(
content
))
contentSentiment
=
classifier
.
classify
(
dict
([
token
,
True
]
for
token
in
content_tokens
))
if
contentSentiment
==
"Positive"
:
points
+=
5
else
:
points
-=
5
points
-=
0
points
+=
len
(
reviews
)
for
review
in
reviews
:
review_tokens
=
remove_noise
(
word_tokenize
(
review
))
...
...
@@ -111,7 +111,7 @@ def analyzePost(title, content, reviews):
if
reviewSentiment
==
"Positive"
:
points
+=
1
else
:
points
-=
1
points
-=
0
return
points
print
(
analyzePost
(
"watch your dog's health"
,
"bvjkdn dbfjksdn"
,
[
"gdfsdff"
]))
#
print(analyzePost("watch your dog's health", "bvjkdn dbfjksdn", ["gdfsdff"]))
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