开源软件名称:pluskid/pymmseg-cpp开源软件地址:https://github.com/pluskid/pymmseg-cpp开源编程语言:C++ 74.5%开源软件介绍:pymmseg-cpp
DESCRIPTION:pymmseg-cpp is a Python interface to rmmseg-cpp. rmmseg-cpp is a high performance Chinese word segmentation utility for Ruby. However, the core part is written in C++ independent of Ruby. So I decide to write a Python interface for it in order to use it in my Python project. FEATURES:
SYNOPSIS:A simple scriptpymmseg-cpp provides a simple script (bin/pymmseg), which can read the text from standard input and print the segmented result to standard output. Try pymmseg -h for help on the options. As a Python moduleTo use pymmseg-cpp in normal Python program, first import the module and init by loading the dictionaries: import mmseg
mmseg.Dictionary.load_dictionaries() If you want to load your own customized dictionaries, please customize
Then create an Algorithm iterable object and iterate through it: algor = mmseg.Algorithm(text)
for tok in algor:
print '%s [%d..%d]' % (tok.text, tok.start, tok.end) Customize the dictionaryYou can also load your own character dictionary or word dictionary in the following way: import mmseg
mmseg.Dictionary.load_words('customize_words.dic')
mmseg.Dictionary.load_chars('customize_chars.dic') Format for chars.dic
Format for words.dic
WARNING
REQUIREMENTS:
INSTALLATION:pymmseg-cpp should be installed using pip:
or setuptools:
You can also download the latest code from github and build it yourself:
Then copy the pymmseg directory to your Python's package path. e.g.
Alternative VersionThere is a package called
CONTRIBUTIONS:Python native extension code contributed by German M. Bravo (Kronuz) for a ~400% performance boost under Python. LICENSE:(The MIT License) Copyright (c) 2012 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论