On 5/27/06, Jeroen Bulters <[EMAIL PROTECTED]> wrote:
> I want to compare two documents in the index (i.e. retrieve the cosine
> similarity/score between two documents term-vector's). Is this possible
> using the standard Ferret functionality?
Hi Jeroen,
No problem. Make sure you store term-vectors when you add the field. That is;
doc.add_field(:field, "yada yada yada",
Field::Store::NO, # or YES
Field::Index::TOKENIZED, # or UNTOKENIZED
Field::TermVector::YES) # or anything else but NO
Then you can retrieve the term vector from an index reader like so;
term_vector = index_reader.get_term_vector(doc_num, :field)
terms = term_vector.terms # array of terms in :field in document
freqs = term_vector.freqs # array of corresponding frequencies
Hope that helps. Is that enough to get you going?
Cheers,
Dave
_______________________________________________
Ferret-talk mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ferret-talk