Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
nlp-toolkit
Advanced tools
This module covers some basic nlp principles and implementations. Every implementation in this module is written as stream to only hold that data in memory that is currently processed at any step.
This module covers some basic nlp principles and implementations. The main focus is performance. When we deal with sample or training data in nlp, we quickly run out of memory. Therefore every implementation in this module is written as stream to only hold that data in memory that is currently processed at any step.
npm install nlp-toolkit
Frequency distribution of words in texts. Tokenize, remove stopwords, stem words, count words. Traditionally those steps happen sequentially. But we do not need to tokenize the whole text before removing stopwords.
var nlp = require('nlp-toolkit');
var fs = require('fs');
var es = require('event-stream');
fs.createReadStream('./pride_prejudice.txt')
.pipe(es.split())
.pipe(nlp.tokenizer())
.pipe(nlp.stopwords())
.pipe(nlp.stemmer())
.pipe(nlp.frequency())
.on('data', function (freqDist) {
console.log(freqDist.slice(0, 10));
})
.on('error', function (err) {
console.error(err);
});
.pipe(nlp.tokenizer(options))
options
:
attribute | type | description |
---|---|---|
characters | RegExp | regular expression that describes what characters to strip of off (default /[^\w]/g ). |
separator | RegExp | regular expression that describes where to split words (default /\s/g ). |
eliminateNumbers | boolean | discard tokens that only contain numbers (default false ). |
toLowerCase | boolean | transform every token to lower case (default true ). |
emptyStrings | boolean | keep empty string when through some previous steps tokens result in length === 0 (default false ). |
Tokenizer also work in a non-stream context:
var tokens = nlp.tokenizer(string, options);
.pipe(nlp.stopwords(options))
options
:
attribute | type | description |
---|---|---|
defaultLang | string | default language if processed object does not provide a lang attribute (default en ). |
additionalWords | object | add additional stopwords to the list of stopwords |
additionalWords
:
attribute | type | description |
---|---|---|
all | array | list of stopwords to add to every language |
default | array | list of stopwords if language is not supported |
lang | array | list of stopwords specific to lang |
Supported languages: da, de, en, es, fi, fr, hu, it, nl, no, pt, ro, ru, se, tr
.
Stopwords also work in a non-stream context:
nlp.stopwords(sentence, options)
.then(function (tokens) {}})
.catch(function (err) { console.error(err); });
.pipe(nlp.stemmer(options))
options
:
attribute | type | description |
---|---|---|
defaultStemmer | string | default stemmer for language if processed object does not provide a lang attribute (default en ). |
Supported languages: da, de, en, es, fi, fr, hu, it, nl, no, pt, ro, ru, se, tr
.
Stopwords also work in a non-stream context:
var tokens = nlp.stemmer(sentence, options);
This module uses the stemmer implementation of Snowball-Stemmer.
.pipe(nlp.frequency())
FAQs
This module covers some basic nlp principles and implementations. Every implementation in this module is written as stream to only hold that data in memory that is currently processed at any step.
The npm package nlp-toolkit receives a total of 66 weekly downloads. As such, nlp-toolkit popularity was classified as not popular.
We found that nlp-toolkit demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.