ifcanduela/abbrev 问题修复 & 功能扩展

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

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

ifcanduela/abbrev

Composer 安装命令:

composer require ifcanduela/abbrev

包简介

Create unambiguous abbreviations for words in a list

README 文档

README

Find unambiguous abbreviations for all words in a list.

Just like npm's abbrev, which is just like ruby's Abbrev.

Installation

Use composer:

composer install ifcanduela/abbrev

Usage

Feed a word list to the Abbrev constructor and then call one of the three public methods.

Suggestions and matches are case-insensitive. The constructor accepts any number of strings or arrays of strings, arbitrarily nested. Once you have an instance it's ready to go.

use ifcanduela\abbrev\Abbrev;

$abbrev = new Abbrev(
        'foo',
        'bar',
        ['baz', 'foobar', ['barbaz']],
    );

Abbrev::match($word)

Get a matching word from the list, or false if the input is ambiguous.

$abbrev = new Abbrev(['ape', 'aperture', 'apprentice'], 'albino', 'append');

$match = $abbrev->match('ap'); // there is not unambiguous match
// => false

$match = $abbrev->match('al'); // there is only one possible match
// => "albino"

Abbrev::suggest($word)

Get a list of matching words from the list for an ambiguous or unambiguous input.

$abbrev = new Abbrev(['ape', 'aperture', 'apprentice'], 'albino', 'append');

$suggestions = $abbrev->suggest('app');
// append
// apprentice

Abbrev::abbreviate()

Retrieve a list of all possible abbreviations.

$abbrev = new Abbrev(['ape', 'aperture', 'apprentice'], 'albino', 'append');

$suggestions = $abbrev->abbreviate();
// [
//   'alb'        => 'albino',
//   'albi'       => 'albino',
//   'albin'      => 'albino',
//   'albino'     => 'albino',
//   'ape'        => 'ape',
//   'aper'       => 'aperture',
//   'apert'      => 'aperture',
//   'apertu'     => 'aperture',
//   'apertur'    => 'aperture',
//   'aperture'   => 'aperture',
//   'appe'       => 'append',
//   'appen'      => 'append',
//   'append'     => 'append',
//   'appr'       => 'apprentice',
//   'appre'      => 'apprentice',
//   'appren'     => 'apprentice',
//   'apprent'    => 'apprentice',
//   'apprenti'   => 'apprentice',
//   'apprentic'  => 'apprentice',
//   'apprentice' => 'apprentice',
// ]

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-06-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固