diff --git a/Python-TextBlob/.idea/.gitignore b/Python-TextBlob with Flask/.idea/.gitignore similarity index 100% rename from Python-TextBlob/.idea/.gitignore rename to Python-TextBlob with Flask/.idea/.gitignore diff --git a/Python-TextBlob with Flask/.idea/Python-TextBlob with Flask.iml b/Python-TextBlob with Flask/.idea/Python-TextBlob with Flask.iml new file mode 100644 index 0000000..2533b8d --- /dev/null +++ b/Python-TextBlob with Flask/.idea/Python-TextBlob with Flask.iml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Python-TextBlob/.idea/inspectionProfiles/Project_Default.xml b/Python-TextBlob with Flask/.idea/inspectionProfiles/Project_Default.xml similarity index 100% rename from Python-TextBlob/.idea/inspectionProfiles/Project_Default.xml rename to Python-TextBlob with Flask/.idea/inspectionProfiles/Project_Default.xml diff --git a/Python-TextBlob/.idea/inspectionProfiles/profiles_settings.xml b/Python-TextBlob with Flask/.idea/inspectionProfiles/profiles_settings.xml similarity index 100% rename from Python-TextBlob/.idea/inspectionProfiles/profiles_settings.xml rename to Python-TextBlob with Flask/.idea/inspectionProfiles/profiles_settings.xml diff --git a/Python-TextBlob/.idea/misc.xml b/Python-TextBlob with Flask/.idea/misc.xml similarity index 52% rename from Python-TextBlob/.idea/misc.xml rename to Python-TextBlob with Flask/.idea/misc.xml index 0a67c5e..2f252d2 100644 --- a/Python-TextBlob/.idea/misc.xml +++ b/Python-TextBlob with Flask/.idea/misc.xml @@ -1,7 +1,7 @@ - - + \ No newline at end of file diff --git a/Python-TextBlob/.idea/modules.xml b/Python-TextBlob with Flask/.idea/modules.xml similarity index 72% rename from Python-TextBlob/.idea/modules.xml rename to Python-TextBlob with Flask/.idea/modules.xml index e48df9a..a5e3e48 100644 --- a/Python-TextBlob/.idea/modules.xml +++ b/Python-TextBlob with Flask/.idea/modules.xml @@ -2,7 +2,7 @@ - + \ No newline at end of file diff --git a/Python-TextBlob/.idea/vcs.xml b/Python-TextBlob with Flask/.idea/vcs.xml similarity index 100% rename from Python-TextBlob/.idea/vcs.xml rename to Python-TextBlob with Flask/.idea/vcs.xml diff --git a/Python-TextBlob with Flask/__pycache__/app.cpython-312.pyc b/Python-TextBlob with Flask/__pycache__/app.cpython-312.pyc new file mode 100644 index 0000000..dbf6ccf Binary files /dev/null and b/Python-TextBlob with Flask/__pycache__/app.cpython-312.pyc differ diff --git a/Python-TextBlob with Flask/app.py b/Python-TextBlob with Flask/app.py new file mode 100644 index 0000000..3942b89 --- /dev/null +++ b/Python-TextBlob with Flask/app.py @@ -0,0 +1,30 @@ +from flask import Flask, request, render_template, jsonify +from textblob import TextBlob + + +app = Flask(__name__) + + +@app.route('/') +def home(): + return render_template('index.html') + +@app.route('/analyzereview', methods=['POST']) +def analyzereview(): + data = request.get_json() + review = data.get('review') + blob = TextBlob(review) + sentiment = blob.sentiment.polarity + + if sentiment > 0: + result = "Positive Review✅🎉" + elif sentiment < 0: + result = "Negative Review🫤" + elif sentiment == 0: + result = "Neutral Review👍" + + return jsonify({'sentiment': result}) + + +if __name__ == '__main__': + app.run() diff --git a/Python-TextBlob with Flask/static/js/script.js b/Python-TextBlob with Flask/static/js/script.js new file mode 100644 index 0000000..1b22ff4 --- /dev/null +++ b/Python-TextBlob with Flask/static/js/script.js @@ -0,0 +1,16 @@ + document.getElementById('review-form').addEventListener('submit', async function(event) { + event.preventDefault(); + + const reviewText = document.getElementById('review').value; + + const response = await fetch('/analyzereview', { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ review: reviewText }) + }); + + const data = await response.json(); + document.getElementById('result').textContent = 'Sentiment: ' + data.sentiment; + }); \ No newline at end of file diff --git a/Python-TextBlob with Flask/templates/index.html b/Python-TextBlob with Flask/templates/index.html new file mode 100644 index 0000000..2f48b5e --- /dev/null +++ b/Python-TextBlob with Flask/templates/index.html @@ -0,0 +1,75 @@ + + + + + + Review Sentiment Analysis + + + + +
+

Review Sentiment Analysis

+
+
+ +
+
+
+
+ + + + + diff --git a/Python-TextBlob/.idea/Python-TextBlob.iml b/Python-TextBlob/.idea/Python-TextBlob.iml deleted file mode 100644 index 2c80e12..0000000 --- a/Python-TextBlob/.idea/Python-TextBlob.iml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/Python-TextBlob/main.py b/Python-TextBlob/main.py deleted file mode 100644 index a8e0342..0000000 --- a/Python-TextBlob/main.py +++ /dev/null @@ -1,12 +0,0 @@ -from textblob import TextBlob -# import nltk -# nltk.download('all') // to download natural language toolkit - -testimonial = TextBlob("Textblob is amazingly simple to use. What great fun!") - - -if __name__ == '__main__': - print(testimonial.sentiment) - print(testimonial.sentiment.polarity) - -