Git Product home page Git Product logo

wordseg's Introduction

This is a small library which can segment Chinese phrases.

The library contains only one class "wordseg"

wordseg.load_dict(dictionary_file)
Load the dictionary.
There is a default dictionary under data, based on People's Daily materials, and you can provide your own

segment(phrase, include_cjk_word, include_cjk_ideogram)
Segment phrase.
If include_cjk_word is True, result includes all non-CJK words and CJK phrase is broken into words.
If include_cjk_ideogram is True, result includes all non-CJK words and CJK phrase is broken into ideograms.
If both are set, result includes both segmentations, note non-CJK words will be included twice.

This library also do some transformations to latin words, i.e. "Café" will be transformed into "cafe", this could be usedful when you are build full-text search index as user may want "Café" while they are searching "cafe".

TODO:
1. Now the lib uses a weighted shortest path algorithm to break CJK phrases, with some optimizations, generally the result should be better than MMSeg(http://technology.chtsai.org/mmseg/) and close to HMM, but there still some error cases, try "make test" to check out. This cannot be easily solved without more domain specific materials and more advanced algorithm, such as HMM.
2. Latin transformation should be configurable, this is not priority as I'm using this lib in a search engine :-)
3. CJK names, this is a major lack
4. CJK numbers, well, low priority
5. Code cleanup, a lot of test/debug code still exists.

Thanks to [email protected] and his/her very easy-to-use UTF8CPP(http://utfcpp.sourceforge.net/) project; also thanks to C++ standard committee for their slow-and-buggy Unicode I/O support in STL.

wordseg's People

Contributors

windoze avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.