Solved

Compare Text

Posted on 2010-11-16
6
332 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 30

Accepted Solution

by:
Marco Gasi earned 500 total points
Comment Utility
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 108

Expert Comment

by:Ray Paseur
Comment Utility
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
Comment Utility
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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 30

Expert Comment

by:Marco Gasi
Comment Utility
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
Comment Utility
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 108

Expert Comment

by:Ray Paseur
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to dynamically set the form action using jQuery.

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now