-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
326 additions
and
326 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.