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

stanford-postagger

v1.1.5

Published

Stanford Log-Linear Part-Of-Speech (POS) Tagger

Downloads

81

Readme

Stanford-PoSTagger

Stanford Log-Linear Part-Of-Speech (PoS) Tagger for Node.js

About

This is a small JavaScript library for use in Node.js environments, providing the possibility to run the Stanford Log-Linear Part-Of-Speech (PoS) Tagger as a local background process and query it with a frontend JavaScript API. Use this for tagging the words of English, German, French, Spanish, Arabic and Chinese texts with PoS tags such as noun, verb, adjective, etc.

NOTICE

The Stanford PoS-Tagger is written in Java and hence this Node.js modules requires an installed java executable in the environment. Additionally, notice that the Stanford PoS-Tagger is licensed under GNU General Public License and is not part of this module. It is 128 MB in size and ships with 21 models. It is automatically downloaded from its external origin on npm install. Applications using this Node.js module have to take the license of Stanford PoS-Tagger into account. The module pos (LGPL licensed, English only), the module en-pos (MIT licensed, English only), the module wink-pos-tagger (AGPL licensed, English only), the module compromise (MIT licensed, English only), and the module kompromiss (MIT licensed, German only) are decent alternatives if less accuracy and smaller language support are acceptable.

Models

This package includes the following upstream Stanford PoS-Tagger models:

Model Id | Language | PoS Tags | Alias Id ----------------------------------------|----------|----------------------|---------- english-left3words-distsim | English | Penn Treebank | english english-caseless-left3words-distsim | English | Penn Treebank | english-bidirectional-distsim | English | Penn Treebank | wsj-0-18-left3words-distsim | English | Penn Treebank | english-alt wsj-0-18-left3words-nodistsim | English | Penn Treebank | wsj-0-18-caseless-left3words-distsim | English | Penn Treebank | wsj-0-18-bidirectional-distsim | English | Penn Treebank | wsj-0-18-bidirectional-nodistsim | English | Penn Treebank | german-hgc | German | STTS Treebank | german german-ud | German | STTS Treebank | german-fast | German | STTS Treebank | german-fast-caseless | German | STTS Treebank | french | French | French Treebank | french french-ud | French | French Treebank | spanish | Spanish | Spanish Treebank | spanish spanish-distsim | Spanish | Spanish Treebank | spanish-ud | Spanish | Spanish Treebank | arabic | Arabic | Bies Tags | arabic arabic-train | Arabic | Bies Tags | chinese-distsim | Chinese | LDC Chinese Treebank | chinese chinese-nodistsim | Chinese | LDC Chinese Treebank |

For English we recommend the english-left3words-distsim (aliased as english) model or alternatively the wsj-0-18-left3words-distsim (aliased as english-alt) model (both with the Penn Treebank PoS tags). For German we recommend the german-ghc (aliased german) model (with the STTS Treebank PoS tags).

Installation

$ npm install stanford-postagger

Usage

(async () => {
    const POS = require(".")
    const pos = new POS()
    await pos.start()
    await pos.tag("The Stanford PoS-Tagger is a great piece of software!").then((data) => {
        console.log(data)
    })
    await pos.stop()
})().catch((err) => {
    console.log(`ERROR: ${err}`)
})

Output:

The_DT Stanford_NNP PoS-Tagger_NNP is_VBZ a_DT great_JJ piece_NN of_IN software_NN !_.

Application Programming Interface

declare class PoSTagger {
    constructor(options?: {
        javaBinary?: string   /* default: "java" */
        javaOptions?: string  /* default: "-server -Xms1G -Xmx1G" */
        tagger?:string        /* default: "${__dirname}/stanford-postagger.d/stanford-postagger.jar" */
        model?: string        /* default: "english" */
    })

    public on(
        event: string,
        callback: (event: any) => void
    ): void

    public start(
    ): Promise<void>

    public tag(
        text: string,
    ): Promise<string>

    public stop(
    ): Promise<void>
}

Motivation

The major differences of stanford-postagger to similar NPM modules and the motivation for the existence of stanford-postagger are:

  1. stanford-postagger, in contrast to the node-stanford-postagger module, does not depend on Docker or XML-RPC. Instead, it just requires the java executable and speaks over stdin/stdout to the Stanford PoS-Tagger process.

  2. stanford-postagger, in contrast to other scripting approaches, does not spawn Stanford PoS-Tagger process for every query. Instead, it uses a continuously running background process.

  3. stanford-postagger, in contrast to other approaches, does not need a pre-installed Stanford PoS-Tagger. Instead, it automatically downloads and locally installs the Stanford PoS-Tagger distribution on npm install.

License

Copyright (c) 2018-2019 Dr. Ralf S. Engelschall (http://engelschall.com/)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.