Spaces:
Sleeping
Sleeping
File size: 929 Bytes
c8b1fd7 | 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 50 51 52 53 54 55 56 57 | from urllib.parse import urlparse
def extract_domain(url):
"""
Extract domain from URL.
"""
return urlparse(url).netloc
def normalize_text(text):
"""
Remove unnecessary spaces.
"""
return " ".join(text.split())
def round_score(score):
"""
Round scores to 2 decimal places.
"""
return round(score, 2)
def get_trust_level(score):
"""
Convert trust score into label.
"""
if score >= 80:
return "Highly Trustworthy"
elif score >= 60:
return "Moderately Trustworthy"
return "Low Trust"
def is_trusted_domain(domain, trusted_domains):
"""
Check whether the domain is trusted.
"""
return domain.lower() in trusted_domains
def contains_opinion(sentence, opinion_words):
"""
Detect opinion-based sentences.
"""
sentence = sentence.lower()
return any(word in sentence for word in opinion_words) |