-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
84 lines (76 loc) · 2.52 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package main
import (
"dictionary"
"fmt"
"index07"
_ "indexMaintain"
_ "matchQuery1"
"matchQuery2"
"runtime"
)
func traceMemStats() {
var ms runtime.MemStats
runtime.ReadMemStats(&ms)
fmt.Printf("Alloc:%d(bytes) HeapIdle:%d(bytes) HeapReleased:%d(bytes)", ms.Alloc, ms.HeapIdle, ms.HeapReleased)
}
func main() {
fmt.Println("字典树D:===============================================================")
fmt.Println("字典树D内存占用大小:")
//traceMemStats()
fmt.Println()
root := dictionary.GenerateDictionaryTree("src/resources/50000Dic.txt", 1, 2, 100) //
fmt.Println()
//traceMemStats()
fmt.Println()
fmt.Println("索引项集:===============================================================")
fmt.Println()
fmt.Println("索引项集内存占用大小:")
traceMemStats()
fmt.Println()
_, indexTreeNode := index07.GenerateIndexTree("src/resources/500000Index.txt", 1, 2, root) //
fmt.Println()
traceMemStats()
fmt.Println()
/*indexTreeNode.FixInvertedIndexSize()
sort.SliceStable(index07.Res, func(i, j int) bool {
if index07.Res[i] < index07.Res[j] {
return true
}
return false
})
fmt.Println(index07.Res)
fmt.Println(len(index07.Res))
sum := 0
for _,val := range index07.Res{
sum += val
}
fmt.Println(index07.Res[0])
fmt.Println(index07.Res[len(index07.Res)-1])
fmt.Println(index07.Res[len(index07.Res)/2])
fmt.Println(sum/len(index07.Res))*/
/*indexTreeNode.SearchGramsFromIndexTree()
fmt.Println(len(index07.Grams))
var numsOfgrams2_12 [4]int
for _,val := range index07.Grams{
numsOfgrams2_12[len(val)]++
}
fmt.Println(numsOfgrams2_12)*/
/*fmt.Println("新增索引后的索引项集:===============================================================")
fmt.Println()
fmt.Println("索引项集内存占用大小:")
//traceMemStats()
fmt.Println()
indexMaintain.AddIndex("src/resources/add2000.txt", 1, 3, root, indexTree)
fmt.Println()
//traceMemStats()
fmt.Println()*/
//resInt := matchQuery2.MatchSearch("get english", root, indexTreeNode, 1, 2)
var searchQuery = [9]string{"get", "get english", "get english images", "get images", "get english images team_hm_header_shad.gif http 1.0", "get images s102325 gif http 1.0", "get english history history_of images cup", "images space.gif", "get http 1.0"}
for i := 0; i < 9; i++ {
resInt := matchQuery2.MatchSearch(searchQuery[i], root, indexTreeNode, 1, 2) //get english venues
//fmt.Println(resInt)
fmt.Println(len(resInt))
fmt.Println("==================================================")
}
//fmt.Println(len(resInt))
}