1.0.8 • Published 2 years ago

related-documents v1.0.8

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
2 years ago

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.

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago