-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathexample.py
More file actions
35 lines (25 loc) · 771 Bytes
/
example.py
File metadata and controls
35 lines (25 loc) · 771 Bytes
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
# -*- coding: utf-8 -*-
#################################################
# example.py
# ESA++
#
# Copyright (c) 2014-2017, Chi-En Wu
# Distributed under The BSD 3-Clause License
#################################################
from __future__ import print_function, unicode_literals
from esapp_python import Segmenter
def main():
sequences = ['這是一隻可愛的小花貓',
'一隻貓',
'真可愛的貓',
'這是一隻花貓',
'小貓真可愛']
segmenter = Segmenter(0.1)
for s in sequences:
segmenter.fit(s)
segmenter.optimize(10)
for s in sequences:
words = segmenter.segment(s)
print(' '.join(words))
if __name__ == '__main__':
main()