demola / urbandictionary
一个帮助管理城市词汇(俚语)的包
dev-master / 1.0.x-dev
2016-04-02 10:52 UTC
Requires
- php: >=5.5.9
- satooshi/php-coveralls: ^1.0
Requires (Dev)
- phpunit/phpunit: ^4.8.22
This package is not auto-updated.
Last update: 2024-09-20 18:28:49 UTC
README
Urban Dictionary 是城市词汇的集合。它是一个存储词汇意义和用法的多关联数组包。该包允许添加、编辑、更新和检索字典中的词汇。
设计
类
-
UrbanWords:包含存储城市词汇的数组。
-
DictionaryEngine:包含向城市词典中添加新词、检索整个词典、检索词汇、更新现有词汇和删除城市词典中的词汇的方法。
-
RankWord:包含根据句子中词汇出现的次数对词汇进行排名的方法。
安装
要安装此包,需要 PHP 5.5+ 和 composer。满足这些要求后,请输入以下代码:
$ composer require demola/urbandictionary
用法
该词典包含带有其意义和用法的城市词汇
-
创建 dictionaryManager 实例
$dictionaryManager = new DictionaryEngine();
-
将城市词汇添加到词典中
$dictionaryManager->add('word', 'description', 'sampleSentence'); // This returns true
-
从词典中检索一个词汇
$data = $dictionaryManager->retrieve('word');
-
检索整个词典
$data = $dictionaryManager->retrieveAll();
-
更新一个词汇及其意义和示例句子
$data = $dictionaryManager->update('word', newDescription', 'newSampleSentence');
-
删除城市词典中的一个词汇
$dictionaryManager->delete('word'); // This returns true
-
在一个句子中对词汇进行排名
-
创建一个 wordOccurence 实例
$wordOccurence = new RankWord; $ranking = $wordOccurence->rankWord($word));
-
测试
在 urban-dictionary 目录中运行以下命令:
~ phpunit
变更日志
请查看 CHANGELOG 文件以获取最近更改的信息。
贡献
请查看 CONTRIBUTING 文件以获取详细的贡献指南。
安全
如果您发现任何问题,请通过 ademola.raimi@andela.com 联系我们。
致谢
Urban Dictionary 由 Raimi Ademola 维护。
许可
UrbanDictionary 在 MIT 许可证 下发布。有关详细信息,请参阅捆绑的 LICENSE 文件。