1
0
mirror of https://github.com/fumiama/jieba.git synced 2026-06-27 15:40:32 +08:00

removed dict.go, functions move to util.go, also use interface to simplify code

This commit is contained in:
Wang Bin
2015-03-25 18:28:37 +08:00
parent 7fe5e7d4c4
commit 59da5b5e3a
7 changed files with 57 additions and 115 deletions

View File

@@ -26,8 +26,8 @@ type Posseg struct {
}
func (p *Posseg) AddEntry(entry *jiebago.Entry) {
if len(entry.Tag) > 0 {
p.Flag[Entry.Word] = strings.TrimSpace(Entry.Flag)
if len(entry.Flag) > 0 {
p.Flag[entry.Word] = strings.TrimSpace(entry.Flag)
}
p.Add(entry.Word, entry.Freq)
}
@@ -41,24 +41,13 @@ func NewPosseg(dictFileName string) (*Posseg, error) {
if err != nil {
return nil, err
}
wtfs, err := jiebago.ParseDictFile(dictFilePath)
for _, wtf := range wtfs {
p.Add(wtf)
}
return p, nil
err = jiebago.LoadDict(p, dictFilePath, true)
return p, err
}
// Load user specified dictionary file.
func (p *Posseg) LoadUserDict(dictFilePath string) error {
wtfs, err := jiebago.ParseDictFile(dictFilePath)
if err != nil {
return err
}
for _, wtf := range wtfs {
p.Add(wtf)
}
return nil
return jiebago.LoadDict(p, dictFilePath, true)
}
func (p *Posseg) cutDetailInternal(sentence string) chan WordTag {