js-keyword

1.1.3 • Public • Published

jsKeyword

  • jsKeyword provide you a easy way to find a string from long text or thousands of tags by fuzzy query.
  • jsKeyword 可以从大量标签中迅速进行模糊检索,或从超长文本中检索标签,轻松实现搜索和自动完成功能。

npm version

Demo

http://lab.rijnx.com/jsKeyword/

Install

npm install --save js-keyword

Usage

Require Module

var keyword = require('js-keyword');

Push Keywords

Push will exclude duplicated data automatically. It will return number of successful push.

keyword.push(["a", "b", "c", ...]);
keyword.push("a", "b", "c", ...);       // { count: 1 }

Remove

keyword.remove(["a", "b", "c", ...]);
keyword.remove("a", "b", "c", ...);

Check

Check whether the keyword is in the pool.

keyword.check(["a", "b", "c", ...]);
keyword.check("a", "b", "c", ...);

It will return a boolean array of existence.

[true, false, true, ...]

Search

Use Search to find the keyword in a long content. It is like indexOf but is much faster.

keyword.search("this is a test text.");

If succeed, it will return the position of keyword.

[
    {
        keyword: "keyword",
        position: {
            start: xxx,
            end:   xxx,
        },
    },
    {
        keyword: "keyword",
        position: {
            start: xxx,
            end:   xxx,
        },
    },
    ...
]

autoComplete

It will return all the keywords which include the input string.

keyword.autoComplete(input);

Will return an array of string.

["keyword", "keyword", ...]

Screenshots

Readme

Keywords

none

Package Sidebar

Install

npm i js-keyword

Weekly Downloads

2

Version

1.1.3

License

ISC

Unpacked Size

26.9 kB

Total Files

5

Last publish

Collaborators

  • rijn