vsm :: VSMIndex :: index_document
With each new document, the inverse_doc_frequency
must be updated.
By default, the method update_index
is called after each call to
index_document
.
When processing batch documents, use auto_update = false
to disable
the auto update of the index.
# Index a document
#
# With each new document, the `inverse_doc_frequency` must be updated.
# By default, the method `update_index` is called after each call to
# `index_document`.
#
# When processing batch documents, use `auto_update = false` to disable
# the auto update of the index.
fun index_document(doc: DOC, auto_update: nullable Bool) do
for term, count in doc.terms_count do
terms_doc_count.inc(term)
if not inversed_index.has_key(term) then
inversed_index[term] = new Array[DOC]
end
inversed_index[term].add doc
end
documents.add doc
if auto_update == null or auto_update then update_index
end
lib/vsm/vsm.nit:176,2--194,4