index.go
package types
type DocumentIndex struct {????// 文本的DocId????DocId uint64
????// 文本的關鍵詞長????TokenLength float32
????// 加入的索引鍵????Keywords []KeywordIndex}
// 反向索引項,這實際上標注了一個(搜索鍵,文檔)對。type KeywordIndex struct {????// 搜索鍵的UTF-8文本????Text string
????// 搜索鍵詞頻????Frequency float32
????// 搜索鍵在文檔中的起始字節位置,按照升序排列????Starts []int}
// 索引器返回結果type IndexedDocument struct {????DocId uint64
????// BM25,僅當索引類型為FrequenciesIndex或者LocationsIndex時返回有效值????BM25 float32
????// 關鍵詞在文檔中的緊鄰距離,緊鄰距離的含義見computeTokenProximity的注釋。????// 僅當索引類型為LocationsIndex時返回有效值。????TokenProximity int32
????// 緊鄰距離計算得到的關鍵詞位置,和Lookup函數輸入tokens的長度一樣且一一對應。????// 僅當索引類型為LocationsIndex時返回有效值。????TokenSnippetLocations []int
????// 關鍵詞在文本中的具體位置。????// 僅當索引類型為LocationsIndex時返回有效值。????TokenLocations [][]int}
// 方便批量加入文檔索引type DocumentsIndex []*DocumentIndex
func (docs DocumentsIndex) Len() int {????return len(docs)}func (docs DocumentsIndex) Swap(i, j int) {????docs[i], docs[j] = docs[j], docs[i]}func (docs DocumentsIndex) Less(i, j int) bool {????return docs[i].DocId < docs[j].DocId}
// 方便批量刪除文檔索引type DocumentsId []uint64
func (docs DocumentsId) Len() int {????return len(docs)}func (docs DocumentsId) Swap(i, j int) {????docs[i], docs[j] = docs[j], docs[i]}func (docs DocumentsId) Less(i, j int) bool {????return docs[i] < docs[j]}
type DocumentIndex struct {????// 文本的DocId????DocId uint64
????// 文本的關鍵詞長????TokenLength float32
????// 加入的索引鍵????Keywords []KeywordIndex}
// 反向索引項,這實際上標注了一個(搜索鍵,文檔)對。type KeywordIndex struct {????// 搜索鍵的UTF-8文本????Text string
????// 搜索鍵詞頻????Frequency float32
????// 搜索鍵在文檔中的起始字節位置,按照升序排列????Starts []int}
// 索引器返回結果type IndexedDocument struct {????DocId uint64
????// BM25,僅當索引類型為FrequenciesIndex或者LocationsIndex時返回有效值????BM25 float32
????// 關鍵詞在文檔中的緊鄰距離,緊鄰距離的含義見computeTokenProximity的注釋。????// 僅當索引類型為LocationsIndex時返回有效值。????TokenProximity int32
????// 緊鄰距離計算得到的關鍵詞位置,和Lookup函數輸入tokens的長度一樣且一一對應。????// 僅當索引類型為LocationsIndex時返回有效值。????TokenSnippetLocations []int
????// 關鍵詞在文本中的具體位置。????// 僅當索引類型為LocationsIndex時返回有效值。????TokenLocations [][]int}
// 方便批量加入文檔索引type DocumentsIndex []*DocumentIndex
func (docs DocumentsIndex) Len() int {????return len(docs)}func (docs DocumentsIndex) Swap(i, j int) {????docs[i], docs[j] = docs[j], docs[i]}func (docs DocumentsIndex) Less(i, j int) bool {????return docs[i].DocId < docs[j].DocId}
// 方便批量刪除文檔索引type DocumentsId []uint64
func (docs DocumentsId) Len() int {????return len(docs)}func (docs DocumentsId) Swap(i, j int) {????docs[i], docs[j] = docs[j], docs[i]}func (docs DocumentsId) Less(i, j int) bool {????return docs[i] < docs[j]}
轉載于:https://www.cnblogs.com/zhangboyu/p/7461643.html
總結
- 上一篇: 将一段区间的偶数分解为两个素数相加(Ja
- 下一篇: 幽灵按键