🚀 Big News:Socket Has Acquired Secure Annex.Learn More →
Socket
Book a DemoSign in
Socket

@lyrasearch/plugin-token-relevance

Package Overview
Dependencies
Maintainers
4
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lyrasearch/plugin-token-relevance

Plugin to add TF-IDF scores to a Lyra index

latest
npmnpm
Version
0.0.1-alpha.2
Version published
Maintainers
4
Created
Source

Token Relevance Plugin

Tests

Plugin to add TF-IDF scores to a Lyra index.

RuntimeStatus
Node.js✅  available
Bun✅  available
V8 isolates✅  available
Major browsers✅  available
Deno✅  available

Usage

For the complete usage guide, please refer to the official plugin documentation.

TL;DR

import { create, insert } from "@lyrasearch/lyra";
import { generateScores } from "plugin-token-relevance";

const db = create({
  schema: {
    author: "string",
    quote: "string",
  },
});

insert(db, {
  quote: "The quick brown fox jumps over the lazy dog",
  author: "John Doe",
});

insert(db, {
  quote: "This quick brown fox is so quick! How can it be so quick?",
  author: "Jane Doe",
});

insert(db, {
  quote: "I have a pair of red shoes.",
  author: "Jimmy Does",
});

const scores = generateScores(db);

console.log(scores);
{
  quote: {
    '76465079-2': {
      the: 0.24413606414846878,
      quick: 0.04505167867868493,
      brown: 0.04505167867868493,
      fox: 0.04505167867868493,
      jumps: 0.12206803207423439,
      over: 0.12206803207423439,
      lazy: 0.12206803207423439,
      dog: 0.12206803207423439
    },
    '76465079-42': {
      this: 0.08450863758985458,
      quick: 0.0935688711018841,
      brown: 0.03118962370062803,
      fox: 0.03118962370062803,
      is: 0.08450863758985458,
      so: 0.16901727517970916,
      how: 0.08450863758985458,
      can: 0.08450863758985458,
      it: 0.08450863758985458,
      be: 0.08450863758985458
    },
    '76465079-60': {
      i: 0.1569446126668728,
      have: 0.1569446126668728,
      a: 0.1569446126668728,
      pair: 0.1569446126668728,
      of: 0.1569446126668728,
      red: 0.1569446126668728,
      shoes: 0.1569446126668728
    }
  },
  author: {
    '76465079-2': { john: 0.5493061443340548, doe: 0.2027325540540822 },
    '76465079-42': { jane: 0.5493061443340548, doe: 0.2027325540540822 },
    '76465079-60': { jimmy: 0.5493061443340548, does: 0.5493061443340548 }
  }
}

License

Apache-2.0

Keywords

lyra

FAQs

Package last updated on 28 Aug 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts