Solved

Compare Text

Posted on 2010-11-16
6
341 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 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 110

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
Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

 
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 110

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

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

691 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