-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
122 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/go-ego/gpy" | ||
) | ||
|
||
func main() { | ||
hans := "中国人" | ||
|
||
// 默认 | ||
a := gpy.NewArgs() | ||
fmt.Println(gpy.Pinyin(hans, a)) | ||
// [[zhong] [guo] [ren]] | ||
|
||
// 包含声调 | ||
a.Style = gpy.Tone | ||
fmt.Println(gpy.Pinyin(hans, a)) | ||
// [[zhōng] [guó] [rén]] | ||
|
||
// 声调用数字表示 | ||
a.Style = gpy.Tone2 | ||
fmt.Println(gpy.Pinyin(hans, a)) | ||
// [[zho1ng] [guo2] [re2n]] | ||
|
||
// 开启多音字模式 | ||
a = gpy.NewArgs() | ||
a.Heteronym = true | ||
fmt.Println(gpy.Pinyin(hans, a)) | ||
// [[zhong zhong] [guo] [ren]] | ||
a.Style = gpy.Tone2 | ||
fmt.Println(gpy.Pinyin(hans, a)) | ||
// [[zho1ng zho4ng] [guo2] [re2n]] | ||
|
||
fmt.Println(gpy.LazyPinyin(hans, gpy.NewArgs())) | ||
// [zhong guo ren] | ||
|
||
fmt.Println(gpy.Convert(hans, nil)) | ||
// [[zhong] [guo] [ren]] | ||
|
||
fmt.Println(gpy.LazyConvert(hans, nil)) | ||
// [zhong guo ren] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package main | ||
|
||
import ( | ||
"flag" | ||
"fmt" | ||
"log" | ||
|
||
"github.com/go-ego/gse" | ||
) | ||
|
||
var ( | ||
text = flag.String("text", "中国互联网历史上最大的一笔并购案", "要分词的文本") | ||
) | ||
|
||
func main() { | ||
flag.Parse() | ||
|
||
var seg gse.Segmenter | ||
// seg.LoadDict("../data/dict/dictionary.txt") | ||
seg.LoadDict() | ||
|
||
segments := seg.Segment([]byte(*text)) | ||
fmt.Println(gse.ToString(segments, true)) | ||
|
||
text2 := []byte("深圳地标建筑, 深圳地王大厦") | ||
segs := seg.Segment(text2) | ||
log.Println(gse.ToString(segs, false)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package main | ||
|
||
import ( | ||
"log" | ||
|
||
"github.com/go-ego/riot" | ||
"github.com/go-ego/riot/types" | ||
) | ||
|
||
var ( | ||
// searcher 是协程安全的 | ||
searcher = riot.Engine{} | ||
) | ||
|
||
func main() { | ||
// 初始化 | ||
searcher.Init(types.EngineOpts{ | ||
Using: 3, | ||
SegmenterDict: "zh", | ||
// SegmenterDict: "your gopath"+"/src/github.com/go-ego/riot/data/dict/dictionary.txt", | ||
}) | ||
defer searcher.Close() | ||
|
||
text := "此次百度收购将成中国互联网最大并购" | ||
text1 := "百度宣布拟全资收购91无线业务" | ||
text2 := "百度是中国最大的搜索引擎" | ||
|
||
// 将文档加入索引,docId 从1开始 | ||
searcher.IndexDoc(1, types.DocIndexData{Content: text}) | ||
searcher.IndexDoc(2, types.DocIndexData{Content: text1}, false) | ||
searcher.IndexDoc(3, types.DocIndexData{Content: text2}, true) | ||
|
||
// 等待索引刷新完毕 | ||
searcher.FlushIndex() | ||
|
||
// 搜索输出格式见 types.SearchResp 结构体 | ||
log.Print(searcher.Search(types.SearchReq{Text:"百度中国"})) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/go-vgo/robotgo" | ||
) | ||
|
||
// 可以做什么要考自己思考 | ||
func main() { | ||
robotgo.ScrollMouse(10, "up") | ||
robotgo.MouseClick("left", true) | ||
robotgo.MoveMouseSmooth(100, 200, 1.0, 100.0) | ||
} |