Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

A nodejs binding for crfsuite

License

NotificationsYou must be signed in to change notification settings

vunb/node-crfsuite

Repository files navigation

A nodejs binding for crfsuite

MIT Licensenpm versiondownloadsTravisAppveyor

This is a link to the CRFSuite library written by Naoaki Okazaki. CRF or Conditional Random Fields are a class of statistical modeling method often applied in pattern recognition and machine learning and used for structured prediction.

Installation

For most "standard" use cases (on Mac, Linux, or Windows on a x86 or x64 processor),node-crfsuite will install easy with:

npm install crfsuite

API Usage

CRFSuite Tagger

constcrfsuite=require('crfsuite')consttagger=newcrfsuite.Tagger()letis_opened=tagger.open('./path/to/crf.model')console.log('File model is opened:',is_opened)lettags=tagger.tag(input)console.log('Tags: ',tags)

CRFSuite Trainer

constpath=require('path')constcrfsuite=require('crfsuite')consttrainer=newcrfsuite.Trainer({debug:true})letmodel_filename=path.resolve('./model.crfsuite')letxseq=[['walk'],['walk','shop'],['clean','shop']]letyseq=['sunny','sunny','rainy']// submit training data to the trainertrainer.append(xseq,yseq)trainer.train(model_filename)// output: ./model.crfsuite

Installation Special Cases

We usenode-pre-gyp to compile and publish binaries of the library for most common use cases (Linux, Mac, Windows on standard processor platforms). If you have a special case,node-crfsuite will work, but it will compile the binary during the install. Compiling with nodejs is done vianode-gyp which requires Python 2.x, so please ensure you have it installed and in your path for all operating systems. Python 3.x will not work.

Build from source

# clone the projectgit clone --recursive https://github.com/vunb/node-crfsuite.git# go to working foldercd node-crfsuite# install dependencies and build the binarynpm install

For development:

# rebuildnpm run build# run unit-testnpmtest

Change Log

2020-03-07: Release version 1.0.1

  • Add an options parameter to pass to a Trainer with a debug property to avoid writing logs to stdout. (17) (mathquis)
  • Update typescript declaration file

2019-07-18: Release version 1.0.0

  • Convert all sources to use N-API, removenan
  • Add typescript declaration file
  • Cleanup package dependencies
  • CI Tool run & test only in node version 10 LTS
  • Add project convention:.gitattributes,.editorconfig
  • Enforced to usenew keyword to create newTagger andTrainer

2019-06-09: uses N-API

Fromcrfsuite@0.9.6 the library usesN-API to use the binary in multiple version of Node.

  • Acording to Node.js Foundation: With N-API, native module developers can compile their module once per platform and architecture, and make it available for any version of Node.js that implements N-API. This holds true even for versions of Node.js that are built with a different VM, e.g.Node-ChakraCore.

Contributing

Pull requests and stars are highly welcome.

For bugs and feature requests, pleasecreate an issue.


[8]ページ先頭

©2009-2025 Movatter.jp