Team Ai
Apppublic

sujitv14/Automated_Web_Development_Lab_Evaluation

sourceHugging Faceupdated 7mo agoView on Hugging Face
0likes
evaluator.py37 linesDownload Raw Back to src
1from bs4 import BeautifulSoup2 3def evaluate_html(content):4    score = 05    feedback = []6 7    soup = BeautifulSoup(content, 'html.parser')8 9    if soup.html:10        score += 111    else:12        feedback.append("Missing <html> tag")13 14    if soup.head and soup.title:15        score += 116    else:17        feedback.append("Missing <head> or <title>")18 19    if soup.body:20        score += 121    else:22        feedback.append("Missing <body>")23 24    tags = ['p', 'h1', 'href', 'h2', 'img', 'a', 'table']25    used = [tag for tag in tags if soup.find(tag)]26 27    if len(used) >= 3:28        score += 129    else:30        feedback.append("Use at least 3 different HTML tags")31 32    if len(soup.text.strip()) > 20:33        score += 134    else:35        feedback.append("Content too short")36 37    return score, feedback