Spaces:
Build error
Build error
from flask import Flask, request, render_template | |
import nltk | |
import requests | |
from bs4 import BeautifulSoup | |
nltk.download('punkt') | |
nltk.download('averaged_perceptron_tagger') | |
app = Flask(__name__) | |
def home(): | |
if request.method == "POST": | |
url = request.form["url"] | |
html = requests.get(url).content | |
soup = BeautifulSoup(html, "html.parser") | |
text = soup.get_text() | |
# Use nltk to perform NLP analysis on the text | |
tokens = nltk.word_tokenize(text) | |
tagged = nltk.pos_tag(tokens) | |
# Check for the presence of certain POS tags to determine content quality | |
content_quality = "High Quality" | |
for word, pos in tagged: | |
if pos in ["CC", "DT", "IN", "MD", "PRP", "PRP$", "TO"]: | |
content_quality = "Low Quality" | |
break | |
return render_template("result.html", quality=content_quality) | |
return render_template("home.html") | |
if __name__ == "__main__": | |
app.run(host="0.0.0.0",port=7860,debug=True) | |