定制 denis-korolev/opencorpora 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

denis-korolev/opencorpora

Composer 安装命令:

composer require denis-korolev/opencorpora

包简介

Library to serialize opencorpora export file data from xml to objects

README 文档

README

Test status on master

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-01-18

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固