오탈자 검사에서 오타와 추가된 글자는 감점에 포함하지 않고, 누락된 글자만 감점되도록 수정

This commit is contained in:
2025-02-13 18:19:14 +09:00
parent 2ec1b8dbd4
commit 99da118a40
13 changed files with 2054 additions and 543 deletions

View File

@@ -349,6 +349,8 @@ class XMLScorer:
# 차이점을 정리하여 result_diff에 저장
result_diff = []
# 감점을 위한 누락 된 단어만 따로 리스트로 저장
missing_list = []
skip_next = False
for i, line in enumerate(diff_list):
@@ -357,14 +359,18 @@ class XMLScorer:
continue
# diff_list의 line 시작이 '-'이면서 다음 line이 '+'이면 두 line을 붙여서 맞춤법이 틀린 단어로 판단
if line.startswith('- '):
# 오타
if i + 1 < len(diff_list) and diff_list[i + 1].startswith('+ '):
line = line.replace('- ', '-')
next = diff_list[i + 1].replace('+ ', '')
result_diff.append(line+'=>'+next)
skip_next = True
# 누락
else:
line = line.replace('- ', '-')
result_diff.append(line)
missing_list.append(line)
# 없어도 되는 글자가 있는 경우
elif line.startswith('+ '):
line = line.replace('+ ', '+')
result_diff.append(line)
@@ -375,7 +381,8 @@ class XMLScorer:
# print(diff)
# result_diff 배열의 길이를 맨 앞에 저장
temp = 40 - min(len(result_diff)*2, 40)
# temp = 40 - min(len(result_diff)*2, 40)
temp = 40 - min(len(missing_list)*2, 40)
self.set_typo_score(temp)
result_diff.insert(0, temp)
@@ -515,17 +522,18 @@ def main():
scoring_criteria_path = r'./scoring_criteria_2512D.json'
# xml(hml)파일 디렉토리 경로
xml_directory = r'./output'
# xml_directory = r'./output'
# xml_directory = r'./output/1교시'
# xml_directory = r'./output/2교시'
# xml_directory = r'./output/3교시'
xml_directory = r'./output/4교시'
# 오탈자 체크를 위한 정답 파일 경로
# answer_path = r'./output/정답.hml'
# answer_path = r'./output/2512A.hml'
# answer_path = r'./output/2512B.hml'
# answer_path = r'./output/2512C.hml'
answer_path = r'./output/2512D.hml'
# answer_path = r'./output/1교시/2512A.hml'
# answer_path = r'./output/2교시/2512B.hml'
# answer_path = r'./output/3교시/2512C.hml'
answer_path = r'./output/4교시/2512D.hml'
# 채점 클래스 초기화