Spaces:
Runtime error
Runtime error
Download src/evaluator.py from sujitv14/Automated_Web_Development_Lab_Evaluation: direct link, hf CLI and curl.
- Browser
- Download file 804 Bytes
-
https://huggingface.co/spaces/sujitv14/Automated_Web_Development_Lab_Evaluation/resolve/main/src/evaluator.py
- Command line
-
hf download hf://spaces/sujitv14/Automated_Web_Development_Lab_Evaluation/src/evaluator.py
-
curl -L -o evaluator.py https://huggingface.co/spaces/sujitv14/Automated_Web_Development_Lab_Evaluation/resolve/main/src/evaluator.py
804 Bytes
| from bs4 import BeautifulSoup | |
| def evaluate_html(content): | |
| score = 0 | |
| feedback = [] | |
| soup = BeautifulSoup(content, 'html.parser') | |
| if soup.html: | |
| score += 1 | |
| else: | |
| feedback.append("Missing <html> tag") | |
| if soup.head and soup.title: | |
| score += 1 | |
| else: | |
| feedback.append("Missing <head> or <title>") | |
| if soup.body: | |
| score += 1 | |
| else: | |
| feedback.append("Missing <body>") | |
| tags = ['p', 'h1', 'href', 'h2', 'img', 'a', 'table'] | |
| used = [tag for tag in tags if soup.find(tag)] | |
| if len(used) >= 3: | |
| score += 1 | |
| else: | |
| feedback.append("Use at least 3 different HTML tags") | |
| if len(soup.text.strip()) > 20: | |
| score += 1 | |
| else: | |
| feedback.append("Content too short") | |
| return score, feedback |