I'm looking for advice on how to deal with comparing (in regards to similarity) documents. I've been checking out Text::Compare, and it seems to do the job quite nicely. However, my plead for advice and knowledge is a bit more "abstract". :)

First of, I want to describe my approach;
# Create a list of files/documents that haven't been # compared to the rest of the documents my @new_docs = $foo->get_new_documents(); my @old_docs = $foo->get_old_documents(); # Process my $Compare = Text::Compare->new( memoize => 1 ); foreach my $new_doc ( @new_docs ) { $Compare->first( $new_docs ); foreach my $old_doc ( @old_docs ) { $Compare->second( $old_doc ); $foo->save_similarity( $new_doc, $old_doc, $Compare->similarit +y() ); } }
This works quite well, but you all understand that if there are 100,000 documents to compare against, it will take a lot of time. Is it possible to something "smart" to make it go faster?

My other question is; what is the best way to store the similarity info? Right now I have a document_similarity table which contains a pointer doc1_id and doc2_id (int, combined primary key) and a similarity field (float). This works, but are there smarter ways here as well?

Thanks in advance for any input!

In reply to Comparing text documents by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.