Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

302
Views
How to find similar text with nodejs

I'm trying to develop a simple search engine to get match sentences in a text file with nodejs, but i want to improve my search engine to get similar text and not just the exact text, any suggestions of how can I do this?

this is my code:

const folder = "./movies/data";
const fs = require("fs");

function search(params) {
  let list = [];

  fs.readdirSync(folder).forEach((file) => {
    const data = fs.readFileSync(`movies/data/${file}`, {
      encoding: "utf8",
      flag: "r",
    });
    if (data.includes(params)) {
      list.push(data);
    }
  });
  console.log(
    `Foram encontradas ${list.length} ocorrências pelo termo ${params}.`
  );
  return `Foram encontradas ${list.length} ocorrências pelo termo ${params}.`;
}

let args = process.argv.slice(2);
search(args.join(" "));

module.exports = search;
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Before to implement any algorith, you have to choose a text comparison algorithm.

On of the best is the Levenshtein distance
https://en.wikipedia.org/wiki/Levenshtein_distance

Link of Levenshtein distance implementation in JS
https://www.tutorialspoint.com/levenshtein-distance-in-javascript

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!