denis-korolev/opencorpora
Composer 安装命令:
composer require denis-korolev/opencorpora
包简介
Library to serialize opencorpora export file data from xml to objects
README 文档
README
Library to serialize opencorpora export file data from xml to objects
This library will help you read Opencorpora export file. In library we have 5 processors:
- GrammemeProcessor (reads only Grammeme node)
- LemmaProcessor (reads only Lemma node)
- LinksProcessor (reads only Links node)
- LinkTypeProcessor (reads only LinkType node)
- RestrictionProcessor (reads only Restr node)
Use this processors to extract xml data to simple DTO objects. XML file opens and reads by PHP library XMLReader
and SimpleXMLElement node by node. That why it use not a lot of memory.
Installation / Usage
Install the latest version via composer:
composer require denis-korolev/opencorpora
Here is an example of usage GrammemeProcessor. Other processors using exactly same.
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; }
统计信息
- 总下载量: 3
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-01-18