queryr/term-store

持久化 Wikibase 术语,支持基于术语的查找和由术语进行的查找

1.3.0 2018-01-04 01:31 UTC

This package is auto-updated.

Last update: 2024-08-29 00:08:27 UTC


README

Build Status Scrutinizer Code Quality Code Coverage Latest Stable Version Download count

存储 Wikibase 实体的术语以方便

  • 根据术语查找 EntityIds
  • 根据 EntityId 查找术语(s)
  • 为 EntityId 存储指纹
  • 删除与 EntityId 相关的所有术语

系统依赖

  • PHP 5.5 或更高版本(支持 PHP 7 和 HHVM)
  • php5-sqlite(仅用于运行测试)

安装

要将此包添加为本地、按项目依赖项,只需将 queryr/term-store 依赖项添加到您的项目 composer.json 文件中。以下是一个只定义了 TermStore 1.x 依赖项的 composer.json 文件的最小示例

{
    "require": {
        "queryr/term-store": "~1.0"
    }
}

用法

如果您想了解数据库模式,请查看 src/TermStoreInstaller.php

所有服务都是通过 TermStoreFactory 类构建的

use Queryr\TermStore\TermStoreFactory;
$factory = new TermStoreFactory(
	$dbalConnection,
	new TermStoreConfig( /* optional config */ )
);

$dbalConnection 是来自 Doctrine DBALConnection 对象。

写入存储

$writer = $factory->newTermStoreWriter();

$writer->storeEntityFingerprint( $entityId, $fingerprint );
$writer->dropTermsForId( $entityId );

根据术语查找 EntityId

$idLookup = $factory->newEntityIdLookup();

$idLookup->getItemIdByLabel( $languageCode, $labelText );
$idLookup->getItemIdByText( $languageCode, $termText );
$idLookup->getIdByLabel( $languageCode, $labelText );

请参阅 EntityIdLookup 接口以获取所有方法和它们的文档。

根据 EntityId 和语言查找标签

$labelLookup = $factory->newLabelLookup();
$labelLookup->getLabelByIdAndLanguage( $entityId, $languageCode );

请参阅 LabelLookup 接口以获取文档。

运行测试

仅用于测试

composer test

仅用于样式检查

composer cs

用于完整的 CI 运行

composer ci

发布说明

版本 1.3.0 (2018-01-04)

  • 将最低 PHP 版本提升到 7.1
  • 添加了标量和返回类型提示

版本 1.2.0 (2017-02-28)

  • 现在允许使用 Wikibase DataModel 6.x 进行安装
  • 现在允许使用 Wikibase DataModel 5.x 进行安装

版本 1.1.0 (2015-11-10)

  • TermStoreFactory 添加了 newLabelLookup
  • 改进了文档

版本 1.0.0 (2015-11-03)

  • 现在允许使用 Wikibase DataModel 4.x 进行安装
  • 现在允许使用 Wikibase DataModel 3.x 进行安装
  • 将最低 Wikibase DataModel 版本更改为 2.5
  • 添加了 ci 命令,该命令运行 PHPUnit、PHPCS、PHPMD 和标签验证
  • 添加了 TravisCI 和 ScrutinizerCI 集成

版本 0.2.2 (2014-10-21)

  • 现在允许使用 Wikibase DataModel 2.x 进行安装

版本 0.2.1 (2014-10-05)

  • 通过使用事务改进了 TermStore::storeEntityFingerprint 的性能

版本 0.2 (2014-09-11)

  • 添加了 TermStoreFactory。服务构建现在应通过此工厂进行
  • 添加了 EntityIdLookup,它现在由 TermStore 实现
  • TermStore 添加了 getItemIdByLabelgetPropertyIdByLabelgetItemIdByTextgetPropertyIdByText

版本 0.1 (2014-06-23)

  • 首次发布