0

I want to make an app where a user inputs some word, and then that word is detected and highlighted on the page. The difficult part is that I want all forms of the word to be detected. This would ultimately be for translation purposes.

So if the user enters eat I want to have that match with eat, eats, eating, and ate.

Ideally this supports multiple languages as well.

Is there a library for this, preferably in JavaScript? So far I've found this decade old question and stuff like the Porter Stemming algorithm, but haven't come across a good, modern solution so far.

ShaneOH
  • 1,454
  • 1
  • 17
  • 29

1 Answers1

0

You would probably be looking for a stemming algorithm, in particular the implementation for Javascript.

Here are a couple JS libraries that could get you started:

  • Porter stemming algorithm GitHub repo
  • Lancaster stemming algorithm (tends to be more aggressive) GitHub repo

Not sure if either of them support multiple languages though.

Also, I'd suggest reading some material on the differences to understand which one would suit your use-case better. You could start off with this article on Baeldung and this post What are the major differences and benefits of Porter and Lancaster Stemming algorithms?

Nick
  • 61
  • 5