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

small refactor the interface, use contructors instead of pointers for entry

This commit is contained in:
Wang Bin
2015-03-30 13:00:56 +08:00
parent 48a0bd390b
commit 51c63cb9ad
7 changed files with 274 additions and 283 deletions

View File

@@ -40,13 +40,12 @@ func LoadDict(l DictLoader, dictFileName string, usingFlag bool) error {
}
defer dictFile.Close()
scanner := bufio.NewScanner(dictFile)
var entry *Entry
var entry Entry
var line string
var fields []string
for scanner.Scan() {
line = scanner.Text()
fields = strings.Split(line, " ")
entry = NewEntry()
entry.Word = strings.Replace(fields[0], "\ufeff", "", 1)
if length := len(fields); length > 1 {
entry.Freq, err = strconv.ParseFloat(fields[1], 64)