File size: 1,562 Bytes
388604c
 
 
 
6b9ee5e
388604c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5ec43a8
388604c
 
 
 
 
11d28a4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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'

@app.route('/')
def home():
    return render_template('home.html')

@app.route('/', methods=['POST'])
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)