File tree Expand file tree Collapse file tree 4 files changed +122
-0
lines changed Expand file tree Collapse file tree 4 files changed +122
-0
lines changed Original file line number Diff line number Diff line change
1
+ package main
2
+
3
+ import (
4
+ "fmt"
5
+
6
+ "github.com/go-ego/gpy"
7
+ )
8
+
9
+ func main () {
10
+ hans := "中国人"
11
+
12
+ // 默认
13
+ a := gpy .NewArgs ()
14
+ fmt .Println (gpy .Pinyin (hans , a ))
15
+ // [[zhong] [guo] [ren]]
16
+
17
+ // 包含声调
18
+ a .Style = gpy .Tone
19
+ fmt .Println (gpy .Pinyin (hans , a ))
20
+ // [[zhōng] [guó] [rén]]
21
+
22
+ // 声调用数字表示
23
+ a .Style = gpy .Tone2
24
+ fmt .Println (gpy .Pinyin (hans , a ))
25
+ // [[zho1ng] [guo2] [re2n]]
26
+
27
+ // 开启多音字模式
28
+ a = gpy .NewArgs ()
29
+ a .Heteronym = true
30
+ fmt .Println (gpy .Pinyin (hans , a ))
31
+ // [[zhong zhong] [guo] [ren]]
32
+ a .Style = gpy .Tone2
33
+ fmt .Println (gpy .Pinyin (hans , a ))
34
+ // [[zho1ng zho4ng] [guo2] [re2n]]
35
+
36
+ fmt .Println (gpy .LazyPinyin (hans , gpy .NewArgs ()))
37
+ // [zhong guo ren]
38
+
39
+ fmt .Println (gpy .Convert (hans , nil ))
40
+ // [[zhong] [guo] [ren]]
41
+
42
+ fmt .Println (gpy .LazyConvert (hans , nil ))
43
+ // [zhong guo ren]
44
+ }
Original file line number Diff line number Diff line change
1
+ package main
2
+
3
+ import (
4
+ "flag"
5
+ "fmt"
6
+ "log"
7
+
8
+ "github.com/go-ego/gse"
9
+ )
10
+
11
+ var (
12
+ text = flag .String ("text" , "中国互联网历史上最大的一笔并购案" , "要分词的文本" )
13
+ )
14
+
15
+ func main () {
16
+ flag .Parse ()
17
+
18
+ var seg gse.Segmenter
19
+ // seg.LoadDict("../data/dict/dictionary.txt")
20
+ seg .LoadDict ()
21
+
22
+ segments := seg .Segment ([]byte (* text ))
23
+ fmt .Println (gse .ToString (segments , true ))
24
+
25
+ text2 := []byte ("深圳地标建筑, 深圳地王大厦" )
26
+ segs := seg .Segment (text2 )
27
+ log .Println (gse .ToString (segs , false ))
28
+ }
Original file line number Diff line number Diff line change
1
+ package main
2
+
3
+ import (
4
+ "log"
5
+
6
+ "github.com/go-ego/riot"
7
+ "github.com/go-ego/riot/types"
8
+ )
9
+
10
+ var (
11
+ // searcher 是协程安全的
12
+ searcher = riot.Engine {}
13
+ )
14
+
15
+ func main () {
16
+ // 初始化
17
+ searcher .Init (types.EngineOpts {
18
+ Using : 3 ,
19
+ SegmenterDict : "zh" ,
20
+ // SegmenterDict: "your gopath"+"/src/github.com/go-ego/riot/data/dict/dictionary.txt",
21
+ })
22
+ defer searcher .Close ()
23
+
24
+ text := "此次百度收购将成中国互联网最大并购"
25
+ text1 := "百度宣布拟全资收购91无线业务"
26
+ text2 := "百度是中国最大的搜索引擎"
27
+
28
+ // 将文档加入索引,docId 从1开始
29
+ searcher .IndexDoc (1 , types.DocIndexData {Content : text })
30
+ searcher .IndexDoc (2 , types.DocIndexData {Content : text1 }, false )
31
+ searcher .IndexDoc (3 , types.DocIndexData {Content : text2 }, true )
32
+
33
+ // 等待索引刷新完毕
34
+ searcher .FlushIndex ()
35
+
36
+ // 搜索输出格式见 types.SearchResp 结构体
37
+ log .Print (searcher .Search (types.SearchReq {Text :"百度中国" }))
38
+ }
Original file line number Diff line number Diff line change
1
+ package main
2
+
3
+ import (
4
+ "github.com/go-vgo/robotgo"
5
+ )
6
+
7
+ // 可以做什么要考自己思考
8
+ func main () {
9
+ robotgo .ScrollMouse (10 , "up" )
10
+ robotgo .MouseClick ("left" , true )
11
+ robotgo .MoveMouseSmooth (100 , 200 , 1.0 , 100.0 )
12
+ }
You can’t perform that action at this time.
0 commit comments