
Research
/Security News
Critical Vulnerability in NestJS Devtools: Localhost RCE via Sandbox Escape
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
A lightweight, rule-based text similarity calculator that selects the most appropriate comparison algorithm based on input string lengths.
SimText is a minimalistic and lightweight text similarity calculator designed for efficiency and ease-of-use. SimText provides a streamlined approach to measure textual likeness.
🪶 Lightweight: Crafted with performance in mind, SimText ensures fast calculations without bogging down your applications.
🔍 Multiple Algorithms:
Levenshtein Distance: Ideal for single, short words, offering a precise measure of character-level differences.
Jaccard Similarity: Computes similarity between sets of words, making it great for longer texts.
N-gram Similarity: Versatile and adaptable, it breaks down text into overlapping chunks for a nuanced similarity measure.
🎯 Contextual Selection: Based on the length and nature of your text inputs, SimText intelligently chooses the most suitable algorithm to offer you the best similarity results.
npm install simtext --save
This guide provides instructions on how to use the exported functions designed to measure the similarity between two strings. These methods include Levenshtein similarity, Jaccard similarity, n-gram similarity, and a general text comparison function.
Compares two strings and returns a similarity score based on the Levenshtein distance.
a
: First string.b
: Second string.import {levenshteinSimilarity} from 'simtext';
const score = levenshteinSimilarity("apples", "apple");
console.log(score); // 0.8333333333333334
Calculates the Jaccard similarity between two strings, comparing the unique words in each string.
str1
: First string.str2
: Second string.import {jaccardSimilarity} from 'simtext';
const score = jaccardSimilarity("apple pie", "apple crumble pie");
console.log(score); // 0.6666666666666666
Computes the n-gram similarity between two strings. This divides the strings into 'n' consecutive characters and then compares them.
str1
: Fienter code hererst string.str2
: Second string.n
: (Optional) Number of characters for the n-gram. Default is 2.import {ngramSimilarity} from 'simtext';
const score = ngramSimilarity("Roses are red, violets are blue", "Roses are red and the sky is blue", 2);
console.log(score); // 0.4166666666666667
A comprehensive function that determines the most appropriate similarity method based on the nature of the input strings.
str1
: First string.str2
: Second string.import {compareText} from 'simtext';
const score = compareText("apple", "appel");
console.log(score); // 0.6.
Note: The compareText
function uses heuristics to choose the similarity method. For example, if both strings are single words and under 10 characters, it uses the levenshteinSimilarity
. If the character count of both strings combined is above 200, it uses jaccardSimilarity
. Otherwise, it uses ngramSimilarity
.
FAQs
A lightweight, rule-based text similarity calculator that selects the most appropriate comparison algorithm based on input string lengths.
The npm package simtext receives a total of 164 weekly downloads. As such, simtext popularity was classified as not popular.
We found that simtext demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Research
/Security News
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.