related-documents
TypeScript icon, indicating that this package has built-in type declarations

1.0.8 • Public • Published

related-documents

npm Build Release Docs

Description

Rank text documents by similarity.

Install

Install using NPM or similar.

npm i related-documents

Usage

import { Related } from "related-documents";

const documents = [
  { title: "ruby", text: "this lorem ipsum blah foo" },
  { title: "ruby", text: "this document is about python." },
  { title: "ruby and node", text: "this document is about ruby and node." },
  {
    title: "examples",
    text: "this document is about node. it has node examples",
  },
];

// The serializer array length must match that of the weights array.
// This example applies a weight of 10 to the title and 1 to the text.
const options = {
  serializer: (document: any) => [document.title, document.text],
  weights: [10, 1],
};

const related = new Related(documents, options);

// Find documents related to document[0]
related.rank(documents[0]);

See the reference documentation.

/related-documents/

    Package Sidebar

    Install

    npm i related-documents

    Weekly Downloads

    98

    Version

    1.0.8

    License

    Apache-2.0

    Unpacked Size

    38.3 kB

    Total Files

    10

    Last publish

    Collaborators

    • jpoehnelt