Solved

Compare Text

Posted on 2010-11-16
6
339 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 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
Technology Partners: 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 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Suggested Solutions

Title # Comments Views Activity
issue with DB import 1 36
$_GET call between URL 3 42
MySQL-Design Help 12 42
Convert php array to comma seperated list 19 35
Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
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…
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 dynamically set the form action using jQuery.

749 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