florence/dictionary 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

florence/dictionary

Composer 安装命令:

composer create-project florence/dictionary

包简介

An urban dictionary agnostic of common slangs and their meanings

README 文档

README

Build Status

Checkpoint One

This package was built mainly for academic purposes. It can be described ad an agnostic package that conforms with thephpleague.com specifications and uses the Test Driven Development process (PHPUnit)

Classes

  • Data: The main dictionary, a static associative array that contains urban words

  • Dictionary: CRUD implementations and Ranking System Implementation.

  • WordExistsException: Returns the associated exception message

  • WordNotFoundException: Returns the associated exception message

Installation

Require via composer like so:

    composer require florence/dictionary

Usage

    $dictionary = Data::$data;

    $dictionary = new Dictionary($dictionary); 

Add Slang

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

Retrieve Slang

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

Update Slang

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

Delete Slang

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

Implement Ranking

The ranking system is implemented using the rankWords() method.

You can now traverse through the Data array to get your desired output like so:

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>";
}

Sample Output:

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

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-10-11