🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

nlp-counter

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nlp-counter

Counter

1.0.1
latest
Source
npm
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
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

counter

FAQs

Package last updated on 27 Jul 2019

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