PHP code example of denis-korolev / opencorpora
1. Go to this page and download the library: Download denis-korolev/opencorpora 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/ */
denis-korolev / opencorpora example snippets
use JMS\Serializer\Naming\IdenticalPropertyNamingStrategy;
use JMS\Serializer\Naming\SerializedNameAnnotationStrategy;
use JMS\Serializer\SerializerBuilder;
use Opencorpora\Dictionary\Grammeme;
use Opencorpora\GrammemeProcessor;
$serializer = SerializerBuilder::create()->setPropertyNamingStrategy(
new SerializedNameAnnotationStrategy(
new IdenticalPropertyNamingStrategy()
)
)
->build();
// path to file
$fileName = $this->projectDir . DIRECTORY_SEPARATOR . 'var' . DIRECTORY_SEPARATOR . 'dict.opcorpora.xml';
$processor = new GrammemeProcessor($serializer);
foreach ($processor->getData($fileName) as $grammeme) {
/**
* @var $grammeme Grammeme
*/
echo $grammeme->name;
echo $grammeme->parent;
echo $grammeme->description;
echo $grammeme->alias;
}