MCPcopy Create free account
hub / github.com/chinawithfrank/ChatBotCourse / segment

Function segment

word_segment.py:10–26  ·  view source on GitHub ↗
(input, output)

Source from the content-addressed store, hash-verified

8from jieba import analyse
9
10def segment(input, output):
11 input_file = open(input, "r")
12 output_file = open(output, "w")
13 while True:
14 line = input_file.readline()
15 if line:
16 line = line.strip()
17 seg_list = jieba.cut(line)
18 segments = ""
19 for str in seg_list:
20 segments = segments + " " + str
21 segments = segments + "\n"
22 output_file.write(segments)
23 else:
24 break
25 input_file.close()
26 output_file.close()
27
28if __name__ == '__main__':
29 if 3 != len(sys.argv):

Callers 1

word_segment.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected