はじめに
これまで、
ディスクベースの構築方法
第3回では、
これらの方法はいずれも、
今回はSort-based InversionとMerge-based Inversionと呼ばれる2つの方法を紹介します。
Sort-based Inversionによる構築
Sort-based Inversionによる構築手順は、
その後、
1: file = NewFile()
2: dictionary = NewHash()
3: while all documents have not been processed do
4: D = GetDocument()
5: for all token ∈ do
6: if term(token) ∉ dictionary then
7: postings list = AddToDictionary(dictionary, term(token))
8: end if
9: WriteRecordToFile(TermID(token),DocID(token),Freq(token), file)
10: end for
11: end while
12: ExternalSort(file)
13: inverted_file = NewFile()
14: for all term ∈ file do
15: ConstructPostingList(term, inverted_file)
16: end for

Merge-based Inversionによる構築
Merge-based Inversionによる構築も同様に疑似コードを使って説明します
この方法では、
この作業を全文書を処理できるまで繰り返し、
1: n ← 0
2: while all documents have not been processed do
3: n ← n + 1
4: filen = NewFile()
5: dictionary = NewHash()
6: while free memory available do
7: D = GetDocument()
8: for all token ∈ D do
9: if term(token) ∉ dictionary then
10: posting_list = AddToDictionary(dictionary, term(token))
11: else
12: posting_list = GetPostingList(dictionary, term(token))
13: end if
14: if full(posting_list) then
15: posting_list = DoublePostingList(dictionary, term(token))
16: end if
17: AddToPostingsList(posting_list, docID(token))
18: end for
19: end while
20: sorted terms ← SortTerms(dictionary)
21: WriteBlockToDisk(sorted terms, dictionary, filen)
22: end while
23: MergeBlocks(file1,...,filen, filemerged)

Sort-based Inversion vs. Merge-based Inversion
ここではアルゴリズムの細かい解析は省略しますが、
構築方法の種類
転置索引の構築には、
- 静的な構築方法
(offline index construction, offline approarch) - 動的な構築方法
(online index construction, online approarch)
静的な構築方法では、
つまり、
一方、
まとめ
今回は、
- 参考文献
[1] Inverted files for text search engines, Justin Zobel, Alistair Moffat, ACM Computing Surveys (CSUR), 2006 [2] Introduction to Information Retrieval, C. D. Manning, P. Raghavan, H. Schutze , Cambridge University Press, 2008 [3] Managing Gigabytes: Compressing and Indexing Documents and Images, Ian H. Witten, Alistair Moffat, Timothy C. Bell, Morgan Kaufmann Publisher, 1999