forked from axawzh/TextCleaner
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
36 lines (27 loc) · 1 KB
/
main.py
File metadata and controls
36 lines (27 loc) · 1 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
from cleaner import Clean
output_path = './output/'
input_path = './input/'
# Update the input file names here
input_filename = "demofile.txt"
input_checktruth_filename = 'correcteddemotext.txt'
# File names of the output files
output_filename = 'demooutput.txt'
output_debug_filename = 'demodebug.txt'
output_checktruth_filename = 'checktruth.txt'
# Open local file
text = open(input_path + input_filename, 'r', encoding='UTF-8').read()
cleaner = Clean() # Create cleaner
# Execute cleaner
text_cleaned = cleaner.clean(text, output_path, output_debug_filename, debug=1)
# Check truth
cleaner.checksample(text_cleaned, output_path, input_checktruth_filename, output_checktruth_filename)
# Output
output_file = open(output_path + output_filename, 'w+')
output_file.write(text_cleaned)
output_file.close()
# This class is invoked by postBook.py to execute cleaner
class CleanStart(object):
cleaner = Clean()
def run(self, text):
text_cleaned = self.cleaner.clean_server(text)
return text_cleaned