Constructors

Properties

n: number

n-gram width

sentinel: string

sentinel character

Methods

  • Add a term into index by key

    Parameters

    Returns void

    It is recommended to use strings as keys, as currently using numbers might be slow.

    RangeError if term is shorter than n

  • Returns whole index as an object

    Returns object

  • Does the index has term?

    Parameters

    • term: string

    Returns boolean

    RangeError if term is shorter than n

  • Search by term and return locations where this term occurs

    Parameters

    • term: string

    Returns Locations

    RangeError if term is shorter than n

  • Normalise a term

    Calls the normalisation function given on constructor, and checks that term length is at least index length.

    Parameters

    • term: string

    Returns string

    RangeError if term is shorter than n

  • Search by term and return indices of matching terms

    Parameters

    • term: string

    Returns Indexable[]

    RangeError if term is shorter than n

  • Size of the index (number of terms in the index)

    Returns number

  • Create index from terms

    Terms can be an array of terms or an object mapping ids to terms

    Parameters

    Returns Index

  • Collapse and trim whitespace, then lowercase the input

    Parameters

    • term: string

    Returns string