Remove redundant stuff
Browse files- utils/clean.py +4 -2
utils/clean.py
CHANGED
@@ -23,16 +23,18 @@ del normalize_chars
|
|
23 |
r_space_cleaner = re.compile(r'\s+')
|
24 |
r_space_normalizer = re.compile(r'[\U00003000\U0000205F\U0000202F\U0000200A\U00002000-\U00002009\U00001680\U000000A0\t]+| {2,}')
|
25 |
r_newline_cleaner = re.compile(r'\n+')
|
26 |
-
r_single_apostrophe_normalizer = re.compile(r'[
|
27 |
r_double_apostrophe_normalizer = re.compile(r'[“”]')
|
28 |
r_strange_apostrophe_normalizer = re.compile(r'[『』]')
|
|
|
29 |
|
30 |
def clean(text):
|
31 |
text = text.translate(normal_map)
|
32 |
text = r_space_cleaner.sub(' ', text)
|
33 |
-
text = r_space_normalizer.sub(' ', text)
|
34 |
text = r_newline_cleaner.sub(' ', text)
|
35 |
text = r_single_apostrophe_normalizer.sub('\'', text)
|
36 |
text = r_double_apostrophe_normalizer.sub('\"', text)
|
37 |
text = r_strange_apostrophe_normalizer.sub('\"', text)
|
|
|
38 |
return text
|
|
|
23 |
r_space_cleaner = re.compile(r'\s+')
|
24 |
r_space_normalizer = re.compile(r'[\U00003000\U0000205F\U0000202F\U0000200A\U00002000-\U00002009\U00001680\U000000A0\t]+| {2,}')
|
25 |
r_newline_cleaner = re.compile(r'\n+')
|
26 |
+
r_single_apostrophe_normalizer = re.compile(r'[’]')
|
27 |
r_double_apostrophe_normalizer = re.compile(r'[“”]')
|
28 |
r_strange_apostrophe_normalizer = re.compile(r'[『』]')
|
29 |
+
r_url_cleaner = re.compile(r'^https?:\/\/.*[\r\n]*')
|
30 |
|
31 |
def clean(text):
|
32 |
text = text.translate(normal_map)
|
33 |
text = r_space_cleaner.sub(' ', text)
|
34 |
+
#text = r_space_normalizer.sub(' ', text)
|
35 |
text = r_newline_cleaner.sub(' ', text)
|
36 |
text = r_single_apostrophe_normalizer.sub('\'', text)
|
37 |
text = r_double_apostrophe_normalizer.sub('\"', text)
|
38 |
text = r_strange_apostrophe_normalizer.sub('\"', text)
|
39 |
+
text = r_url_cleaner.sub('[File URL attached]', text)
|
40 |
return text
|