Commit 828b798a authored by shalithadeshan's avatar shalithadeshan

implement API configuration and and update ontology scripts

parent 0873ac50
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")
:( = 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
......@@ -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"]))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment