smart_interview_analyser / grammar_analysis.py
asmithaaa's picture
Upload 40 files
438c749 verified
raw
history blame contribute delete
357 Bytes
import language_tool_python
tool = language_tool_python.LanguageTool('en-US')
def grammar_score(text):
matches = tool.check(text)
error_count = len(matches)
words = len(text.split())
if words == 0:
return 0
# simple grammar score
score = max(0, 100 - (error_count / words) * 100)
return round(score, 2), error_count