Détail du package

mol_text_distance

jin5.1k0.0.1214

Calculates the lexicographical distance between two texts.

$mol_text_distance, $mol_text, $mol, $mol_text_profile_distance

readme

$mol_text_distance

Calculates the lexicographical distance between two texts.

Algorithm

  • A simple and fast.
  • Text profile based.
  • Normalized from 0 (equal) to 1 (different).
  • Rearrangement of words gives short distance.
  • Different texts length support.
  • Independent of changes position.
  • Complexity O(n).
  • Memory usage O(log n).
  • For equal length texts it's a metric).

Usage

// 0.18
$mol_text_distance(
    `little meerkat jumps over big elephant`,
    `over little elephant jumps big meerkat`,
)

// 0.66
$mol_text_distance(
    `A structural comparison of arbitrary objects is discussed.`,
    `Application of caching for correct comparison of cyclic references is disclosed.`,
)
const profile1 = $mol_text_profile( `profile` )
const profile2 = $mol_text_profile( `prodir` )
const distance = $mol_text_profile_distance( profile1, profile2 ) // 0.54

NPM Bundle

npm install mol_text_distance

1KB

import { $mol_text_distance } from 'mol_text_distance'