Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lunr-languages

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lunr-languages

A a collection of languages stemmers and stopwords for Lunr Javascript library

  • 1.14.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
114K
decreased by-10.11%
Maintainers
1
Weekly downloads
 
Created

What is lunr-languages?

The lunr-languages npm package extends the functionality of the Lunr.js library to support multiple languages. It provides language-specific stemmers, stop word lists, and other tools to enhance search indexing and querying for non-English languages.

What are lunr-languages's main functionalities?

Language-specific Stemmers

This feature allows you to use language-specific stemmers to improve search accuracy. The code sample demonstrates how to set up a French stemmer and create an index with French content.

const lunr = require('lunr');
require('lunr-languages/lunr.stemmer.support')(lunr);
require('lunr-languages/lunr.fr')(lunr);

const idx = lunr(function () {
  this.use(lunr.fr);
  this.field('title');
  this.field('body');

  this.add({
    'title': 'Bonjour',
    'body': 'Le monde est beau'
  });
});

console.log(idx.search('beau'));

Stop Word Lists

This feature allows you to use custom stop word lists to exclude common words from the index. The code sample demonstrates how to set up a custom stop word list for French.

const lunr = require('lunr');
require('lunr-languages/lunr.stemmer.support')(lunr);
require('lunr-languages/lunr.fr')(lunr);
require('lunr-languages/lunr.stopword')(lunr);

lunr.fr.stopWordFilter = lunr.generateStopWordFilter(['et', 'le', 'la']);

const idx = lunr(function () {
  this.use(lunr.fr);
  this.field('title');
  this.field('body');

  this.add({
    'title': 'Bonjour',
    'body': 'Le monde est beau'
  });
});

console.log(idx.search('monde'));

Multi-language Support

This feature allows you to create a search index that supports multiple languages simultaneously. The code sample demonstrates how to set up an index that supports both French and German.

const lunr = require('lunr');
require('lunr-languages/lunr.stemmer.support')(lunr);
require('lunr-languages/lunr.multi')(lunr);
require('lunr-languages/lunr.fr')(lunr);
require('lunr-languages/lunr.de')(lunr);

const idx = lunr(function () {
  this.use(lunr.multi('fr', 'de'));
  this.field('title');
  this.field('body');

  this.add({
    'title': 'Bonjour',
    'body': 'Le monde est beau'
  });
  this.add({
    'title': 'Hallo',
    'body': 'Die Welt ist schön'
  });
});

console.log(idx.search('schön'));

Other packages similar to lunr-languages

FAQs

Package last updated on 09 Oct 2023

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc