https://github.com/willf/segment
A tool to segment text based on frequencies and the Viterbi algorithm "#TheBoyWhoLived" => ['#', 'The', 'Boy', 'Who', 'Lived']
https://github.com/willf/segment
python segment viterbi-algorithm
Last synced: 2 months ago
JSON representation
A tool to segment text based on frequencies and the Viterbi algorithm "#TheBoyWhoLived" => ['#', 'The', 'Boy', 'Who', 'Lived']
- Host: GitHub
- URL: https://github.com/willf/segment
- Owner: willf
- Created: 2015-04-20T16:37:26.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2016-04-23T04:51:08.000Z (about 9 years ago)
- Last Synced: 2025-04-10T20:13:03.085Z (3 months ago)
- Topics: python, segment, viterbi-algorithm
- Language: Python
- Homepage:
- Size: 2.13 MB
- Stars: 82
- Watchers: 5
- Forks: 15
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
This module segments text according word frequency using the Viterbi algorithm. Probably
due to Peter Norvig somehow.Three sources of frequency information is provided.
One is from the Google NGram corpus, a general web corpus.
The second is from the Rovereto Twitter N-Gram Corpus, which is better for some Twitter data.
The third is from a webcrawl dataset of anchor text provided
by Vinay Goel of the Internet Archive.> from segment.segmenter import Analyzer
> e = Analyzer('en')
> e.segment("AbeLincoln")
['Abe', 'Lincoln']
> e.segment("BieberHeartsBeliebers")
['Bi', 'e', 'ber', 'Hearts', 'Be', 'lieber', 's']
> t = Analyzer('twitter')
> t.segment("BieberHeartsBeliebers")
['Bieber', 'Hearts', 'Beliebers']
> t = Analyzer('anchor')
> t.segment("wordpress&sex")
['wordpress', '&', 'sex']