-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain2.py
More file actions
43 lines (33 loc) Β· 1.86 KB
/
main2.py
File metadata and controls
43 lines (33 loc) Β· 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# -*- coding: utf-8 -*-
from time import time
start = time()
import joblib
from konlpy.tag import Okt
import pandas as pd
from sentence_transformers import SentenceTransformer
import os
def getVerbAndNoun(text):
okt = Okt()
df = pd.DataFrame(okt.pos(text), columns=['morph', 'tag'])
df.set_index('tag', inplace=True)
return df['morph'].values
PK_NUM = 69
df = pd.read_csv('problem_2.csv')
essays = df['essay']
model_name = f'/home/ubuntu/anaconda3/envs/nonmentor/ease_real/models/Problem_{PK_NUM}/model.pkl'
model = joblib.load(model_name)
sbert = SentenceTransformer('/home/ubuntu/anaconda3/envs/nonmentor/ease_real/models/SBERT')
from ease.grade import grade
essay1 = '''μ μλ¬Έ (κ°)λ μΈλ¬Ό μ νμ μ μ€νκ² μ κ·Όνλ νλ¦Ώνκ³Ό κ³Όκ°νκ² λμ νλ λν€νΈν
νμΌλ‘ λΆλ₯νκ³ μλ€. μ΄μ λ°λ₯΄λ©΄ (λ€)μ (λ§)μ 주체λ€μ νλ¦Ών, (λ), (λΌ)μ 주체λ€μ λν€νΈν
νμΌλ‘ λΆλ₯λλ€. (λ€)λ μ₯μκ° κ³΅κ²©κ³Ό μλΉλ₯Ό μ μ€νκ² κ²°μ νκ³ , κΈ°λ―Έμ λ§κ² μ μ€νκ² λμ²ν΄μΌ ν¨μ κ°μ‘°νλ€. (λ§)μ 리λλ€μ κΈλ³νλ μν©μμλ μ€ν¨μ λν λλ €μ λλ¬Έμ μμ¬κ²°μ μ μ§λμΉκ² μ μ€νκ² νκ³ μ μν μ§νμ ννΌνλ€. λ°λ©΄ (λ)μ νΌμΉ΄μλ μ λͺ
ν νκ°μμμλ λΆκ΅¬νκ³ μμ£Όνμ§ μκ³ μλ‘μ΄ μμμ λμ νλ λͺ¨μ΅μ 보μ¬μ€λ€. (λΌ)μ βλβλ νμΆμ μν΄ λͺ©μ¨μ κ±Έκ³ λ°λ€μ λͺΈμ λμ§λ κ³Όκ°ν λμ μ νκ³ μλ€.
'''
min_sim = 1e9
for i, essay in enumerate(essays):
score = grade(model, essay1, PK_NUM, sbert=sbert)
# print(score['d_score'][0])
# print(score['n_score'][0])
# print(score['p_score'][0])
print(f'{i}: {score["similarity"]}')
if min_sim > score["similarity"]:
min_sim = score["similarity"]
end = time()
print(f'κ²½κ³Όμκ°: {end-start}')