项目作者: rse

项目描述 :
Stanford Log-linear Part-Of-Speech (PoS) Tagger for Node.js
高级语言: JavaScript
项目地址: git://github.com/rse/stanford-postagger.git
创建时间: 2018-05-12T22:26:32Z
项目社区:https://github.com/rse/stanford-postagger

开源协议:

下载


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

  1. $ npm install stanford-postagger

Usage

  1. (async () => {
  2. const POS = require(".")
  3. const pos = new POS()
  4. await pos.start()
  5. await pos.tag("The Stanford PoS-Tagger is a great piece of software!").then((data) => {
  6. console.log(data)
  7. })
  8. await pos.stop()
  9. })().catch((err) => {
  10. console.log(`ERROR: ${err}`)
  11. })

Output:

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

Application Programming Interface

  1. declare class PoSTagger {
  2. constructor(options?: {
  3. javaBinary?: string /* default: "java" */
  4. javaOptions?: string /* default: "-server -Xms1G -Xmx1G" */
  5. tagger?:string /* default: "${__dirname}/stanford-postagger.d/stanford-postagger.jar" */
  6. model?: string /* default: "english" */
  7. })
  8. public on(
  9. event: string,
  10. callback: (event: any) => void
  11. ): void
  12. public start(
  13. ): Promise<void>
  14. public tag(
  15. text: string,
  16. ): Promise<string>
  17. public stop(
  18. ): Promise<void>
  19. }

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.