Kane250 Posted April 12, 2009 Share Posted April 12, 2009 Hi, I did find search results on this - but they don't seem to do what I want to do, and could really use a hand getting this code started if anyone is familiar with this function. Basically, I am taking a paragraph of text, splitting it up into sentences and into an array, and inserting each one by one into a table. However, there is a high probability of very similar text or exact text to be re-inserted over and over, so what I want to do is use the levenshtein function to check against the database for similarity and only allow it to insert if it's a certain percentage different (or however you define it). Basically, I know that I need an array of what's already in my database, and that the function should compare the array of sentences against that array, but I don't really get how to use this function to make the decision of it passing through or not... Any help is very much appreciated! Here is the relevant code I want to add this too.. $para1content = "these would be sentences. More sentences."; $para1exploded = (split('[.!?] ', $para1content)); foreach ($para1exploded as $content) { $query = "INSERT INTO `$value` (`text`, `key`, `added_at`) VALUES ('$content', '$key', CURRENT_TIMESTAMP)"; if (!mysql_query($query,$conn)) { die('Error=' . mysql_error()); } }; Link to comment https://forums.phpfreaks.com/topic/153721-familiar-with-levenshtein/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.