florence/dictionary

此包已被弃用,不再维护。未建议替代包。

一个对常见俚语及其含义一视同仁的城市词典

安装: 0

依赖: 0

建议者: 0

安全性: 0

星标: 2

关注者: 1

分支: 0

开放问题: 0

类型:项目

dev-master 2020-07-09 21:42 UTC

This package is auto-updated.

Last update: 2023-07-10 04:19:00 UTC


README

Build Status

Checkpoint One

此包主要是为了学术目的而构建的。它可以描述为一个符合phpleague.com规范且使用测试驱动开发过程(PHPUnit)的无偏见包。

  • 数据:主要词典,一个包含城市词汇的静态关联数组

  • 词典:CRUD实现和排名系统实现。

  • WordExistsException:返回关联的异常信息

  • WordNotFoundException:返回关联的异常信息

安装

通过如下方式使用composer要求

    composer require florence/dictionary

使用方法

    $dictionary = Data::$data;

    $dictionary = new Dictionary($dictionary); 

添加俚语

    $dictionary->addSlang($slang, $description, $sentence);

检索俚语

    $dictionary->findOne($slang);
    
    $dictionary->findAll();

更新俚语

    $dictionary->updateSlang($slang, $description, $sentence);

删除俚语

    $dictionary->deleteOne($slang);
    
    $dictionary->deleteAll();

实现排名

排名系统是通过使用rankWords()方法实现的。

现在您可以通过以下方式遍历数据数组以获取所需输出

foreach(Data::$data as $row => $innerArray)
{   

    $res = $innerArray['Sample-sentence'];

    $getRank = $ranker->rankAndSort($res);

    $output = '';

        foreach($getRank as $key => $value)
        {
            $output .= "$key => $value".', ';
        }

        $output = rtrim("[".$output,','."]")."<br>";

        // print the final output

        echo $output;
        echo "<br>";
}

示例输出

[“Tight” => 3, “Prosper” => 2, “Yes” => 1, “Have” => 1, “you” => 1, “finished” => 1, “the” => 1, “curriculum?” => 1]