Comments (4)
The problem is where the list of stop words are declared
For reasons that I can't remember now the stopWordFilter uses a lunr.SortedSet as the datastructure for keeping track of the stop words. A key part of the SortedSet is that the set of values are sorted, the SortedSet usually maintains this characteristic, but they way the list of words are being loaded bypasses this check, setting SortedSet#elements
directly.
Because the list is not sorted the SortedSet#indexOf
check fails to correctly find the word "en" (and probably others also).
The quick fix for this is to always sort the list of stopWords, or ensure they are already sorted in the source file, see the english stop word filter for example.
The SortedSet could be entirely replaced by a JavaScript object with the stopWords as properties, being careful to not confuse other, inherited properties of a JavaScript object as stopWords (e.g. "valueOf")
A better, long term, fix would be for lunr to provide an easier way of creating custom stopWordLists, something with an API like this:
dutchStopWords = lunr.stopWordFilter('de en van ik te dat die in een hij het niet')
from lunr-languages.
I understand. I have changed the stopwords part in the dutch source file:
// Looking at the original English stoplist the length should be equal to the length of the array minus 1.
// I guess the empty element at the beginning of the array is not counted.
lunr.du.stopWordFilter.stopWords.length = 101;
lunr.du.stopWordFilter.stopWords.elements = [
'',
'aan',
'al',
'alles',
'als',
'altijd',
'andere',
'ben',
'bij',
'daar',
'dan',
'dat',
'de',
'der',
'deze',
'die',
'dit',
'doch',
'doen',
'door',
'dus',
'een',
'eens',
'en',
'er',
'ge',
'geen',
'geweest',
'haar',
'had',
'heb',
'hebben',
'heeft',
'hem',
'het',
'hier',
'hij',
'hoe',
'hun',
'iemand',
'iets',
'ik',
'in',
'is',
'ja',
'je',
'kan',
'kon',
'kunnen',
'maar',
'me',
'meer',
'men',
'met',
'mij',
'mijn',
'moet',
'na',
'naar',
'niet',
'niets',
'nog',
'nu',
'of',
'om',
'omdat',
'onder',
'ons',
'ook',
'op',
'over',
'reeds',
'te',
'tegen',
'toch',
'toen',
'tot',
'u',
'uit',
'uw',
'van',
'veel',
'voor',
'want',
'waren',
'was',
'wat',
'werd',
'wezen',
'wie',
'wil',
'worden',
'wordt',
'zal',
'ze',
'zelf',
'zich',
'zij',
'zijn',
'zo',
'zonder',
'zou'
];
This seems to work correctly. Maybe you can update your source files.
Thank you.
from lunr-languages.
Hi @marcselman ,
Thanks for pointing out the issue. I continued the discussion regarding this on the #8 and will fix as soon as possible.
Thanks!
from lunr-languages.
Fixed! Check #8 for more details.
from lunr-languages.
Related Issues (20)
- Error when initializing `lunr.th.js` HOT 1
- Is this repository dead? HOT 1
- Add language support for Catalan
- How should I use it in ES6?
- lunr.zh.js can`t search 'database' HOT 4
- React JS
- Accented letter ê should be replaced by e in the french stemmer HOT 1
- Usage of Lunr js with Turkish language
- Minified version of the Thai language is missing HOT 2
- lunr-languages/lunr.fr.js fails to find common words like "équipement" HOT 3
- Can "nodejieba" be as "devDependency" or "peerDependency" in lunr-languages? HOT 4
- Update nodejs version in CI
- nodejieba (Chinese) is not working with webpack HOT 1
- lunr.de fails with umlaute in wildcard search
- Arabic HOT 1
- Search indexing for Chinese language (lunr.zh) does not work with multi-language HOT 4
- Idea: Use Intl.Segmenter to reduce bundle size in browsers
- Error when using lunr.zh.js 'nodejieba.cut is not a function' HOT 2
- Cannot read properties of undefined (reading 'registerFunction') HOT 1
- Add language support for Sanskrit, Kannada & Telugu HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lunr-languages.