This is a more or less theoretical question, but I hope that fellow monks might find it interesting.

I'm working on a database of quotes (from Buffy The Vampire Slayer).

I want people to be able to add a quote to the database, but I also want to check the quote isn't already there.

So say I have this quote in the database:

I walk. I talk. I shop, I sneeze. I'm gonna be a fireman when the floods roll back. There's trees in the desert since you moved out. And I don't sleep on a bed of bones.

what if someone comes along and enters an abbreviated version -- say they think it's better just as:

I'm gonna be a fireman when the floods roll back. There's trees in the desert since you moved out.

or what if their spelling/interpretation differs slightly:

I'm going to be a fireman when the floods roll back. ^^^^^^^^^^^

I would like to be able to somehow compare the strings in such a way that the fact that the quote is already entered shows up, despite the fact that it's not exactly the same, either shorter or longer or slightly differently written in some aspects.

I can't think of a smart way to do this, though of course you could just compare all possible substrings of the two strings, which seems overly mechanical.

The result should presumably be a percentage score or similar?

Thanks in Advance,
CP

--
Weaselling out of things is important. It's what separates us from the animals ... except the weasel.


In reply to Smart Comparison of Buffy Strings by Cody Pendant

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.