Skip to content
Advertisement

How do I determine the term frequency of the terms in each document?

I’m building an inverted index, but I can’t seem to get the correct frequencies when I check the database. I read everywhere that you should use a HashMap, but I’m not quite sure if this is the correct method of doing so. Any ideas?

JavaScript

Advertisement

Answer

You should get the value for the token first, increment it and put it again.

Like this in your loop:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement