2017 © Pedro Peláez
 

library simpledict

SimpleDict

image

minuux/simpledict

SimpleDict

  • Saturday, February 11, 2017
  • by minuux
  • Repository
  • 1 Watchers
  • 1 Stars
  • 11 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 63 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

SimpleDict

这是一个简单快速的词库工具,用来从一段文本中找出存在于词库的词语。, (*1)

特点

  • 简单:纯 PHP 实现,无需安装扩展。
  • 快速:查找耗时跟词库大小关系不大(我的小破本上查询 40 万的词库轻轻松松),不会一次性加载整个词库,使用时内存占用小(就是生成词库的时候有点费内存)。

使用方法

准备文本格式的词库, (*2)

首先准备一个文本文件,每个词占一行。格式:, (*3)

词语<tab>值, (*4)

生成 SimpleDict 专用词库, (*5)

SimpleDict::make("text_file_path", "output_dict_path");

搜索, (*6)

$dict = new SimpleDict("dict_path");
$result = $dict->search("some text here...");

/* $result 的格式:
array(
  'word1' => array('value' => 'value1', 'count' => 'count1'),
  ...
)*/

替换, (*7)

// 简单替换
$replaced = $dict->replace("some text here...", "**");
// 高级替换
$replaced = $dict->replace("some text here...", function($word, $value) {
  return "[$word -> $value]";
});

The Versions

11/02 2017

dev-master

9999999-dev

SimpleDict

  Sources   Download

The Requires

  • php >=5.3.3

 

11/02 2017

1.1.0

1.1.0.0

SimpleDict

  Sources   Download

The Requires

  • php >=5.3.3

 

10/02 2017

1.0.0

1.0.0.0

SimpleDict

  Sources   Download