Spaces:
Sleeping
Sleeping
Update Deliverable2.py
Browse files- Deliverable2.py +15 -8
Deliverable2.py
CHANGED
@@ -33,15 +33,22 @@ class URLValidator:
|
|
33 |
sentiment_result = self.sentiment_analyzer(content[:512])[0]
|
34 |
return 100 if sentiment_result["label"] == "POSITIVE" else 50 if sentiment_result["label"] == "NEUTRAL" else 30
|
35 |
|
36 |
-
def
|
37 |
-
|
38 |
-
|
39 |
-
|
|
|
|
|
|
|
|
|
40 |
return {
|
41 |
-
"
|
42 |
-
"
|
43 |
-
"
|
44 |
-
|
|
|
|
|
|
|
45 |
}
|
46 |
|
47 |
queries_urls = [
|
|
|
33 |
sentiment_result = self.sentiment_analyzer(content[:512])[0]
|
34 |
return 100 if sentiment_result["label"] == "POSITIVE" else 50 if sentiment_result["label"] == "NEUTRAL" else 30
|
35 |
|
36 |
+
def validate_url(user_query, url_to_check):
|
37 |
+
try:
|
38 |
+
result = validator.rate_url_validity(user_query, url_to_check)
|
39 |
+
print("Validation Result:", result) # Debugging line
|
40 |
+
|
41 |
+
if "Validation Error" in result:
|
42 |
+
return {"Error": result["Validation Error"]}
|
43 |
+
|
44 |
return {
|
45 |
+
"Content Relevance Score": f"{result['raw_score']['Content Relevance']} / 100",
|
46 |
+
"Bias Score": f"{result['raw_score']['Bias Score']} / 100",
|
47 |
+
"Final Validity Score": f"{result['raw_score']['Final Validity Score']} / 100"
|
48 |
+
}
|
49 |
+
except Exception as e:
|
50 |
+
return {"Error": str(e)}
|
51 |
+
|
52 |
}
|
53 |
|
54 |
queries_urls = [
|