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

nlp-js-tools-english

v1.0.2

Published

POS Tagger and lemmatizer for javascript

Downloads

16

Readme

NLP Javascript tools for english language

Tokenize, POS Tagger, lemmatizer and stemmer

Inspired by the french similar lib.

This package is partly based on the Snowball stemming algorythm and the javascript adaptation by Kasun Gajasinghe, University of Moratuwa

This package offers 4 NLP tools in javascript for french language :

  • Tokenizing
  • POS Tagging
  • Lemmatizing
  • Stemming

Install

npm install nlp-js-tools-english

Usage

var NlpjsTEn = require('nlp-js-tools-english');

Corpus to use

var corpus = "Internet Computer price makes a strong bullish comeback, targeting $10.44, as the Federal Reserve leaves interest rates unchanged at 5.25% - 5.5%.";

Configs

var config = {
    tagTypes: ['nat', 'vir', 'vre', 'common', 'nbr'],
    strictness: false,
    minimumLength: 3,
    debug: true
};

New instance with specific corpus and configs

var nlpToolsEn = new NlpjsTEn(corpus, config);

These are the available methods, self-explanatory. Note: The sentence that is passed into the class earlier is automaticaly tokenized.

var tokenizedWords = nlpToolsEn.tokenized;
var posTaggedWords = nlpToolsEn.posTagger();
var lemmatizedWords = nlpToolsEn.lemmatizer();
var stemmedWords = nlpToolsEn.stemmer();
var stemmedWord = nlpToolsEn.wordStemmer("aléatoirement");

Attributes

config

Shows config

tokenized

["semble", "nourrir", "de"]

Methods return

posTagger()

[{
  "id": 1,
  "word": "semble",
  "pos": [
   "VER",
   "VER"
  ]
 },
 {
  "id": 2,
  "word": "nourrir",
  "pos": [
   "VER"
  ]
 },
 {
  "id": 3,
  "word": "de",
  "pos": [
   "NOM",
   "ART:def",
   "PRE"
  ]
 }]

lemmatizer()

[{
  "id": 1,
  "word": "semble",
  "lemma": "sembler"
 },
 {
  "id": 2,
  "word": "nourrir",
  "lemma": "nourrir"
 },
 {
  "id": 3,
  "word": "de",
  "lemma": "de"
 }]

stemmer()

[{
  "id": 1,
  "word": "semble",
  "stem": "sembl"
 },
 {
  "id": 3,
  "word": "nourrir",
  "stem": "nourr"
 },
 {
  "id": 5,
  "word": "de",
  "stem": "de"
}]

wordStemmer(word)

{
    word: "aléatoirement",
    stem: "aléatoir"
}

Config

Option | Type | Default | Description --- | --- | --- | --- tagTypes | Array | ["adj", "adv", "art", "con", "nom", "ono", "pre", "ver", "pro"] | List of dictionnaries the package will look in, in case you only need verbs or nouns, both or whatever else. If a word does not belong to any type, it is tagged as "UNK". strictness | Bool | false | If you set the strictness to true and try to POS Tag the word generalement, it will fail because the word is missine its accents. On the other hand, trying to POS Tag the word with the strictness set to false well return the types art, pre and nom because the word will match de in these dictionnaries. minimumLength | Int | 1 | Algorythms will ignore words that are shorter than this parameter. debug | Bool | false | Enable console debug