liquidmetal

:sweat_drops::metal: A mimetic poly-alloy of the Quicksilver scoring algorithm, essentially LiquidMetal.

Github星跟踪图

LiquidMetal

A mimetic poly-alloy of the Quicksilver
scoring algorithm, essentially LiquidMetal. </Schwarzenegger Voice>

Flex matching short abbreviations against longer strings is a boon in
productivity for typists. Applications like
Quicksilver, Alfred,
LaunchBar, and
Launchy have made this method of keyboard entry a
popular one. It's time to bring this same functionality to web controls.
LiquidMetal makes scoring long strings against abbreviations easy.

Usage

Include the library:

<script src="liquidmetal.js" type="text/javascript"></script>

Score any string against an abbreviation:

LiquidMetal.score("FooBar",  "foo")   //=> 0.950
LiquidMetal.score("FooBar",  "fb")    //=> 0.917
LiquidMetal.score("Foo Bar", "fb")    //=> 0.929
LiquidMetal.score("Foo Bar", "baz")   //=> 0.0
LiquidMetal.score("Foo Bar", "")      //=> 0.8

All scores fall between a range of 0.0 (no match) to 1.0 (perfect match).

Inspired By

Why?

  • To satisfy my own requirements for the
    jquery.flexselect plugin
  • The Quicksilver algorithm doesn't give proper weight to abbreviations that
    match the first character of the scored string.
  • The Quicksilver algorithm is extremely slow for certain length
    string/abbreviation combinations because of its use of recursion. While
    slightly slower for shorter length string/abbreviation combinations,
    LiquidMetal outperforms the Quicksilver algorithm by orders of magnitude under
    other conditions.
  • The javascript version of the Quicksilver algorithm (Quicksilver.js) is case
    sensitive and doesn't give added weight to camel case strings; whereas,
    LiquidMetal is case insensitive and does give added weight to uppercase
    letters in camel case strings.

Todo

  • More tests
  • Consider tweaking the scores for "trailing" characters
  • Improve implementation of highest score matching (LiquidMetal
    currently returns the highest scoring match for an abbreviation,
    but is inefficient)
  • See if it's possible to tune the performance further

Author

Ryan McGeary (@rmm5t)

License

MIT License

主要指标

概览
名称与所有者rmm5t/liquidmetal
主编程语言JavaScript
编程语言JavaScript (语言数: 2)
平台
许可证MIT License
所有者活动
创建于2009-02-06 00:16:49
推送于2020-06-17 02:10:02
最后一次提交2020-06-16 20:09:49
发布数7
最新版本名称v1.3.0 (发布于 )
第一版名称v0.1 (发布于 )
用户参与
星数295
关注者数8
派生数24
提交数56
已启用问题?
问题数6
打开的问题数1
拉请求数4
打开的拉请求数0
关闭的拉请求数0
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?