Skip to content

Commit

Permalink
Update examples and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
vcaesar committed Nov 8, 2017
1 parent 6c6e6cf commit 02954e1
Show file tree
Hide file tree
Showing 16 changed files with 41 additions and 40 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ package main
import (
"log"

"github.com/go-ego/riot/engine"
"github.com/go-ego/riot"
"github.com/go-ego/riot/types"
)

var (
// searcher is coroutine safe
searcher = engine.Engine{}
searcher = riot.Engine{}
)

func main() {
Expand Down
4 changes: 2 additions & 2 deletions README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ package main
import (
"log"

"github.com/go-ego/riot/engine"
"github.com/go-ego/riot"
"github.com/go-ego/riot/types"
)

var (
// searcher 是协程安全的
searcher = engine.Engine{}
searcher = riot.Engine{}
)

func main() {
Expand Down
4 changes: 2 additions & 2 deletions data/riot/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ import (
rpc "github.com/go-ego/riot/net/grpc"
rhttp "github.com/go-ego/riot/net/http"

"github.com/go-ego/riot/engine"
"github.com/go-ego/riot"
"github.com/go-vgo/gt/conf"
"github.com/go-vgo/gt/zlog"
)

var (
// searcher is coroutine safe
searcher = engine.Engine{}
searcher = riot.Engine{}
)

// var config rpc.Config
Expand Down
4 changes: 2 additions & 2 deletions data/riot1/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ import (
rpc "github.com/go-ego/riot/net/grpc"
rhttp "github.com/go-ego/riot/net/http"

"github.com/go-ego/riot/engine"
"github.com/go-ego/riot"
"github.com/go-vgo/gt/conf"
"github.com/go-vgo/gt/zlog"
)

var (
// searcher is coroutine safe
searcher = engine.Engine{}
searcher = riot.Engine{}
)

var config com.Config
Expand Down
21 changes: 11 additions & 10 deletions docs/zh/codelab.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ type Weibo struct {

```go
import (
"github.com/go-ego/riot/engine"
"github.com/go-ego/riot"
"github.com/go-ego/riot/types"
)
```
第一个包定义了引擎功能,第二个包定义了常用结构体。在使用引擎之前需要初始化,例如

```go
var searcher engine.Engine
var searcher riot.Engine
searcher.Init(types.EngineInitOptions{
SegmenterDict: "../../data/dict/dictionary.txt",
StopTokenFile: "../../data/dict/stop_tokens.txt",
Expand Down Expand Up @@ -184,11 +184,12 @@ response := searcher.Search(types.SearchRequest{
如果你想进一步了解riot 引擎,建议你直接阅读代码。代码的目录结构如下:
/core 核心部件,包括索引器和排序器
/data 字典文件和停用词文件
/docs 文档
/engine 引擎,包括主协程、分词协程、索引器协程和排序器协程的实现
/examples 例子和性能测试程序
/testdata 测试数据
/types 常用结构体
/utils 常用函数
riot/ 引擎,包括主协程、分词协程、索引器协程和排序器协程的实现
/core 核心部件,包括索引器和排序器
/data 字典文件和停用词文件
/docs 文档
/engine 引擎,包括主协程、分词协程、索引器协程和排序器协程的实现, 已移到主目录
/examples 例子和性能测试程序
/testdata 测试数据
/types 常用结构体
/utils 常用函数
2 changes: 1 addition & 1 deletion docs/zh/custom_scoring_criteria.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func (criteria MyScoringCriteria) Score(
}
```

文档的MyScoringFields数据通过engine.Engine的IndexDocument函数传给排序器保存在内存中。然后通过Search函数的参数调用MyScoringCriteria进行查询
文档的MyScoringFields数据通过 riot.Engine 的 IndexDocument 函数传给排序器保存在内存中。然后通过Search函数的参数调用 MyScoringCriteria 进行查询

当然,MyScoringCriteria的Score函数也可以通过docId从硬盘或数据库读取更多文档数据用于打分,但速度要比从内存中直接读慢许多,请在内存和速度之间合适取舍。

Expand Down
6 changes: 3 additions & 3 deletions examples/benchmark/benchmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"sync"
"time"

"github.com/go-ego/riot/engine"
"github.com/go-ego/riot"
"github.com/go-ego/riot/types"
)

Expand Down Expand Up @@ -49,7 +49,7 @@ var (
storageEngine = flag.String("storageEngine", "lbd", "use StorageEngine")
persistentStorageShards = flag.Int("persistentStorageShards", 0, "持久数据库存储裂分数目")

searcher = engine.Engine{}
searcher = riot.Engine{}
options = types.RankOptions{
OutputOffset: 0,
MaxOutputs: 100,
Expand Down Expand Up @@ -202,7 +202,7 @@ func main() {
if *usePersistent {
searcher.Close()
t6 := time.Now()
searcher1 := engine.Engine{}
searcher1 := riot.Engine{}
searcher1.Init(types.EngineInitOptions{
SegmenterDict: *dictionaries,
StopTokenFile: *stopTokenFile,
Expand Down
4 changes: 2 additions & 2 deletions examples/codelab/search_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"strconv"
"strings"

"github.com/go-ego/riot/engine"
"github.com/go-ego/riot"
"github.com/go-ego/riot/types"
)

Expand All @@ -27,7 +27,7 @@ const (
)

var (
searcher = engine.Engine{}
searcher = riot.Engine{}
wbs = map[uint64]Weibo{}
weiboData = flag.String("weibo_data", "../../testdata/weibo_data.txt", "微博数据文件")
dictFile = flag.String("dict_file", "../../data/dict/dictionary.txt", "词典文件")
Expand Down
4 changes: 2 additions & 2 deletions examples/logic/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ package main
import (
"log"

"github.com/go-ego/riot/engine"
"github.com/go-ego/riot"
"github.com/go-ego/riot/types"
)

var (
// searcher is coroutine safe
searcher = engine.Engine{}
searcher = riot.Engine{}
)

func main() {
Expand Down
4 changes: 2 additions & 2 deletions examples/pinyin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ import (
"fmt"
"os"

"github.com/go-ego/riot/engine"
"github.com/go-ego/riot"
"github.com/go-ego/riot/types"
)

var (
// searcher是协程安全的
searcher = engine.Engine{}
searcher = riot.Engine{}
)

func initEngine() {
Expand Down
4 changes: 2 additions & 2 deletions examples/pinyin_weibo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"os"
"os/signal"

"github.com/go-ego/riot/engine"
"github.com/go-ego/riot"
"github.com/go-ego/riot/types"
)

Expand All @@ -24,7 +24,7 @@ const (
)

var (
searcher = engine.Engine{}
searcher = riot.Engine{}
wbs = map[uint64]Weibo{}
weiboData = flag.String("weibo_data", "weibo.txt", "微博数据文件")
dictFile = flag.String("dict_file", "../../data/dict/dictionary.txt", "词典文件")
Expand Down
4 changes: 2 additions & 2 deletions examples/simple/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ package main
import (
"log"

"github.com/go-ego/riot/engine"
"github.com/go-ego/riot"
"github.com/go-ego/riot/types"
)

var (
// searcher is coroutine safe
searcher = engine.Engine{}
searcher = riot.Engine{}
)

func main() {
Expand Down
4 changes: 2 additions & 2 deletions examples/simple/zh/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ package main
import (
"log"

"github.com/go-ego/riot/engine"
"github.com/go-ego/riot"
"github.com/go-ego/riot/types"
)

var (
// searcher 是线程安全的
searcher = engine.Engine{}
searcher = riot.Engine{}
)

func main() {
Expand Down
4 changes: 2 additions & 2 deletions examples/store/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ import (
"log"
"os"

"github.com/go-ego/riot/engine"
"github.com/go-ego/riot"
"github.com/go-ego/riot/types"
)

var (
// searcher is coroutine safe
searcher = engine.Engine{}
searcher = riot.Engine{}
)

func initEngine() {
Expand Down
4 changes: 2 additions & 2 deletions examples/weibo/custom_scoring_criteria.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"strconv"
"strings"

"github.com/go-ego/riot/engine"
"github.com/go-ego/riot"
"github.com/go-ego/riot/types"
)

Expand Down Expand Up @@ -52,7 +52,7 @@ var (
"../../data/dict/stop_tokens.txt",
"停用词文件")

searcher = engine.Engine{}
searcher = riot.Engine{}
options = types.RankOptions{
ScoringCriteria: WeiboScoringCriteria{},
OutputOffset: 0,
Expand Down
4 changes: 2 additions & 2 deletions net/com/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ import (
"log"
"os"

"github.com/go-ego/riot/engine"
"github.com/go-ego/riot"
"github.com/go-ego/riot/types"
// "github.com/go-vgo/gt/zlog"
)

var (
// Searcher is coroutine safe
Searcher = engine.Engine{}
Searcher = riot.Engine{}
// Conf is config
Conf Config
)
Expand Down

0 comments on commit 02954e1

Please sign in to comment.