npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

incremental-search-keywords

v1.0.7

Published

JavaScript library to extract incremental keywords from a string or object

Downloads

81

Readme

Incremental Search Keyword Library

This is a JavaScript library that provides functionality to extract keywords from a string, an object, or an array of strings. The main function of the library is extract.

Installation

To install the library, use the following command:

npm install incremental-search-keywords

## Browser Usage

You can also use the `extract` function in a browser environment. First, include the library in your HTML file:

```html
<script src="path/to/incremental-search-keywords.js" ></script>

Then, you can use the extract function to extract keywords from a string, an object, or an array of strings. Here's an example:

const input = "This is a sample string for testing the keyword extractor library.";
const options = {
    minWordLength: 3,
    skipDigits: true,
    skipSpecialCharacters: true,
    skipStopWords: true,
    stopWords: ['the', 'a', 'is', 'for'],
    asItIs: ['keyword', 'extractor'] // Array of words to be included as they are

};

const keywords = extract(input, options);

console.log(keywords);

In this example, the extract function will extract keywords from the input string based on the options object. The options object specifies that the minimum length of a keyword should be 3, digits should be skipped, special characters should be skipped, stop words should be skipped, and the stop words are 'the', 'a', 'is', and 'for'.

Nodejs Usage

First, import the extract function from the library:

const { extract } = require('keyword-extractor-library');

Then, you can use the extract function to extract keywords from a string, an object, or an array of strings. Here's an example:

const input = { "title": "This is a sample string for testing the keyword extractor library." };
const options = {
    minWordLength: 3,
    skipDigits: true,
    skipSpecialCharacters: true,
    skipStopWords: true,
    stopWords: ['the', 'a', 'is', 'for']
};

const keywords = extract(input, options);

console.log(keywords);

In this example, the extract function will extract keywords from the input string based on the options object. The options object specifies that the minimum length of a keyword should be 3, digits should be skipped, special characters should be skipped, stop words should be skipped, and the stop words are 'the', 'a', 'is', and 'for'.

Default Options in extract

The extract function has some default options that you can override if necessary. Here's a description of each option:

  • minWordLength: This option specifies the minimum length of a word to be considered for extraction. The default minimum length is 3.

  • skipDigits: This option specifies whether to skip words that are purely digits. The default is true, meaning words that are purely digits are skipped.

  • skipSpecialCharacters: This option specifies whether to skip words that contain special characters. The default is true, meaning words with special characters are skipped.

  • skipStopWords: This option specifies whether to skip words that are considered common, or "stop words". The default is true, meaning stop words are skipped.

  • stopWords: This option allows you to provide your own list of stop words. The default is a predefined list of common stop words.

  • keys: This option allows you to provide a list of keys to extract from the input if the input is an object. The default is null, meaning all keys are considered.

  • omit: This option allows you to provide a list of keys to omit from the input if the input is an object. The default is an empty array, meaning no keys are omitted by default. In case both keys and omit are present, keys takes priority

  • asItIs: This option allows you to specify an array of words that should be included in the output without modification, regardless of other filtering options such as skipDigits, skipSpecialCharacters, or skipStopWords. This is useful for ensuring specific keywords or phrases are always included in the extracted results. The default is an empty array, meaning no words are included as-is by default.

Here's an example of how to override the default options:

const options = {
  minWordLength: 2,
  skipDigits: false,
  skipSpecialCharacters: false,
  skipStopWords: false,
  stopWords: ['my', 'custom', 'stopwords'],
  keys: ['key1', 'key2']
};

const keywords = extract('This is a test string', options);