Calculating TF

I have a question, I'm crating a script that will calculate the TF from a document. I have the document stored in a vector.

My question is when I print the vector I get the frequency of times the words appear in the text, for example the word college appears 10 times in the text. Should I keep the numbers like this or should I make the number between 0 and 1?

Because every where that I look they say that the TF is 0.1 or 0.9.

Here is the code I have to calculate the frequency.
#Get the word frequency from the text.
for my $word (@$words){
   $wordcount{$word}++;
}

Open in new window

LVL 1
EnnioAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Adam314Commented:
Keeping the TF between 0 and 1 means it is normalized.  To do this, divide every number by the highest frequency.

Whether or not you do this will depend on how you are using it.
0
EnnioAuthor Commented:
So I should dived it to the highest frequency or the number of words in the text?

0
Adam314Commented:
By the highest frequency.

For examle, if you had this:
    college: 10
    apple: 6
    letter: 16
You would divide each by 16, because it is the highest frequency, getting:
    college: .625
    apple: .375
    letter: 1.0
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
EnnioAuthor Commented:
ok... thanks... because I was looking some where and they said to divide by the total numbers of terms in the text.  That make sense now.

:)
0
Adam314Commented:
Well, again it depends on what you are looking for, but you could divide each by the total number of terms in the text.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Perl

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.