?
Solved

Compare Text

Posted on 2010-11-16
6
Medium Priority
?
344 Views
Last Modified: 2012-05-10
Maybe some one did before. I want to make script which will found in mysql text which more similar. Like fore example i have 1000 text in my database and i need to find which is more similar.
Can any one give idea how i can make this script. Which way is better to server and speed. I will made all in php. Maybe some one have some script
0
Comment
Question by:umaxim
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
6 Comments
 
LVL 31

Accepted Solution

by:
Marco Gasi earned 2000 total points
ID: 34154545
It looks like you had an input text and you wish search in your table which text is more similar to the input one: is it correct? If this is the case, you have to keep in mind that you can't (AFAIK) check for similar meanings: even supposing this is possible, you should hire a professional developer to do it.

Then you have two possibilities:

1. you can use metaphone() function (http://it.php.net/metaphone): this function return true if two string sound similar;

2. you can use similar_text() function (http://it.php.net/manual/en/function.similar-text.php): this function compares string by character and not by sound

3. you can use levenshtein() function (http://it.php.net/manual/en/function.levenshtein.php) which compares strings calculating the number of chars one has to change in string1 to make it equal to string 2;

A fourth possibility is to combine the above tecniques.

None of these tecniques refers to the menings, so they can help or not depending on what exactly you are trying to do.

If you think someone of this tecniques could be interesting for you and you need of some other suggestion to implement them in your code, please let me know.

Cheers
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 34154655
Speed will not really be an issue if the numbers are in the range of "have 1000 text in my database" because 1,000 of anything will get processed very fast.  The central issue here is going to be how you define "similar."

Please post two or three examples of your texts and a test case that should be found to be similar to one of the examples.  Then we can provide more concrete assistance.  The length of the text matters a great deal, so it will be best for us to start from examples.  In very short texts, some combinations of soundex(), metaphone(), and sometimes levenshtein() may be the right tools.
0
 
LVL 1

Author Comment

by:umaxim
ID: 34157361
I will just by text.Like if i take "Hi my name is maxym" i need to show up all text where i have "Hi my name is maxym" and for the same staff all text. I think i will split by senteces and then check which text have what sentences.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 31

Expert Comment

by:Marco Gasi
ID: 34157414
I don't know if I really understand but can you test this?

$sql="SELECT text FROM table HWERE text LIKE "%Hi my name is maxym%";
$res = mysql_query($sql) etc...

Cheers
0
 
LVL 1

Author Comment

by:umaxim
ID: 34157477
eap i think to do like this but how to do is it will have like 500 word. It will take for long time to find everything by sentences.
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 34157583
Please post two or three examples of your texts and a test case that should be found to be similar to one of the examples.  Thanks.
0

Featured Post

Introducing Priority Question

Increase expert visibility of your issues by participating in Priority Question, our latest feature for Premium and Team Account holders. Adjust the priority of your question to get emergent issues in front of subject-matter experts for help when you need it most.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question