Update the index

Recompute the inverse_doc_frequency values. Must be called manually after indexing new document with the option auto_update = false.

Property definitions

vsm $ VSMIndex :: update_index
	# Update the index
	#
	# Recompute the `inverse_doc_frequency` values.
	# Must be called manually after indexing new document with the option
	# `auto_update = false`.
	fun update_index do
		for doc in documents do
			for term, ccount in doc.terms_count do
				inverse_doc_frequency[term] = (documents.length.to_f / terms_doc_count[term]).log
			end
		end
		for doc in documents do
			for term, freq in doc.terms_frequency do
				doc.tfidf[term] = freq * inverse_doc_frequency[term]
			end
		end
	end
lib/vsm/vsm.nit:196,2--212,4