Relative frequency measures how much of a document’s token stream belongs to a specified term. Divide the term’s count by the document’s total token count to obtain a fraction or percentage, making comparisons less dependent on document length. section 3.1
Measuring “justice”
In a 23-token sentence, “justice” appears once, so its relative frequency is 1 ÷ 23, or about 4%. That score reflects occurrence share, not necessarily the term’s importance. section 3.1
>>> len(counts) #1 18 >>> counts.sum() 23 >>> len(tokens) #2 23 >>> counts / counts.sum() #3 , 0.217391 and 0.086957 It 0.043478 has 0.043478 also 0.043478 ...
Inspect token counts, verify that their sum matches the token total, and divide the counts by that total with pandas. section 3.1
Because common words can dominate these percentages while carrying little meaning, relative frequency serves as an intermediate normalization before broader document statistics provide term significance. section 3.1
