ultra-nlp-js

A Node.js binding for ultra-nlp


Keywords
rust, native, esm, library, nodejs, npm-package
License
MIT
Install
npm install ultra-nlp-js@0.5.1

Documentation

ultra-nlp-js

A ultra-nlp binding for Node.js.

Install

npm install --save ultra-nlp-js
# or
yarn add ultra-nlp-js

API

BehaviorForUnmatched

enum BehaviorForUnmatched {
  Ignore
, KeepAsWords
, KeepAsChars
}

Match

class Match implements JSONSerializable<{
  range: TextRange
  indexOfPatterns: number | null
}> {
  constructor(
    range: TextRange
  , indexOfPatterns: number | null
  )

  getRange(): TextRange
  getIndexOfPatterns(): number | null
  getValueFrom<T>(map: Record<number, T>): T | null
}

TextRange

class TextRange implements JSONSerializable<{
  startIndex: number
  endIndex: number
}> {
  /**
   * @param startIndex byte index
   * @param endIndex byte index
   */
  constructor(
    startIndex: number
  , endIndex: number
  )

  /**
   * @returns byte index
   */
  getStartIndex(): number

  /**
   * @returns byte index
   */
  getEndIndex(): number

  /**
   * @returns byte length
   */
  len(): number

  extract(bufferUTF8: Buffer): string
  extract(text: string): string
}

cedarwood

ForwardDictionary

class ForwardDictionary {
  instance: NativeCedarwoodFowardDictionary

  constructor(patterns: string[])
}

BackwardDictionary

class BackwardDictionary {
  instance: NativeCedarwoodFowardDictionary

  constructor(patterns: string[])
}

segmentFull

function segmentFull(
  text: string
, dict: StandardDictionary
, behaviorForUnmatched: BehaviorForUnmatched
): Match[]

segmentForwardLongest

function segmentForwardLongest(
  text: string
, dict: ForwardDictionary
, behaviorForUnmatched: BehaviorForUnmatched
): Match[]

segmentBackwardLongest

function segmentBackwardLongest(
  text: string
, dict: BackwardDictionary
, behaviorForUnmatched: BehaviorForUnmatched
): Match[]

segmentBidirectionalLongest

function segmentBidirectionalLongest(
  text: string
, forwardDict: ForwardDictionary
, backwardDict: BackwardDictionary
, behaviorForUnmatched: BehaviorForUnmatched
): Match[]

daachorse

StandardDictionary

class StandardDictionary {
  instance: NativeDaachorseStandardDictionary

  constructor(patterns: string[])
}

ForwardDictionary

class ForwardDictionary {
  instance: NativeDaachorseFowardDictionary

  constructor(patterns: string[])
}

BackwardDictionary

class BackwardDictionary {
  instance: NativeDaachorseFowardDictionary

  constructor(patterns: string[])
}

segmentFull

function segmentFull(
  text: string
, dict: StandardDictionary
, behaviorForUnmatched: BehaviorForUnmatched
): Match[]

segmentForwardLongest

function segmentForwardLongest(
  text: string
, dict: ForwardDictionary
, behaviorForUnmatched: BehaviorForUnmatched
): Match[]

segmentBackwardLongest

function segmentBackwardLongest(
  text: string
, dict: BackwardDictionary
, behaviorForUnmatched: BehaviorForUnmatched
): Match[]

segmentBidirectionalLongest

function segmentBidirectionalLongest(
  text: string
, forwardDict: ForwardDictionary
, backwardDict: BackwardDictionary
, behaviorForUnmatched: BehaviorForUnmatched
): Match[]

hashmap

Dictionary

class Dictionary {
  instance: NativeHashmapDictionary

  constructor(patterns: string[])
}

segmentFull

function segmentFull(
  text: string
, dict: Dictionary
, behaviorForUnmatched: BehaviorForUnmatched
): Match[]

segmentForwardLongest

function segmentForwardLongest(
  text: string
, dict: Dictionary
, behaviorForUnmatched: BehaviorForUnmatched
): Match[]

segmentBackwardLongest

function segmentBackwardLongest(
  text: string
, dict: Dictionary
, behaviorForUnmatched: BehaviorForUnmatched
): Match[]

segmentBidirectionalLongest

function segmentBidirectionalLongest(
  text: string
, dict: Dictionary
, behaviorForUnmatched: BehaviorForUnmatched
): Match[]