Page 1 of 1

calculation

Posted: Mon Oct 20, 2003 7:03 am
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.