Skip to content

Commit

Permalink
add minified version for Thai
Browse files Browse the repository at this point in the history
  • Loading branch information
MihaiValentin committed Jun 18, 2021
1 parent a841702 commit 982cb36
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 27 deletions.
2 changes: 2 additions & 0 deletions build/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ var list = [
file: 'TurkishStemmer.js',
stopwords: stopwordsCustomFolder + 'tr.csv',
wordCharacters: wordCharacters('Latin')
}, {
locale: 'th',
}, {
locale: 'vi',
}, {
Expand Down
8 changes: 5 additions & 3 deletions lunr.hi.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
lunr.hi.wordCharacters = "\u0900-\u0903\u0904-\u090f\u0910-\u091f\u0920-\u092f\u0930-\u093f\u0940-\u094f\u0950-\u095f\u0960-\u096f\u0970-\u097fa-zA-Za-zA-Z0-90-9";
// lunr.hi.wordCharacters = "ऀँंःऄअआइईउऊऋऌऍऎएऐऑऒओऔकखगघङचछजझञटठडढणतथदधनऩपफबभमयरऱलळऴवशषसहऺऻ़ऽािीुूृॄॅॆेैॉॊोौ्ॎॏॐ॒॑॓॔ॕॖॗक़ख़ग़ज़ड़ढ़फ़य़ॠॡॢॣ।॥०१२३४५६७८९॰ॱॲॳॴॵॶॷॸॹॺॻॼॽॾॿa-zA-Za-zA-Z0-90-9";
lunr.hi.trimmer = lunr.trimmerSupport.generateTrimmer(lunr.hi.wordCharacters);

lunr.Pipeline.registerFunction(lunr.hi.trimmer, 'trimmer-hi');
/* lunr stop word filter */
lunr.hi.stopWordFilter = lunr.generateStopWordFilter(
Expand All @@ -108,7 +108,9 @@
segmenter.init();
lunr.hi.tokenizer = function(obj) {
if (!arguments.length || obj == null || obj == undefined) return []
if (Array.isArray(obj)) return obj.map(function (t) { return isLunr2 ? new lunr.Token(t.toLowerCase()) : t.toLowerCase()});
if (Array.isArray(obj)) return obj.map(function(t) {
return isLunr2 ? new lunr.Token(t.toLowerCase()) : t.toLowerCase()
});

var str = obj.toString().toLowerCase().replace(/^\s+/, '');
return segmenter.cut(str).split('|');
Expand All @@ -118,4 +120,4 @@
lunr.Pipeline.registerFunction(lunr.hi.stopWordFilter, 'stopWordFilter-hi');

};
}))
}))
6 changes: 3 additions & 3 deletions lunr.ro.js
Original file line number Diff line number Diff line change
Expand Up @@ -490,9 +490,9 @@
if (!sbp.eq_s_b(1, "u"))
break;
}
case 2:
sbp.slice_del();
break;
case 2:
sbp.slice_del();
break;
}
}
sbp.limit_backward = v_1;
Expand Down
6 changes: 3 additions & 3 deletions lunr.ru.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,9 @@
if (!sbp.eq_s_b(1, "\u044F"))
return false;
}
case 2:
sbp.slice_del();
break;
case 2:
sbp.slice_del();
break;
}
return true;
}
Expand Down
36 changes: 19 additions & 17 deletions lunr.th.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,22 +60,22 @@

/* register specific locale function */
lunr.th = function() {
this.pipeline.reset();
this.pipeline.add(
/*lunr.th.stopWordFilter,*/
lunr.th.trimmer
);
this.pipeline.reset();
this.pipeline.add(
/*lunr.th.stopWordFilter,*/
lunr.th.trimmer
);

if (isLunr2) { // for lunr version 2.0.0
this.tokenizer = lunr.th.tokenizer;
} else {
if (lunr.tokenizer) { // for lunr version 0.6.0
lunr.tokenizer = lunr.th.tokenizer;
}
if (this.tokenizerFn) { // for lunr version 0.7.0 -> 1.0.0
this.tokenizerFn = lunr.th.tokenizer;
}
if (isLunr2) { // for lunr version 2.0.0
this.tokenizer = lunr.th.tokenizer;
} else {
if (lunr.tokenizer) { // for lunr version 0.6.0
lunr.tokenizer = lunr.th.tokenizer;
}
if (this.tokenizerFn) { // for lunr version 0.7.0 -> 1.0.0
this.tokenizerFn = lunr.th.tokenizer;
}
}
};

/* lunr trimmer function */
Expand All @@ -85,13 +85,15 @@

var segmenter = lunr.wordcut;
segmenter.init();
lunr.th.tokenizer = function (obj) {
lunr.th.tokenizer = function(obj) {
//console.log(obj);
if (!arguments.length || obj == null || obj == undefined) return []
if (Array.isArray(obj)) return obj.map(function (t) { return isLunr2 ? new lunr.Token(t) : t })
if (Array.isArray(obj)) return obj.map(function(t) {
return isLunr2 ? new lunr.Token(t) : t
})

var str = obj.toString().replace(/^\s+/, '');
return segmenter.cut(str).split('|');
}
};
}))
}))
2 changes: 1 addition & 1 deletion min/lunr.hi.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions min/lunr.th.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 982cb36

Please sign in to comment.