Socket
Book a DemoInstallSign in
Socket

word-frequency-basic

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

word-frequency-basic

Finding the number of repeating words in a text

1.0.0
latest
Source
npmnpm
Version published
Weekly downloads
3
Maintainers
1
Weekly downloads
 
Created
Source

word-frequency-basic

NPM

Single function code block for finding the number of repeating words in a text.

Install

yarn add word-frequency-basic

or

npm i word-frequency-basic

Usage

ParametersTypeDefaultDescription
textstringnullThe text to be split into words
caseSensitivebooleantrueAllows you to count by paying attention to whether the letters are big or small.
letter"normal" / "upperCase" / "lowerCase""normal"Words can be output in uppercase, lowercase or normal letters.
noPunctuationbooleantrueDetermines whether to remove punctuation marks.
import numberOfWords from "word-frequency-basic"

numberOfWords(text, caseSensitive, letter, noPunctuation)

Examples

import numberOfWords from "word-frequency-basic"

const text = "Hello world, count my words, hello again."

// Example 1
console.log(numberOfWords(text))

/* Output 1
{
  "Hello": 1,
  "world": 1,
  "count": 1,
  "my": 1,
  "words": 1,
  "hello": 1,
  "again": 1
}
*/

// Example 2
console.log(numberOfWords(text, false))

/* Output 2
{
  "hello": 2,
  "world": 1,
  "count": 1,
  "my": 1,
  "words": 1,
  "again": 1
}
*/

// Example 3
console.log(numberOfWords(text, true, "upperCase"))

/* Output 3
{
  "HELLO": 1,
  "WORLD": 1,
  "COUNT": 1,
  "MY": 1,
  "WORDS": 1,
  "AGAIN": 1
}
*/

// Example 4
console.log(numberOfWords(text, true, "normal", false))

/* Output 4
{
  "hello": 1,
  "world,": 1,
  "count": 1,
  "my": 1,
  "words,": 1,
  "again.": 1
}
*/

Keywords

word

FAQs

Package last updated on 18 Jan 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.