Skip to content

Commit

Permalink
refacter: Model updated | 파일분리 확인
Browse files Browse the repository at this point in the history
  • Loading branch information
yujin37 committed Nov 5, 2023
1 parent 5ac60de commit a950a77
Show file tree
Hide file tree
Showing 6 changed files with 326 additions and 326 deletions.
57 changes: 57 additions & 0 deletions Model/ExpressCheck.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
from PyKomoran import *
import re

komoran = Komoran('STABLE')

#53번 표현 가점, 감점
def Express(sentence):
#문장 끝 표현 체크, 감점
check = (komoran.get_plain_text(sentence[0][:]).split(' '))
for i in range(len(check)):
temp = check[i].split('/')
check[i] = temp
cnt = 0
for i in range(len(check)): #-ㅂ/ 습니다, -아/-어요
if check[i][0].endswith('습니다') or check[i][0].endswith('ㅂ니다') or check[i][0].endswith('요') or check[i][0].endswith('아요') or check[i][0].endswith('어요') :
cnt+=1

#대조 표현 사용, 가점
pattern = re.compile(r'지만|는데 반해|와 달리|과 달리')
matches = re.findall(pattern, sentence[0])
result = '문장 끝 표현 ' + str(cnt) + '회, 대조표현 사용 ' + str(len(matches)) + '회 사용함.'
result_cnt = -1 * cnt + len(matches)
if result_cnt < 0:
result_cnt = 0
response = {"표현 검사" : result , "점수" : result_cnt}
return response

#51번, 52번
def ExpressShort(sentence, answer):
cnt_Result = []
#print(sentence[:], answer[:])
for i in range(len(answer)):
cnt = 0
sen = (komoran.get_plain_text(sentence[0]).split(' '))
sen2 = (komoran.get_plain_text(answer[0]).split(' '))

for i in range(len(sen)):
temp = sen[i].split('/')
sen[i] = temp
for i in range(len(sen2)):
temp = sen2[i].split('/')
sen2[i] = temp
if sen[-1][1] == sen2[-1][1] and sen[-1][0] == sen2[-1][0]: #모든 값이 같은 경우
#print('동일', sen[-1][1], sen2[-1][1])
cnt=1
elif sen[-1][1] == sen2[-1][1]: #문법 종류는 맞으나 완전히 답안이 같지 않은 경우
cnt = 0.5
else:
#print('비동일', sen[-1][1], sen2[-1][1])
cnt = 0
cnt_Result.append(cnt)


result = '문장 끝 표현 ' + str(max(cnt_Result)) + '회 사용'

response = {"표현 검사" : result , "점수" : cnt}
return response
Loading

0 comments on commit a950a77

Please sign in to comment.