Re: Need to mark similar phrases in two different texts

SuperNova wrote:
I need to mark similar phrases in two different texts, for example to
use <b> tag.

Why do you want this?

This may work:
1) Make a list of words in each text.
2) Compute the intersection of these lists, so that the result is a list
with words which are present in both texts.
3) Filter this list to avoid common words such as 'it' and 'a'.
4) Mark the all words in the list bold in the texts.

Something like this:

$text1 = 'Google Chrome[...]';
$text2 = 'Hematology Analyzers[...]';

// We don't want case sensitivity
$lower1 = strtolower($text1);
$lower2 = strtolower($text2);

// Array of words
$array1 = preg_split('/\W/', $lower1);
$array2 = preg_split('/\W/', $lower2);

// Intersect
$intersect = array_intersect($array1, $array2);

// Filter
$filter = array('a', '');
$filtered = array_diff($intersect , $filter);

// Make bold
foreach ($filtered as $word) {
$text1 = preg_replace("/($word)/i", '<b>\1</b>', $text1);
$text2 = preg_replace("/($word)/i", '<b>\1</b>', $text2);

echo $text1;
echo $text2;

Relevant Pages

  • New, revised list of spyware-related IPs
    ... replaced those filters with complete filters of Internetfuel. ... This IP blocklist is intended to be used to block known spyware sites ... This will filter Alexa while ... able to delete rules in the previous lists which block traffic to and ...
  • RE: Connecting and filtering lists
    ... I had set the filter up to filter that ... >> We added two User Information Lookup columns to the TeamMembers Table. ... >> then the MemberProject, then the Projects table. ... >> PROJECTS views show all rows from the lists (they are only filtered after the ...
  • Re: error message: Cannot delete an issue which is not current
    ... I can confirm that this resolves the display issue when filtering lists ... I have created a similar help desk and added the field invoice which ... you must set your filter so that it matches your criteria ...
  • Re: Exchange 2007-Dynamic Distribution Group - Custom Attribute
    ... And what is the best way to Upgrade or convert Exchange 2003 Address Lists ... shell and use the -RecipientFilter parameter to define a filter. ... Filterable Properties for the -RecipientFilter Parameter in Exchange 2007 ...
  • Re: intersection
    ... > Create a new worksheet and all the lists into column A. ... > Since there's a header in A1, put this in B2 and copy down. ... > Filter to show just the true.true.true.true's. ... >> I have a problem with Excel, I have to do an intersection between 4 ...