ts-playground
    Preparing search index...

    Function computeTermFrequencies

    • Calculate TF (Term Frequency)

      Parameters

      • documents: Document[]

        The documents to calculate TF from

      Returns WordScore[]

      An array of dictionaries of words and their TF

      const documents = [
      ['a', 'b', 'c', 'c],
      ['a', 'b', 'd'],
      ]

      const result = computeTermFrequencies(documents)
      result // => [{ a: 0.25, b: 0.25, c: 0.5 }, { a: 0.3333333333333333, b: 0.3333333333333333, d: 0.3333333333333333 }]