本文整理汇总了Golang中github.com/huichen/wukong/utils.Expect函数的典型用法代码示例。如果您正苦于以下问题:Golang Expect函数的具体用法?Golang Expect怎么用?Golang Expect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Expect函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestAddKeywords
func TestAddKeywords(t *testing.T) {
var indexer Indexer
indexer.Init(types.IndexerInitOptions{IndexType: types.LocationsIndex})
indexer.AddDocumentToCache(&types.DocumentIndex{
DocId: 1,
Keywords: []types.KeywordIndex{{"token1", 0, []int{}}},
}, false)
indexer.AddDocumentToCache(&types.DocumentIndex{
DocId: 2,
Keywords: []types.KeywordIndex{{"token2", 0, []int{}}},
}, false)
indexer.AddDocumentToCache(&types.DocumentIndex{
DocId: 3,
Keywords: []types.KeywordIndex{{"token3", 0, []int{}}},
}, false)
indexer.AddDocumentToCache(&types.DocumentIndex{
DocId: 7,
Keywords: []types.KeywordIndex{{"token7", 0, []int{}}},
}, false)
indexer.AddDocumentToCache(&types.DocumentIndex{
DocId: 1,
Keywords: []types.KeywordIndex{{"token2", 0, []int{}}},
}, false)
indexer.AddDocumentToCache(&types.DocumentIndex{
DocId: 7,
Keywords: []types.KeywordIndex{{"token77", 0, []int{}}},
}, false)
indexer.AddDocumentToCache(nil, true)
utils.Expect(t, "", indicesToString(&indexer, "token1"))
utils.Expect(t, "1 2 ", indicesToString(&indexer, "token2"))
utils.Expect(t, "3 ", indicesToString(&indexer, "token3"))
utils.Expect(t, "7 ", indicesToString(&indexer, "token77"))
}
开发者ID:merryChris,项目名称:wukong,代码行数:34,代码来源:indexer_test.go
示例2: TestRemoveDocument
func TestRemoveDocument(t *testing.T) {
var engine Engine
engine.Init(types.EngineInitOptions{
SegmenterDictionaries: "../testdata/test_dict.txt",
DefaultRankOptions: &types.RankOptions{
ScoringCriteria: TestScoringCriteria{},
},
})
AddDocs(&engine)
engine.RemoveDocument(5, false)
engine.RemoveDocument(6, false)
engine.FlushIndex()
engine.IndexDocument(6, types.DocumentIndexData{
Content: "中国人口有十三亿",
Fields: ScoringFields{0, 9, 1},
}, false)
engine.FlushIndex()
outputs := engine.Search(types.SearchRequest{Text: "中国人口"})
utils.Expect(t, "2", len(outputs.Docs))
utils.Expect(t, "6", outputs.Docs[0].DocId)
utils.Expect(t, "9000", int(outputs.Docs[0].Scores[0]*1000))
utils.Expect(t, "1", outputs.Docs[1].DocId)
utils.Expect(t, "6000", int(outputs.Docs[1].Scores[0]*1000))
}
开发者ID:merryChris,项目名称:wukong,代码行数:27,代码来源:engine_test.go
示例3: TestLookupWithPartialLocations
func TestLookupWithPartialLocations(t *testing.T) {
var indexer Indexer
indexer.Init(types.IndexerInitOptions{IndexType: types.LocationsIndex})
// doc0 = "token2 token4 token4 token2 token3 token4" + "label1"(不在文本中)
indexer.AddDocument(&types.DocumentIndex{
DocId: 0,
Keywords: []types.KeywordIndex{
{"token2", 0, []int{0, 21}},
{"token3", 0, []int{28}},
{"label1", 0, []int{}},
{"token4", 0, []int{7, 14, 35}},
},
})
// doc1 = "token2 token4 token4 token2 token3 token4"
indexer.AddDocument(&types.DocumentIndex{
DocId: 1,
Keywords: []types.KeywordIndex{
{"token2", 0, []int{0, 21}},
{"token3", 0, []int{28}},
{"token4", 0, []int{7, 14, 35}},
},
})
utils.Expect(t, "0 ", indicesToString(&indexer, "label1"))
utils.Expect(t, "[0 1 [21 28]] ",
indexedDocsToString(indexer.Lookup([]string{"token2", "token3"}, []string{"label1"}, nil)))
}
开发者ID:cnspica,项目名称:wukong,代码行数:28,代码来源:indexer_test.go
示例4: TestEngineIndexDocumentWithPersistentStorage
func TestEngineIndexDocumentWithPersistentStorage(t *testing.T) {
gob.Register(ScoringFields{})
var engine Engine
engine.Init(types.EngineInitOptions{
SegmenterDictionaries: "../testdata/test_dict.txt",
DefaultRankOptions: &types.RankOptions{
OutputOffset: 0,
MaxOutputs: 10,
ScoringCriteria: &RankByTokenProximity{},
},
IndexerInitOptions: &types.IndexerInitOptions{
IndexType: types.LocationsIndex,
},
UsePersistentStorage: true,
PersistentStorageFolder: "wukong.persistent",
PersistentStorageShards: 2,
})
AddDocs(&engine)
engine.RemoveDocument(5, true)
engine.Close()
var engine1 Engine
engine1.Init(types.EngineInitOptions{
SegmenterDictionaries: "../testdata/test_dict.txt",
DefaultRankOptions: &types.RankOptions{
OutputOffset: 0,
MaxOutputs: 10,
ScoringCriteria: &RankByTokenProximity{},
},
IndexerInitOptions: &types.IndexerInitOptions{
IndexType: types.LocationsIndex,
},
UsePersistentStorage: true,
PersistentStorageFolder: "wukong.persistent",
PersistentStorageShards: 2,
})
engine1.FlushIndex()
outputs := engine1.Search(types.SearchRequest{Text: "中国人口"})
utils.Expect(t, "2", len(outputs.Tokens))
utils.Expect(t, "中国", outputs.Tokens[0])
utils.Expect(t, "人口", outputs.Tokens[1])
utils.Expect(t, "2", len(outputs.Docs))
utils.Expect(t, "2", outputs.Docs[0].DocId)
utils.Expect(t, "1000", int(outputs.Docs[0].Scores[0]*1000))
utils.Expect(t, "[0 6]", outputs.Docs[0].TokenSnippetLocations)
utils.Expect(t, "1", outputs.Docs[1].DocId)
utils.Expect(t, "76", int(outputs.Docs[1].Scores[0]*1000))
utils.Expect(t, "[0 18]", outputs.Docs[1].TokenSnippetLocations)
engine1.Close()
os.RemoveAll("wukong.persistent")
}
开发者ID:merryChris,项目名称:wukong,代码行数:55,代码来源:engine_test.go
示例5: TestLookupWithBM25
func TestLookupWithBM25(t *testing.T) {
var indexer Indexer
indexer.Init(types.IndexerInitOptions{
IndexType: types.FrequenciesIndex,
BM25Parameters: &types.BM25Parameters{
K1: 1,
B: 1,
},
})
// doc0 = "token2 token4 token4 token2 token3 token4"
indexer.AddDocument(&types.DocumentIndex{
DocId: 0,
TokenLength: 6,
Keywords: []types.KeywordIndex{
{"token2", 3, []int{0, 21}},
{"token3", 7, []int{28}},
{"token4", 15, []int{7, 14, 35}},
},
})
// doc0 = "token6 token7"
indexer.AddDocument(&types.DocumentIndex{
DocId: 1,
TokenLength: 2,
Keywords: []types.KeywordIndex{
{"token6", 3, []int{0}},
{"token7", 15, []int{7}},
},
})
outputs := indexer.Lookup([]string{"token2", "token3", "token4"}, []string{}, nil)
// BM25 = log2(3) * (12/9 + 28/17 + 60/33) = 6.3433
utils.Expect(t, "76055", int(outputs[0].BM25*10000))
}
开发者ID:cnspica,项目名称:wukong,代码行数:34,代码来源:indexer_test.go
示例6: TestRemoveDocument
func TestRemoveDocument(t *testing.T) {
var ranker Ranker
ranker.Init()
ranker.AddDoc(1, DummyScoringFields{
label: "label3",
counter: 3,
amount: 22.3,
})
ranker.AddDoc(2, DummyScoringFields{
label: "label4",
counter: 1,
amount: 2,
})
ranker.AddDoc(3, DummyScoringFields{
label: "label1",
counter: 7,
amount: 10.3,
})
ranker.RemoveDoc(3)
criteria := DummyScoringCriteria{}
scoredDocs, _ := ranker.Rank([]types.IndexedDocument{
types.IndexedDocument{DocId: 1, TokenProximity: 6},
types.IndexedDocument{DocId: 2, TokenProximity: -1},
types.IndexedDocument{DocId: 3, TokenProximity: 24},
types.IndexedDocument{DocId: 4, TokenProximity: 18},
}, types.RankOptions{ScoringCriteria: criteria}, false)
utils.Expect(t, "[1 [25300 ]] [2 [3000 ]] ", scoredDocsToString(scoredDocs))
}
开发者ID:ljyf5593,项目名称:wukong,代码行数:29,代码来源:ranker_test.go
示例7: TestLookupWithLocations
func TestLookupWithLocations(t *testing.T) {
var indexer Indexer
indexer.Init(types.IndexerInitOptions{IndexType: types.LocationsIndex})
// doc1 = "token2 token4 token4 token2 token3 token4"
indexer.AddDocumentToCache(&types.DocumentIndex{
DocId: 1,
Keywords: []types.KeywordIndex{
{"token2", 0, []int{0, 21}},
{"token3", 0, []int{28}},
{"token4", 0, []int{7, 14, 35}},
},
}, true)
// doc2 = "token2 token4 token4 token2 token3 token4"
indexer.AddDocumentToCache(&types.DocumentIndex{
DocId: 2,
Keywords: []types.KeywordIndex{
{"token3", 0, []int{0, 21}},
{"token5", 0, []int{28}},
{"token2", 0, []int{7, 14, 35}},
},
}, true)
indexer.RemoveDocumentToCache(2, true)
docs, _ := indexer.Lookup([]string{"token2", "token3"}, []string{}, nil, false)
utils.Expect(t, "[[0 21] [28]]", docs[0].TokenLocations)
}
开发者ID:merryChris,项目名称:wukong,代码行数:27,代码来源:indexer_test.go
示例8: TestRankDocument
func TestRankDocument(t *testing.T) {
var ranker Ranker
ranker.Init()
scoredDocs := ranker.Rank([]types.IndexedDocument{
types.IndexedDocument{DocId: 1, BM25: 6},
types.IndexedDocument{DocId: 3, BM25: 24},
types.IndexedDocument{DocId: 4, BM25: 18},
}, types.RankOptions{ScoringCriteria: types.RankByBM25{}})
utils.Expect(t, "[3 [24000 ]] [4 [18000 ]] [1 [6000 ]] ", scoredDocsToString(scoredDocs))
scoredDocs = ranker.Rank([]types.IndexedDocument{
types.IndexedDocument{DocId: 1, BM25: 6},
types.IndexedDocument{DocId: 3, BM25: 24},
types.IndexedDocument{DocId: 2, BM25: 0},
types.IndexedDocument{DocId: 4, BM25: 18},
}, types.RankOptions{ScoringCriteria: types.RankByBM25{}, ReverseOrder: true})
utils.Expect(t, "[2 [0 ]] [1 [6000 ]] [4 [18000 ]] [3 [24000 ]] ", scoredDocsToString(scoredDocs))
}
开发者ID:cnspica,项目名称:wukong,代码行数:18,代码来源:ranker_test.go
示例9: TestRemoveDocument
func TestRemoveDocument(t *testing.T) {
var engine Engine
engine.Init(types.EngineInitOptions{
SegmenterDictionaries: "../testdata/test_dict.txt",
DefaultRankOptions: &types.RankOptions{
ScoringCriteria: TestScoringCriteria{},
},
})
AddDocs(&engine)
engine.RemoveDocument(4)
outputs := engine.Search(types.SearchRequest{Text: "中国人口"})
utils.Expect(t, "1", len(outputs.Docs))
utils.Expect(t, "0", outputs.Docs[0].DocId)
utils.Expect(t, "6000", int(outputs.Docs[0].Scores[0]*1000))
}
开发者ID:cnspica,项目名称:wukong,代码行数:18,代码来源:engine_test.go
示例10: TestRankWithCriteria
func TestRankWithCriteria(t *testing.T) {
var ranker Ranker
ranker.Init()
ranker.AddScoringFields(1, DummyScoringFields{
label: "label3",
counter: 3,
amount: 22.3,
})
ranker.AddScoringFields(2, DummyScoringFields{
label: "label4",
counter: 1,
amount: 2,
})
ranker.AddScoringFields(3, DummyScoringFields{
label: "label1",
counter: 7,
amount: 10.3,
})
ranker.AddScoringFields(4, DummyScoringFields{
label: "label1",
counter: -1,
amount: 2.3,
})
criteria := DummyScoringCriteria{}
scoredDocs := ranker.Rank([]types.IndexedDocument{
types.IndexedDocument{DocId: 1, TokenProximity: 6},
types.IndexedDocument{DocId: 2, TokenProximity: -1},
types.IndexedDocument{DocId: 3, TokenProximity: 24},
types.IndexedDocument{DocId: 4, TokenProximity: 18},
}, types.RankOptions{ScoringCriteria: criteria})
utils.Expect(t, "[1 [25300 ]] [3 [17300 ]] [2 [3000 ]] [4 [1300 ]] ", scoredDocsToString(scoredDocs))
criteria.Threshold = 4
scoredDocs = ranker.Rank([]types.IndexedDocument{
types.IndexedDocument{DocId: 1, TokenProximity: 6},
types.IndexedDocument{DocId: 2, TokenProximity: -1},
types.IndexedDocument{DocId: 3, TokenProximity: 24},
types.IndexedDocument{DocId: 4, TokenProximity: 18},
}, types.RankOptions{ScoringCriteria: criteria})
utils.Expect(t, "[1 [25300 ]] [3 [17300 ]] ", scoredDocsToString(scoredDocs))
}
开发者ID:cnspica,项目名称:wukong,代码行数:42,代码来源:ranker_test.go
示例11: TestOpenOrCreateBolt
func TestOpenOrCreateBolt(t *testing.T) {
db, err := openBoltStorage("bolt_test")
utils.Expect(t, "<nil>", err)
db.Close()
db, err = openBoltStorage("bolt_test")
utils.Expect(t, "<nil>", err)
err = db.Set([]byte("key1"), []byte("value1"))
utils.Expect(t, "<nil>", err)
buffer := make([]byte, 100)
buffer, err = db.Get([]byte("key1"))
utils.Expect(t, "<nil>", err)
utils.Expect(t, "value1", string(buffer))
walFile := db.WALName()
db.Close()
os.Remove(walFile)
os.Remove("bolt_test")
}
开发者ID:ljyf5593,项目名称:wukong,代码行数:20,代码来源:bolt_storage_test.go
示例12: TestLookupWithProximity
func TestLookupWithProximity(t *testing.T) {
var indexer Indexer
indexer.Init(types.IndexerInitOptions{IndexType: types.LocationsIndex})
// doc0 = "token2 token4 token4 token2 token3 token4"
indexer.AddDocument(&types.DocumentIndex{
DocId: 0,
Keywords: []types.KeywordIndex{
{"token2", 0, []int{0, 21}},
{"token3", 0, []int{28}},
{"token4", 0, []int{7, 14, 35}},
},
})
utils.Expect(t, "[0 1 [21 28]] ",
indexedDocsToString(indexer.Lookup([]string{"token2", "token3"}, []string{}, nil)))
// doc0 = "t2 t1 . . . t2 t3"
indexer.AddDocument(&types.DocumentIndex{
DocId: 0,
Keywords: []types.KeywordIndex{
{"t1", 0, []int{3}},
{"t2", 0, []int{0, 12}},
{"t3", 0, []int{15}},
},
})
utils.Expect(t, "[0 8 [3 12 15]] ",
indexedDocsToString(indexer.Lookup([]string{"t1", "t2", "t3"}, []string{}, nil)))
// doc0 = "t3 t2 t1 . . . . . t2 t3"
indexer.AddDocument(&types.DocumentIndex{
DocId: 0,
Keywords: []types.KeywordIndex{
{"t1", 0, []int{6}},
{"t2", 0, []int{3, 19}},
{"t3", 0, []int{0, 22}},
},
})
utils.Expect(t, "[0 10 [6 3 0]] ",
indexedDocsToString(indexer.Lookup([]string{"t1", "t2", "t3"}, []string{}, nil)))
}
开发者ID:cnspica,项目名称:wukong,代码行数:40,代码来源:indexer_test.go
示例13: TestEngineIndexDocumentWithContentAndLabels
func TestEngineIndexDocumentWithContentAndLabels(t *testing.T) {
var engine1, engine2 Engine
engine1.Init(types.EngineInitOptions{
SegmenterDictionaries: "../data/dictionary.txt",
IndexerInitOptions: &types.IndexerInitOptions{
IndexType: types.LocationsIndex,
},
})
engine2.Init(types.EngineInitOptions{
SegmenterDictionaries: "../data/dictionary.txt",
IndexerInitOptions: &types.IndexerInitOptions{
IndexType: types.DocIdsIndex,
},
})
addDocsWithLabels(&engine1)
addDocsWithLabels(&engine2)
outputs1 := engine1.Search(types.SearchRequest{Text: "百度"})
outputs2 := engine2.Search(types.SearchRequest{Text: "百度"})
utils.Expect(t, "1", len(outputs1.Tokens))
utils.Expect(t, "1", len(outputs2.Tokens))
utils.Expect(t, "百度", outputs1.Tokens[0])
utils.Expect(t, "百度", outputs2.Tokens[0])
utils.Expect(t, "5", len(outputs1.Docs))
utils.Expect(t, "5", len(outputs2.Docs))
}
开发者ID:merryChris,项目名称:wukong,代码行数:27,代码来源:engine_test.go
示例14: TestAddKeywords
func TestAddKeywords(t *testing.T) {
var indexer Indexer
indexer.Init(types.IndexerInitOptions{IndexType: types.LocationsIndex})
indexer.AddDocument(&types.DocumentIndex{
DocId: 1,
Keywords: []types.KeywordIndex{{"token1", 0, []int{}}},
})
indexer.AddDocument(&types.DocumentIndex{
DocId: 7,
Keywords: []types.KeywordIndex{{"token1", 0, []int{}}},
})
indexer.AddDocument(&types.DocumentIndex{
DocId: 2,
Keywords: []types.KeywordIndex{{"token1", 0, []int{}}},
})
indexer.AddDocument(&types.DocumentIndex{
DocId: 3,
Keywords: []types.KeywordIndex{{"token2", 0, []int{}}},
})
indexer.AddDocument(&types.DocumentIndex{
DocId: 1,
Keywords: []types.KeywordIndex{{"token1", 0, []int{}}},
})
indexer.AddDocument(&types.DocumentIndex{
DocId: 1,
Keywords: []types.KeywordIndex{{"token2", 0, []int{}}},
})
indexer.AddDocument(&types.DocumentIndex{
DocId: 2,
Keywords: []types.KeywordIndex{{"token2", 0, []int{}}},
})
indexer.AddDocument(&types.DocumentIndex{
DocId: 0,
Keywords: []types.KeywordIndex{{"token2", 0, []int{}}},
})
utils.Expect(t, "1 2 7 ", indicesToString(&indexer, "token1"))
utils.Expect(t, "0 1 2 3 ", indicesToString(&indexer, "token2"))
}
开发者ID:cnspica,项目名称:wukong,代码行数:39,代码来源:indexer_test.go
示例15: TestCountDocsOnly
func TestCountDocsOnly(t *testing.T) {
var engine Engine
engine.Init(types.EngineInitOptions{
SegmenterDictionaries: "../testdata/test_dict.txt",
DefaultRankOptions: &types.RankOptions{
ReverseOrder: true,
OutputOffset: 0,
MaxOutputs: 1,
ScoringCriteria: &RankByTokenProximity{},
},
IndexerInitOptions: &types.IndexerInitOptions{
IndexType: types.LocationsIndex,
},
})
AddDocs(&engine)
engine.RemoveDocument(4)
outputs := engine.Search(types.SearchRequest{Text: "中国人口", CountDocsOnly: true})
utils.Expect(t, "0", len(outputs.Docs))
utils.Expect(t, "2", len(outputs.Tokens))
utils.Expect(t, "2", outputs.NumDocs)
}
开发者ID:chenkaiC4,项目名称:wukong,代码行数:23,代码来源:engine_test.go
示例16: TestFrequenciesIndex
func TestFrequenciesIndex(t *testing.T) {
var engine Engine
engine.Init(types.EngineInitOptions{
SegmenterDictionaries: "../testdata/test_dict.txt",
DefaultRankOptions: &types.RankOptions{
ScoringCriteria: BM25ScoringCriteria{},
},
IndexerInitOptions: &types.IndexerInitOptions{
IndexType: types.FrequenciesIndex,
},
})
AddDocs(&engine)
outputs := engine.Search(types.SearchRequest{Text: "中国人口"})
utils.Expect(t, "2", len(outputs.Docs))
utils.Expect(t, "4", outputs.Docs[0].DocId)
utils.Expect(t, "2311", int(outputs.Docs[0].Scores[0]*1000))
utils.Expect(t, "0", outputs.Docs[1].DocId)
utils.Expect(t, "2211", int(outputs.Docs[1].Scores[0]*1000))
}
开发者ID:cnspica,项目名称:wukong,代码行数:23,代码来源:engine_test.go
示例17: TestRankDocument
func TestRankDocument(t *testing.T) {
var ranker Ranker
ranker.Init()
ranker.AddDoc(1, DummyScoringFields{})
ranker.AddDoc(3, DummyScoringFields{})
ranker.AddDoc(4, DummyScoringFields{})
scoredDocs, _ := ranker.Rank([]types.IndexedDocument{
types.IndexedDocument{DocId: 1, BM25: 6},
types.IndexedDocument{DocId: 3, BM25: 24},
types.IndexedDocument{DocId: 4, BM25: 18},
}, types.RankOptions{ScoringCriteria: types.RankByBM25{}}, false)
utils.Expect(t, "[3 [24000 ]] [4 [18000 ]] [1 [6000 ]] ", scoredDocsToString(scoredDocs))
scoredDocs, _ = ranker.Rank([]types.IndexedDocument{
types.IndexedDocument{DocId: 1, BM25: 6},
types.IndexedDocument{DocId: 3, BM25: 24},
types.IndexedDocument{DocId: 2, BM25: 0},
types.IndexedDocument{DocId: 4, BM25: 18},
}, types.RankOptions{ScoringCriteria: types.RankByBM25{}, ReverseOrder: true}, false)
// doc0因为没有AddDoc所以没有添加进来
utils.Expect(t, "[1 [6000 ]] [4 [18000 ]] [3 [24000 ]] ", scoredDocsToString(scoredDocs))
}
开发者ID:ljyf5593,项目名称:wukong,代码行数:23,代码来源:ranker_test.go
示例18: TestOffsetAndMaxOutputs
func TestOffsetAndMaxOutputs(t *testing.T) {
var engine Engine
engine.Init(types.EngineInitOptions{
SegmenterDictionaries: "../testdata/test_dict.txt",
DefaultRankOptions: &types.RankOptions{
ReverseOrder: true,
OutputOffset: 1,
MaxOutputs: 3,
ScoringCriteria: &RankByTokenProximity{},
},
IndexerInitOptions: &types.IndexerInitOptions{
IndexType: types.LocationsIndex,
},
})
AddDocs(&engine)
outputs := engine.Search(types.SearchRequest{Text: "中国人口"})
utils.Expect(t, "2", len(outputs.Docs))
utils.Expect(t, "4", outputs.Docs[0].DocId)
utils.Expect(t, "1", outputs.Docs[1].DocId)
}
开发者ID:cnspica,项目名称:wukong,代码行数:23,代码来源:engine_test.go
示例19: TestSearchWithin
func TestSearchWithin(t *testing.T) {
var engine Engine
engine.Init(types.EngineInitOptions{
SegmenterDictionaries: "../testdata/test_dict.txt",
DefaultRankOptions: &types.RankOptions{
ReverseOrder: true,
OutputOffset: 0,
MaxOutputs: 10,
ScoringCriteria: &RankByTokenProximity{},
},
IndexerInitOptions: &types.IndexerInitOptions{
IndexType: types.LocationsIndex,
},
})
AddDocs(&engine)
docIds := make(map[uint64]bool)
docIds[5] = true
docIds[1] = true
outputs := engine.Search(types.SearchRequest{
Text: "中国人口",
DocIds: docIds,
})
utils.Expect(t, "2", len(outputs.Tokens))
utils.Expect(t, "中国", outputs.Tokens[0])
utils.Expect(t, "人口", outputs.Tokens[1])
utils.Expect(t, "2", len(outputs.Docs))
utils.Expect(t, "1", outputs.Docs[0].DocId)
utils.Expect(t, "76", int(outputs.Docs[0].Scores[0]*1000))
utils.Expect(t, "[0 18]", outputs.Docs[0].TokenSnippetLocations)
utils.Expect(t, "5", outputs.Docs[1].DocId)
utils.Expect(t, "100", int(outputs.Docs[1].Scores[0]*1000))
utils.Expect(t, "[0 15]", outputs.Docs[1].TokenSnippetLocations)
}
开发者ID:merryChris,项目名称:wukong,代码行数:37,代码来源:engine_test.go
示例20: TestLookupWithLocations
func TestLookupWithLocations(t *testing.T) {
var indexer Indexer
indexer.Init(types.IndexerInitOptions{IndexType: types.LocationsIndex})
// doc0 = "token2 token4 token4 token2 token3 token4"
indexer.AddDocument(&types.DocumentIndex{
DocId: 0,
Keywords: []types.KeywordIndex{
{"token2", 0, []int{0, 21}},
{"token3", 0, []int{28}},
{"token4", 0, []int{7, 14, 35}},
},
})
utils.Expect(t, "[[0 21] [28]]",
indexer.Lookup([]string{"token2", "token3"}, []string{}, nil)[0].TokenLocations)
}
开发者ID:cnspica,项目名称:wukong,代码行数:16,代码来源:indexer_test.go
注:本文中的github.com/huichen/wukong/utils.Expect函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论