1. Go to this page and download the library: Download kr-digital/names-detector 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/ */
kr-digital / names-detector example snippets
$namesDetector = new \KRDigital\NamesDetector\NamesDetector();
$firstNameEntry = $namesDetector->extractFirstName('Иванов Иван Иванович');
// $entry->getValue() = 'Иван', $entry->getGender()->getValue() = 'm'
$middleNameEntry = $namesDetector->extractMiddleName('Иванов Иван Иванович');
// $middleNameEntry->getValue() = 'Иванович', $middleNameEntry->getGender()->getValue() = 'm'
$title = $namesDetector->createTitle('Мария Петровна Смирнова');
// $title = 'Уважаемая Мария Петровна'
$customDictionaryPath = '/var/www/app/data/en_dictionary.json';
// поддерживаемые форматы: php, json
$config = new \KRDigital\NamesDetector\Config\Config($customDictionaryPath);
$namesDetector = new \KRDigital\NamesDetector\NamesDetector($config);
// <...>
$namesDetector = new \KRDigital\NamesDetector\NamesDetector();
$prefix = new \KRDigital\NamesDetector\Entry\Prefix\Prefix('Дорогой', 'Дорогая');
$namesDetector->createTitle('Иванов Иван Иванович', $prefix); // 'Дорогой Иван Иванович'
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.