-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchars_analysis.py
62 lines (48 loc) · 1.57 KB
/
chars_analysis.py
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# API: https://aiopen.etri.re.kr/guide_wiseNLU.php#group07
from imports import ACCESS_KEY
from hanspell import spell_checker
import urllib3
import json
def adjustSpacing(transcripts):
# 띄어쓰기 없애기
# new_transcripts = []
# for i in range(len(transcripts)):
# new_sent = transcripts[i].replace(" ", '')
# new_transcripts.append(new_sent)
result = spell_checker.check(transcripts)
return result
def countNumOfWords(transcript):
count = 0
for i in range(len(transcript)):
if transcript[i]==" ":
count+=1
return count+1
def checkClosingRemarks(transcript):
openApiURL = "http://aiopen.etri.re.kr:8000/WiseNLU_spoken"
accessKey = ACCESS_KEY
analysisCode = "morp"
text = transcript
result = False
requestJson = {
"access_key": accessKey,
"argument": {
"text" : text,
"analysis_code": analysisCode
}
}
http = urllib3.PoolManager()
response = http.request(
"POST",
openApiURL,
headers={"Content-Type": "application/json; charset=UTF-8"},
body = json.dumps(requestJson)
)
# check closing remarks are appropriate
return_objects = json.loads(response.data)['return_object']
sentences = return_objects["sentence"]
morps = sentences[0]["morp"]
for morp in morps:
if morp["type"]=="EF" or (morp["type"]=="EC" and morp["lemma"][-1]=="요"):
if morp["position"] >= len(text.encode())-10: #TODO: 맺음말 위치 확인
result = True
return result