You’re ranking pages for a search. Write about(times, page_length, average_length, enough): from 0 to 1, how much a page is about one word, given that the word appears times times. page_length is the page’s length in words and average_length the average over all pages. After about enough mentions on an average-length page, more mentions barely matter: the tenth “python” tells you little the ninth didn’t.
Someone searches “python”. Three pages come back, each drawn to its length with a tick for every “python” (the average page is 300 words). Your function scores, from 0 to 1, how much each page is about python.
about(times, page_length, average_length, enough)| times | how often the word appears on the page | e.g. 0 |
| page_length | words on this page | e.g. 300 |
| average_length | words on an average page | e.g. 300 |
| enough | after about this many mentions (on an average page) more barely matter | e.g. 2 |
| returns | 0 to 1: how much the page is about the word | |