Socket
Socket
Sign inDemoInstall

nlp-counter

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    nlp-counter

Counter


Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Install size
22.4 kB
Created
Weekly downloads
 

Readme

Source

Counter Build Status

import Counter from 'counter';

let words = ['the', 'the', 'the', 'the'];
let counter = new Counter();
counter.incAll(words);

counter.inc('a', 1);
counter.inc('a', 1);
counter.inc('b', 1);
counter.inc('b', 1);

counter.normalize();
counter.maxCount();
counter.argMax();

Install

$ npm install nlp-counter

Usage

let counter = new Counter();
let counter_another = new Counter();

let text = `I am firm, You are obstinate, He is a pig-headed fool. I am righteously indignant, you are annoyed, he is making a fuss over nothing. I have reconsidered the matter, you have changed your mind, he has gone back on his word.`
let tokenize = (txt) => txt.replace(/[,\.]+/g, '').split(' ')
let words = tokenize(text);

words.map(w => {
	counter.inc(w);
});

counter.incAll(words);
counter_another.incAll(['the', 'the', 'the', 'the']);

counter.keys();
counter.values();
counter.size();

counter.normalize();
counter.maxCount();
counter.argMax();
counter.elementwiseMax(counter_another);
counter.subtract(counter_another);

API

Counter

inc(key: string, increment = 1)

incAll(keys: [string], increment = 1)

incBy(counter: Counter)

getCount(key: string): number

setCount(key: string, count: number)

removeKey(key: string): number

elementwiseMax(counter: Counter)

totalCount(): number

normalize()

scale(factor: number)

maxCount(): number

argMax(): string

subtract(other: Counter)

toString(): string

clear()

keys(): Iterator

values(): Iterator

size(): number

isEmpty(): boolean

contains(key: string): boolean

CounterMap

inc(key: string, value: string, increment = 1)

incAll(keys: [[string, string]], increment = 1)

getCount(key: string, value: string): number

setCount(key: string, value: string, count: number)

removeKey(key: string, value?: string): number

totalCount(): number

normalize(): number

scale(factor: number)

subtract(other: CounterMap)

toString(): string

keys(): string[]

keySize(): number

totalSize(): number

isEmpty(): boolean

contains(key: string, value?: string): boolean

Maintainers

  • Josherich

Keywords

FAQs

Last updated on 27 Jul 2019

Did you know?

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc