Documentation ¶
Overview ¶
Package posseg is the Golang implementation of Jieba's posseg module.
Example ¶
package main import ( "fmt" "github.com/fumiama/jieba/posseg" ) func main() { seg, err := posseg.LoadDictionaryAt("../dict.txt") if err != nil { panic(err) } for _, segment := range seg.Cut("我爱北京天安门", true) { fmt.Printf("%s %s\n", segment.Text(), segment.Pos()) } }
Output: 我 r 爱 v 北京 ns 天安门 ns
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Dictionary ¶
A Dictionary represents a thread-safe dictionary used for word segmentation.
func (*Dictionary) AddToken ¶
func (d *Dictionary) AddToken(token dictionary.Token)
AddToken adds one token
func (*Dictionary) Frequency ¶
func (d *Dictionary) Frequency(key string) (float64, bool)
Frequency returns the frequency and existence of give word
func (*Dictionary) Load ¶
func (d *Dictionary) Load(tokens ...dictionary.Token)
Load loads all tokens
type Segment ¶
type Segment struct {
// contains filtered or unexported fields
}
Segment represents a word with it's POS
type Segmenter ¶
type Segmenter Dictionary
Segmenter is a Chinese words segmentation struct.
func LoadDictionary ¶
LoadDictionary loads dictionary from given file name. Everytime LoadDictionaryAt is called, previously loaded dictionary will be cleard.
func LoadDictionaryAt ¶
LoadDictionaryAt loads dictionary from given file name. Everytime LoadDictionaryAt is called, previously loaded dictionary will be cleard.
func (*Segmenter) Cut ¶
Cut cuts a sentence into words. Parameter hmm controls whether to use the Hidden Markov Model.
func (*Segmenter) LoadUserDictionary ¶
LoadUserDictionary loads a user specified dictionary, it must be called after LoadDictionary, and it will not clear any previous loaded dictionary, instead it will override exist entries.
func (*Segmenter) LoadUserDictionaryAt ¶
LoadUserDictionaryAt loads a user specified dictionary, it must be called after LoadDictionary, and it will not clear any previous loaded dictionary, instead it will override exist entries.