mirror of
https://github.com/fumiama/jieba.git
synced 2026-06-18 00:50:26 +08:00
small refactor, updated REAMDE
This commit is contained in:
@@ -1,3 +1,3 @@
|
|||||||
language: go
|
language: go
|
||||||
go:
|
go:
|
||||||
- 1.4.1
|
- 1.4.2
|
||||||
|
|||||||
@@ -107,7 +107,7 @@
|
|||||||
var sentence = "我爱北京天安门"
|
var sentence = "我爱北京天安门"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
jiebago.SetDictionary("/Path/to/default/dictionary/file")
|
posseg.SetDictionary("/Path/to/default/dictionary/file")
|
||||||
for _, wt := range posseg.Cut(sentence, true) {
|
for _, wt := range posseg.Cut(sentence, true) {
|
||||||
fmt.Printf("%s %s\n", wt.Word, wt.Tag)
|
fmt.Printf("%s %s\n", wt.Word, wt.Tag)
|
||||||
}
|
}
|
||||||
@@ -195,4 +195,4 @@ Tokenize
|
|||||||
|
|
||||||
许可证
|
许可证
|
||||||
======
|
======
|
||||||
MIT: http://wangbin.mit-license.org
|
MIT: http://wangbin.mit-license.org
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ func SetDictionary(dictFileName string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func __cut(sentence string) []WordTag {
|
func cutDetailInternal(sentence string) []WordTag {
|
||||||
result := make([]WordTag, 0)
|
result := make([]WordTag, 0)
|
||||||
runes := []rune(sentence)
|
runes := []rune(sentence)
|
||||||
_, posList := Viterbi(runes)
|
_, posList := Viterbi(runes)
|
||||||
@@ -67,7 +67,7 @@ func cutDetail(sentence string) []WordTag {
|
|||||||
blocks := jiebago.RegexpSplit(reHanDetail, sentence)
|
blocks := jiebago.RegexpSplit(reHanDetail, sentence)
|
||||||
for _, blk := range blocks {
|
for _, blk := range blocks {
|
||||||
if reHanDetail.MatchString(blk) {
|
if reHanDetail.MatchString(blk) {
|
||||||
for _, wordTag := range __cut(blk) {
|
for _, wordTag := range cutDetailInternal(blk) {
|
||||||
result = append(result, wordTag)
|
result = append(result, wordTag)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user