-
-
Notifications
You must be signed in to change notification settings - Fork 496
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cyrillic languages support #51
Comments
Hello. Try this settings: https://github.com/nextapps-de/flexsearch#cjk-word-break-chinese-japanese-korean var index = FlexSearch.create({
encode: false,
tokenize: function(str){
return str.replace(/[\x00-\x7F]/g, "").split("");
}
}); index.add(1, "Фообар"); var results = index.search("Фообар"); When you just want to index whole words (not partials) then this may be better: var index = FlexSearch.create({
encode: false,
tokenize: function(str){
return str.split(/\s+/);
}
}); |
Hello @ts-thomas Yep, it works with the following options. const index = new FlexSearch({
tokenize: function(str){
return str.replace(/[\x00-\x7F]/g, "").split("");
}
}); But why it doesn't work with the |
This one works too: const index = new FlexSearch({
tokenize: function(str){
return str.split("");
}
}); |
The forward tokenizer splits words via regex, but this regex will also remove cyrillic chars actually. The tokenizer needs to be enhanced to use „forward“ with non-latin content. |
It would be really helpful 😉 |
@mahnunchik The latest version v0.6.1 has the new option split when creating an index. This makes it possible to use built-in tokenizer like "strict" or "forward" (which is required by the contextual index) and also handle word splitting separately. var index = FlexSearch.create({
encode: false,
split: /\s+/,
tokenize: "reverse"
}); index.add(0, "Фообар"); var results = index.search("Фообар"); var results = index.search("бар"); var results = index.search("Фоо"); |
@ts-thomas thank you! It helps me in my task. Maybe there is sense to use more common It will be hard to find root of the problem for string like |
The next main release will get an improvement of handling all language-specific features. This improvement will also cover splitting words. |
The mentioned solutions here helped me to make FlexSearch indexing Arabic text. Thanks guys. |
Also take into account to use the "rtl" option for right-to-left support: var index = FlexSearch.create({
encode: false,
rtl: true,
split: /\s+/,
tokenize: "forward"
}); |
Hi @ts-thomas, last year you said:
As FlexSearch is currently in 0.7.0 release candidate, I was wondering if there is some new feature about languages processing. I recently created a project called SearchinGhost, it is an in-browser search plugins for Ghost CMS powered by FlexSearch. I am really happy with FlexSearch (thank your for the work done!) but I would like to bring multi-lang capabilities. For now, with what I read in the issues, I came up with these language default options: Latin: FlexSearch.create({
encode: "simple",
tokenize: "forward"
}); Arabic FlexSearch.create({
encode: false,
rtl: true,
split: /\s+/,
tokenize: "forward"
}); Cyrilic, indian (any word separated by space language) FlexSearch.create({
encode: false,
split: /\s+/,
tokenize: "forward"
}); Chinese, Japanese or Korean (with dedicated chars w/o spaces) FlexSearch.create({
encode: false,
tokenize: function(str){
return str.replace(/[\x00-\x7F]/g, "").split("");
}
}); Do you think there is any possible improvement/optimisation? EDIT: I finally found this relevent documentation about the v0.7.0 - https://github.com/nextapps-de/flexsearch/blob/0.7.0/doc/0.7.0.md. Hope this version will be out one day :) |
For some reason, the solution to this in typescript seems to be different. I'm just posting how I've gotten it to work in hopes it will help others. Note: I'm using I was not able to follow the I found that specifying the It seems that the only function that actually matters is the encode function. I looked at the source and I played a bit and it seemed that when you specify an encoder, the tokenize, stemmer, and charset it doesn't affect anything. Here's my working code:
I'm using the natural library to handle the stemming. I'm new to this library so please correct any horrible mistakes I've made! |
Hello,
I've faced with the following behaviour.
This example works as expected:
But this one shows no results.
I've tested in node and in browser.
The text was updated successfully, but these errors were encountered: