Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (4)
As of 2024-04-19 23:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found