Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Ngram

Represents a set of zero or more tokens from a text.

Hierarchy

  • Ngram

Index

Constructors

constructor

  • new Ngram(tokens?: Token[]): Ngram
  • Parameters

    • Default value tokens: Token[] = []

    Returns Ngram

Properties

Private cachedKey

cachedKey: string

Private cachedLemmaKey

cachedLemmaKey: string | undefined

occurrence

occurrence: number = 1

occurrences

occurrences: number = 1

Private tokens

tokens: Token[]

Accessors

characterLength

  • get characterLength(): number
  • Returns the length of the n-gram in characters. This does not account for whitespace.

    Returns number

characterPosition

  • get characterPosition(): number
  • Returns the position (in units of character) at which this n-gram appears in the sentence.

    Returns number

    • the position

key

  • get key(): string
  • Returns the n-gram key

    Returns string

lemmaKey

  • get lemmaKey(): string | undefined
  • Returns the n-gram lemma-based key

    Returns string | undefined

sentenceCharacterLength

  • get sentenceCharacterLength(): number
  • Returns the length of the sentence (in units of character) in which this n-gram occurs. This includes whitespace in the sentence

    Returns number

sentenceTokenLength

  • get sentenceTokenLength(): number
  • Returns the length of the sentence (in units of {@link Token}) in which this n-gram occurs.

    Returns number

tokenLength

  • get tokenLength(): number
  • Returns the length of the n-gram in {@link Token}'s

    Returns number

tokenPosition

  • get tokenPosition(): number
  • Returns the position (in units of {@link Token} ) at which this n-gram appears in the sentence.

    Returns number

    • the position

Methods

Private cacheKeys

  • cacheKeys(): void
  • Caches the keys if they have not already been generated

    Returns void

equals

  • equals(ngram: Ngram): boolean
  • Checks if two n-grams are equal

    Parameters

    Returns boolean

getTokens

  • getTokens(): Token[]
  • Returns the tokens in this n-gram

    Returns Token[]

isBigram

  • isBigram(): boolean
  • Checks if this n-gram contains two tokens

    Returns boolean

isNull

  • isNull(): boolean
  • Checks if this n-grams is an empty placeholder

    Returns boolean

isTrigram

  • isTrigram(): boolean
  • Checks if this n-gram contains three tokens

    Returns boolean

isUnigram

  • isUnigram(): boolean
  • Checks if this n-gram contains one token

    Returns boolean

looksLike

  • looksLike(ngram: Ngram): boolean
  • Checks if two n-grams look the same

    Parameters

    Returns boolean

toJSON

  • toJSON(verbose?: boolean): object
  • Outputs the n-gram to json

    Parameters

    • Default value verbose: boolean = false

      print full metadata

    Returns object

toString

  • toString(): string
  • Returns the n-gram key

    Returns string

Generated using TypeDoc