Solved

Compare Text

Posted on 2010-11-16
6
338 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
  • 2
  • 2
  • 2
6 Comments
 
LVL 31

Accepted Solution

by:
Marco Gasi earned 500 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 109

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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
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 109

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

828 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