1
0
mirror of https://github.com/fumiama/jieba.git synced 2026-06-28 08:02:45 +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

@@ -41,6 +41,10 @@ type TagExtracter struct {
stopWords map[string]int
}
func (t *TagExtracter) AddEntry(entry *jiebago.Entry) {
t.stopWords[entry.Word] = 1
}
func NewTagExtracter(dictFileName, IDFFileName string) (*TagExtracter, error) {
j, err := jiebago.NewJieba(dictFileName)
if err != nil {
@@ -61,11 +65,7 @@ func (t *TagExtracter) SetStopWords(stopWordsFileName string) error {
return err
}
wtfs, err := jiebago.ParseDictFile(stopWordsFilePath)
for _, wtf := range wtfs {
t.stopWords[wtf.Word] = 1
}
return nil
return jiebago.LoadDict(t, stopWordsFilePath, false)
}
// Keyword extraction.