PHP code example of spekulatius / keyword-merge

1. Go to this page and download the library: Download spekulatius/keyword-merge library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

spekulatius / keyword-merge example snippets


$kwcmp = new Spekulatius\KeywordMerge\KeywordComparator;

$kwcmp->matchesWord('tbilisi georgia', 'is tbilisi the capital of georgia?');
// false

$kwcmp->containsWord('tbilisi georgia', 'is tbilisi the capital of georgia?');
// true

$kwcmp->similarWord('tbilisi georgia', 'georgias tbilisi');
// true

$kwcmp = new Spekulatius\KeywordMerge\KeywordComparator;

$kwcmp->matchesWords('tbilisi georgia', 'is tbilisi the capital of georgia?');
// []

$kwcmp->containsWords('tbilisi georgia', 'is tbilisi the capital of georgia?');
// ['is tbilisi the capital of georgia?']

$kwcmp->similarWords('tbilisi georgia', 'georgias tbilisi');
// ['georgias tbilisi']

$kwcmp = new Spekulatius\KeywordMerge\KeywordComparator;

$kwcmp->inUrlPath('https://example.com/cats-are-awesome', 'seo tools');
// false

$kwcmp->inUrlPath('https://example.com/seo-tools', 'seo tools');
// true

$kwcmp->inUrlPath('https://example.com/chrome-seo-tools', 'chrome seo tools and toolkit');
// true - one word difference is accepted, from 3+ words