-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtext_processing.py
More file actions
62 lines (51 loc) · 2.2 KB
/
text_processing.py
File metadata and controls
62 lines (51 loc) · 2.2 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#######################
# Test Processing I #
#######################
"""
NLP에서 흔히하는 전처리는 소문자 변환, 앞뒤 필요없는 띄어쓰기를 제거하는 등의 텍스트 정규화 (text normalization)입니다.
이번 숙제에서는 텍스트 처리 방법을 파이썬으로 배워보겠습니다.
"""
def normalize(input_string):
"""
인풋으로 받는 스트링에서 정규화된 스트링을 반환함
아래의 요건들을 충족시켜야함
* 모든 단어들은 소문자로 되어야함
* 띄어쓰기는 한칸으로 되어야함
* 앞뒤 필요없는 띄어쓰기는 제거해야함
Parameters:
input_string (string): 영어로 된 대문자, 소문자, 띄어쓰기, 문장부호, 숫자로 이루어진 string
ex - "This is an example.", " EXTRA SPACE "
Returns:
normalized_string (string): 위 요건을 충족시킨 정규회된 string
ex - 'this is an example.'
Examples:
>>> import text_processing as tp
>>> input_string1 = "This is an example."
>>> tp.normalize(input_string1)
'this is an example.'
>>> input_string2 = " EXTRA SPACE "
>>> tp.normalize(input_string2)
'extra space'
"""
normalized_string = None
return normalized_string
def no_vowels(input_string):
"""
인풋으로 받는 스트링에서 모든 모음 (a, e, i, o, u)를 제거시킨 스트링을 반환함
Parameters:
input_string (string): 영어로 된 대문자, 소문자, 띄어쓰기, 문장부호로 이루어진 string
ex - "This is an example."
Returns:
no_vowel_string (string): 모든 모음 (a, e, i, o, u)를 제거시킨 스트링
ex - "Ths s n xmpl."
Examples:
>>> import text_processing as tp
>>> input_string1 = "This is an example."
>>> tp.normalize(input_string1)
"Ths s n xmpl."
>>> input_string2 = "We love Python!"
>>> tp.normalize(input_string2)
''W lv Pythn!'
"""
no_vowel_string = None
return no_vowel_string