ts-playground
    Preparing search index...

    Function computeInverseDocumentFrequency

    • Calculate IDF (Inverse Document Frequency)

      Parameters

      • documents: Document[]

        The documents to calculate IDF from

      Returns WordScore

      A dictionary of words and their IDF

      const documents = [
      ['a', 'b', 'c'],
      ['a', 'b', 'd'],
      ]
      const result = computeInverseDocumentFrequency(documents)
      result // => { a: 0.0, b: 0.0, c: 0.6931471805599453, d: 0.6931471805599453 }