Spaces:
Paused
Paused
| from flask import Flask, request, render_template | |
| import pandas as pd | |
| import nltk | |
| import re | |
| import requests | |
| from nltk.corpus import stopwords | |
| from nltk.sentiment import SentimentIntensityAnalyzer | |
| nltk.download('averaged_perceptron_tagger') | |
| nltk.download('punkt') | |
| app = Flask(__name__) | |
| def clean_content(content): | |
| content = re.sub(r'[^\w\s]','',content) | |
| content = content.lower() | |
| content = nltk.word_tokenize(content) | |
| content = [word for word in content if word not in set(stopwords.words('english'))] | |
| return content | |
| def sentiment_analysis(content): | |
| sentiment = SentimentIntensityAnalyzer() | |
| sentiment_score = sentiment.polarity_scores(content) | |
| return sentiment_score | |
| def content_quality_detection(content): | |
| content_tokens = clean_content(content) | |
| sentiment_score = sentiment_analysis(content) | |
| content_length = len(content_tokens) | |
| if content_length >= 200 and sentiment_score['compound'] >= 0.5: | |
| return 'High-Quality Content' | |
| elif content_length >= 100 and sentiment_score['compound'] >= 0.2: | |
| return 'Moderate-Quality Content' | |
| else: | |
| return 'Low-Quality Content' | |
| def home(): | |
| return render_template('home.html') | |
| def import_content(): | |
| url = request.form['url'] | |
| df = pd.read_html(requests.get(url).text) | |
| content = df[0].to_string() | |
| quality = content_quality_detection(content) | |
| return render_template('result.html', quality=quality) | |
| if __name__ == '__main__': | |
| app.run(host="0.0.0.0",port=7860,debug=True) | |