nlcst-normalize

2018-11-13 admin

nlcst-normalize是什么

什么是nlcst-normalize,Normalize a word for easier comparison

nlcst-normalize使用教程帮助文档

nlcst-normalize Build Status Coverage Status

Normalize a word for easier comparison, useful for NLCST.

Installation

npm:

npm install nlcst-normalize

Usage

var normalize = require('nlcst-normalize')

normalize("Don't") // => 'dont'
normalize('Don’t') // => 'dont'
normalize('Don’t', {allowApostrophes: true}) // => 'don\'t'
normalize('Block-level') // => 'blocklevel'
normalize('Block-level', {allowDashes: true}) // => 'block-level'

normalize({
  type: 'WordNode',
  children: [
    {type: 'TextNode', value: 'Block'},
    {type: 'PunctuationNode', value: '-'},
    {type: 'TextNode', value: 'level'}
  ]
}) // => 'blocklevel'

API

normalize(value[, options])

Normalize a word (string, Node, Array.<Node>) for easier comparison. Always normalises smart apostrophes () to straight apostrophes (') and lowercases alphabetical characters ([A-Z]).

options.allowApostrophes

boolean, default: false — Do not strip apostrophes (').

options.allowDashes

boolean, default: false — Do not strip hyphens (-).

Contribute

See contributing.md in syntax-tree/nlcst for ways to get started.

This organisation has a Code of Conduct. By interacting with this repository, organisation, or community you agree to abide by its terms.

License

MIT © Titus Wormer

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处。

转载请注明:文章转载自 JavaScript中文网 [https://www.javascriptcn.com]

本文地址:https://www.javascriptcn.com/read-45330.html

文章标题:nlcst-normalize

回到顶部