SPIMI-INVERT(token_stream)
1 output_ f ile = NEWFILE()
2 dictionary = NEWHASH()
3 while (free memory available)
4 do token ← next(token_stream)
5 if term(token) ∈/ dictionary
6 then postings_list = ADDTODICTIONARY(dictionary, term(token))
7 else postings_list = GETPOSTINGSLIST(dictionary, term(token))
8 if f ull(postings_list)
9 then postings_list = DOUBLEPOSTINGSLIST(dictionary, term(token))
10 ADDTOPOSTINGSLIST(postings_list, docID(token))
11 sorted_terms ← SORTTERMS(dictionary)
12 WRITEBLOCKTODISK(sorted_terms, dictionary, output_ f ile)
13 return output_ f ile