calculation

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
theclay7
Forum Commoner
Posts: 50
Joined: Wed Feb 19, 2003 3:17 am

calculation

Post by theclay7 »

i have big problem, would anyone pls kindly help.

i have to read these quotes:
quotes[0] = "to be or not to be that is the question"

quotes[1] = "love looks not with the eyes but with the mind"

quotes[2] = "love all trust a few do wrong to none"

then I have to calculate the following:

1) df = number of quotes containing the term (e.g. df["to"] = 2 from quotes[0] and quotes[2])

2) pairs of QID and tf
QID = quote ID
tf = frequency of a term within a quote
(e.g. For "to" , {QID = 0, tf = 2}, {QID = 2, tf = 1})

(but if it is "a", it will only show {QID = 2, tf = 1})

and print in the format as follow:
/*** word<tab>df<tab>QID<tab>tf ***/
a<tab>1<tab>2<tab>1
to<tab>2<tab>0<tab>2<tab>2<tab>1


how can I do that in PHP? please kindly help. thank you.
Post Reply