middleman-search 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -0
- data/lib/middleman-search/extension.rb +2 -0
- data/lib/middleman-search/search-index-resource.rb +25 -1
- data/lib/middleman-search/version.rb +1 -1
- data/vendor/assets/javascripts/lunr.da.js +273 -0
- data/vendor/assets/javascripts/lunr.de.js +373 -0
- data/vendor/assets/javascripts/lunr.du.js +437 -0
- data/vendor/assets/javascripts/lunr.es.js +588 -0
- data/vendor/assets/javascripts/lunr.fi.js +529 -0
- data/vendor/assets/javascripts/lunr.fr.js +691 -0
- data/vendor/assets/javascripts/lunr.hu.js +554 -0
- data/vendor/assets/javascripts/lunr.it.js +605 -0
- data/vendor/assets/javascripts/lunr.jp.js +118 -0
- data/vendor/assets/javascripts/lunr.no.js +246 -0
- data/vendor/assets/javascripts/lunr.pt.js +559 -0
- data/vendor/assets/javascripts/lunr.ro.js +547 -0
- data/vendor/assets/javascripts/lunr.ru.js +380 -0
- data/vendor/assets/javascripts/lunr.stemmer.support.js +282 -0
- data/vendor/assets/javascripts/lunr.sv.js +245 -0
- data/vendor/assets/javascripts/lunr.tr.js +1063 -0
- metadata +19 -3
@@ -0,0 +1,118 @@
|
|
1
|
+
/*!
|
2
|
+
* Lunr languages, `Japanese` language
|
3
|
+
* https://github.com/MihaiValentin/lunr-languages
|
4
|
+
*
|
5
|
+
* Copyright 2014, Chad Liu
|
6
|
+
* http://www.mozilla.org/MPL/
|
7
|
+
*/
|
8
|
+
/*!
|
9
|
+
* based on
|
10
|
+
* Snowball JavaScript Library v0.3
|
11
|
+
* http://code.google.com/p/urim/
|
12
|
+
* http://snowball.tartarus.org/
|
13
|
+
*
|
14
|
+
* Copyright 2010, Oleg Mazko
|
15
|
+
* http://www.mozilla.org/MPL/
|
16
|
+
*/
|
17
|
+
|
18
|
+
/**
|
19
|
+
* export the module via AMD, CommonJS or as a browser global
|
20
|
+
* Export code from https://github.com/umdjs/umd/blob/master/returnExports.js
|
21
|
+
*/
|
22
|
+
;
|
23
|
+
(function(root, factory) {
|
24
|
+
if (typeof define === 'function' && define.amd) {
|
25
|
+
// AMD. Register as an anonymous module.
|
26
|
+
define(factory)
|
27
|
+
} else if (typeof exports === 'object') {
|
28
|
+
/**
|
29
|
+
* Node. Does not work with strict CommonJS, but
|
30
|
+
* only CommonJS-like environments that support module.exports,
|
31
|
+
* like Node.
|
32
|
+
*/
|
33
|
+
module.exports = factory()
|
34
|
+
} else {
|
35
|
+
// Browser globals (root is window)
|
36
|
+
factory()(root.lunr);
|
37
|
+
}
|
38
|
+
}(this, function() {
|
39
|
+
/**
|
40
|
+
* Just return a value to define the module export.
|
41
|
+
* This example returns an object, but the module
|
42
|
+
* can return a function as the exported value.
|
43
|
+
*/
|
44
|
+
return function(lunr) {
|
45
|
+
/* throw error if lunr is not yet included */
|
46
|
+
if ('undefined' === typeof lunr) {
|
47
|
+
throw new Error('Lunr is not present. Please include / require Lunr before this script.');
|
48
|
+
}
|
49
|
+
|
50
|
+
/* throw error if lunr stemmer support is not yet included */
|
51
|
+
if ('undefined' === typeof lunr.stemmerSupport) {
|
52
|
+
throw new Error('Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.');
|
53
|
+
}
|
54
|
+
|
55
|
+
/* register specific locale function */
|
56
|
+
lunr.jp = function() {
|
57
|
+
this.pipeline.reset();
|
58
|
+
this.pipeline.add(
|
59
|
+
lunr.jp.stopWordFilter,
|
60
|
+
lunr.jp.stemmer
|
61
|
+
);
|
62
|
+
// change the tokenizer for japanese one
|
63
|
+
lunr.tokenizer = lunr.jp.tokenizer;
|
64
|
+
};
|
65
|
+
var segmenter = new TinySegmenter(); // インスタンス生成
|
66
|
+
|
67
|
+
lunr.jp.tokenizer = function (obj) {
|
68
|
+
if (!arguments.length || obj == null || obj == undefined) return []
|
69
|
+
if (Array.isArray(obj)) return obj.map(function (t) { return t.toLowerCase() })
|
70
|
+
|
71
|
+
var str = obj.toString().replace(/^\s+/, '')
|
72
|
+
|
73
|
+
for (var i = str.length - 1; i >= 0; i--) {
|
74
|
+
if (/\S/.test(str.charAt(i))) {
|
75
|
+
str = str.substring(0, i + 1)
|
76
|
+
break
|
77
|
+
}
|
78
|
+
}
|
79
|
+
|
80
|
+
|
81
|
+
var segs = segmenter.segment(str); // 単語の配列が返る
|
82
|
+
return segs.filter(function (token) {
|
83
|
+
return !!token
|
84
|
+
})
|
85
|
+
.map(function (token) {
|
86
|
+
return token
|
87
|
+
})
|
88
|
+
}
|
89
|
+
|
90
|
+
/* lunr stemmer function */
|
91
|
+
lunr.jp.stemmer = (function() {
|
92
|
+
|
93
|
+
/* TODO japanese stemmer */
|
94
|
+
return function(word) {
|
95
|
+
return word;
|
96
|
+
}
|
97
|
+
})();
|
98
|
+
|
99
|
+
lunr.Pipeline.registerFunction(lunr.jp.stemmer, 'stemmer-jp');
|
100
|
+
|
101
|
+
/* stop word filter function */
|
102
|
+
lunr.jp.stopWordFilter = function(token) {
|
103
|
+
if (lunr.jp.stopWordFilter.stopWords.indexOf(token) === -1) {
|
104
|
+
return token;
|
105
|
+
}
|
106
|
+
};
|
107
|
+
|
108
|
+
lunr.jp.stopWordFilter.stopWords = new lunr.SortedSet();
|
109
|
+
lunr.jp.stopWordFilter.stopWords.length = 45;
|
110
|
+
|
111
|
+
// The space at the beginning is crucial: It marks the empty string
|
112
|
+
// as a stop word. lunr.js crashes during search when documents
|
113
|
+
// processed by the pipeline still contain the empty string.
|
114
|
+
// stopword for japanese is from http://www.ranks.nl/stopwords/japanese
|
115
|
+
lunr.jp.stopWordFilter.stopWords.elements = ' これ それ あれ この その あの ここ そこ あそこ こちら どこ だれ なに なん 何 私 貴方 貴方方 我々 私達 あの人 あのかた 彼女 彼 です あります おります います は が の に を で え から まで より も どの と し それで しかし'.split(' ');
|
116
|
+
lunr.Pipeline.registerFunction(lunr.jp.stopWordFilter, 'stopWordFilter-jp');
|
117
|
+
};
|
118
|
+
}))
|
@@ -0,0 +1,246 @@
|
|
1
|
+
/*!
|
2
|
+
* Lunr languages, `Norwegian` language
|
3
|
+
* https://github.com/MihaiValentin/lunr-languages
|
4
|
+
*
|
5
|
+
* Copyright 2014, Mihai Valentin
|
6
|
+
* http://www.mozilla.org/MPL/
|
7
|
+
*/
|
8
|
+
/*!
|
9
|
+
* based on
|
10
|
+
* Snowball JavaScript Library v0.3
|
11
|
+
* http://code.google.com/p/urim/
|
12
|
+
* http://snowball.tartarus.org/
|
13
|
+
*
|
14
|
+
* Copyright 2010, Oleg Mazko
|
15
|
+
* http://www.mozilla.org/MPL/
|
16
|
+
*/
|
17
|
+
|
18
|
+
/**
|
19
|
+
* export the module via AMD, CommonJS or as a browser global
|
20
|
+
* Export code from https://github.com/umdjs/umd/blob/master/returnExports.js
|
21
|
+
*/
|
22
|
+
;
|
23
|
+
(function(root, factory) {
|
24
|
+
if (typeof define === 'function' && define.amd) {
|
25
|
+
// AMD. Register as an anonymous module.
|
26
|
+
define(factory)
|
27
|
+
} else if (typeof exports === 'object') {
|
28
|
+
/**
|
29
|
+
* Node. Does not work with strict CommonJS, but
|
30
|
+
* only CommonJS-like environments that support module.exports,
|
31
|
+
* like Node.
|
32
|
+
*/
|
33
|
+
module.exports = factory()
|
34
|
+
} else {
|
35
|
+
// Browser globals (root is window)
|
36
|
+
factory()(root.lunr);
|
37
|
+
}
|
38
|
+
}(this, function() {
|
39
|
+
/**
|
40
|
+
* Just return a value to define the module export.
|
41
|
+
* This example returns an object, but the module
|
42
|
+
* can return a function as the exported value.
|
43
|
+
*/
|
44
|
+
return function(lunr) {
|
45
|
+
/* throw error if lunr is not yet included */
|
46
|
+
if ('undefined' === typeof lunr) {
|
47
|
+
throw new Error('Lunr is not present. Please include / require Lunr before this script.');
|
48
|
+
}
|
49
|
+
|
50
|
+
/* throw error if lunr stemmer support is not yet included */
|
51
|
+
if ('undefined' === typeof lunr.stemmerSupport) {
|
52
|
+
throw new Error('Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.');
|
53
|
+
}
|
54
|
+
|
55
|
+
/* register specific locale function */
|
56
|
+
lunr.no = function() {
|
57
|
+
this.pipeline.reset();
|
58
|
+
this.pipeline.add(
|
59
|
+
lunr.no.stopWordFilter,
|
60
|
+
lunr.no.stemmer
|
61
|
+
);
|
62
|
+
};
|
63
|
+
|
64
|
+
/* lunr stemmer function */
|
65
|
+
lunr.no.stemmer = (function() {
|
66
|
+
/* create the wrapped stemmer object */
|
67
|
+
var Among = lunr.stemmerSupport.Among,
|
68
|
+
SnowballProgram = lunr.stemmerSupport.SnowballProgram,
|
69
|
+
st = new function NorwegianStemmer() {
|
70
|
+
var a_0 = [new Among("a", -1, 1), new Among("e", -1, 1),
|
71
|
+
new Among("ede", 1, 1), new Among("ande", 1, 1),
|
72
|
+
new Among("ende", 1, 1), new Among("ane", 1, 1),
|
73
|
+
new Among("ene", 1, 1), new Among("hetene", 6, 1),
|
74
|
+
new Among("erte", 1, 3), new Among("en", -1, 1),
|
75
|
+
new Among("heten", 9, 1), new Among("ar", -1, 1),
|
76
|
+
new Among("er", -1, 1), new Among("heter", 12, 1),
|
77
|
+
new Among("s", -1, 2), new Among("as", 14, 1),
|
78
|
+
new Among("es", 14, 1), new Among("edes", 16, 1),
|
79
|
+
new Among("endes", 16, 1), new Among("enes", 16, 1),
|
80
|
+
new Among("hetenes", 19, 1), new Among("ens", 14, 1),
|
81
|
+
new Among("hetens", 21, 1), new Among("ers", 14, 1),
|
82
|
+
new Among("ets", 14, 1), new Among("et", -1, 1),
|
83
|
+
new Among("het", 25, 1), new Among("ert", -1, 3),
|
84
|
+
new Among("ast", -1, 1)
|
85
|
+
],
|
86
|
+
a_1 = [new Among("dt", -1, -1),
|
87
|
+
new Among("vt", -1, -1)
|
88
|
+
],
|
89
|
+
a_2 = [new Among("leg", -1, 1),
|
90
|
+
new Among("eleg", 0, 1), new Among("ig", -1, 1),
|
91
|
+
new Among("eig", 2, 1), new Among("lig", 2, 1),
|
92
|
+
new Among("elig", 4, 1), new Among("els", -1, 1),
|
93
|
+
new Among("lov", -1, 1), new Among("elov", 7, 1),
|
94
|
+
new Among("slov", 7, 1), new Among("hetslov", 9, 1)
|
95
|
+
],
|
96
|
+
g_v = [17,
|
97
|
+
65, 16, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 48, 0, 128
|
98
|
+
],
|
99
|
+
g_s_ending = [
|
100
|
+
119, 125, 149, 1
|
101
|
+
],
|
102
|
+
I_x, I_p1, sbp = new SnowballProgram();
|
103
|
+
this.setCurrent = function(word) {
|
104
|
+
sbp.setCurrent(word);
|
105
|
+
};
|
106
|
+
this.getCurrent = function() {
|
107
|
+
return sbp.getCurrent();
|
108
|
+
};
|
109
|
+
|
110
|
+
function r_mark_regions() {
|
111
|
+
var v_1, c = sbp.cursor + 3;
|
112
|
+
I_p1 = sbp.limit;
|
113
|
+
if (0 <= c || c <= sbp.limit) {
|
114
|
+
I_x = c;
|
115
|
+
while (true) {
|
116
|
+
v_1 = sbp.cursor;
|
117
|
+
if (sbp.in_grouping(g_v, 97, 248)) {
|
118
|
+
sbp.cursor = v_1;
|
119
|
+
break;
|
120
|
+
}
|
121
|
+
if (v_1 >= sbp.limit)
|
122
|
+
return;
|
123
|
+
sbp.cursor = v_1 + 1;
|
124
|
+
}
|
125
|
+
while (!sbp.out_grouping(g_v, 97, 248)) {
|
126
|
+
if (sbp.cursor >= sbp.limit)
|
127
|
+
return;
|
128
|
+
sbp.cursor++;
|
129
|
+
}
|
130
|
+
I_p1 = sbp.cursor;
|
131
|
+
if (I_p1 < I_x)
|
132
|
+
I_p1 = I_x;
|
133
|
+
}
|
134
|
+
}
|
135
|
+
|
136
|
+
function r_main_suffix() {
|
137
|
+
var among_var, v_1, v_2;
|
138
|
+
if (sbp.cursor >= I_p1) {
|
139
|
+
v_1 = sbp.limit_backward;
|
140
|
+
sbp.limit_backward = I_p1;
|
141
|
+
sbp.ket = sbp.cursor;
|
142
|
+
among_var = sbp.find_among_b(a_0, 29);
|
143
|
+
sbp.limit_backward = v_1;
|
144
|
+
if (among_var) {
|
145
|
+
sbp.bra = sbp.cursor;
|
146
|
+
switch (among_var) {
|
147
|
+
case 1:
|
148
|
+
sbp.slice_del();
|
149
|
+
break;
|
150
|
+
case 2:
|
151
|
+
v_2 = sbp.limit - sbp.cursor;
|
152
|
+
if (sbp.in_grouping_b(g_s_ending, 98, 122))
|
153
|
+
sbp.slice_del();
|
154
|
+
else {
|
155
|
+
sbp.cursor = sbp.limit - v_2;
|
156
|
+
if (sbp.eq_s_b(1, "k") && sbp.out_grouping_b(g_v, 97, 248))
|
157
|
+
sbp.slice_del();
|
158
|
+
}
|
159
|
+
break;
|
160
|
+
case 3:
|
161
|
+
sbp.slice_from("er");
|
162
|
+
break;
|
163
|
+
}
|
164
|
+
}
|
165
|
+
}
|
166
|
+
}
|
167
|
+
|
168
|
+
function r_consonant_pair() {
|
169
|
+
var v_1 = sbp.limit - sbp.cursor,
|
170
|
+
v_2;
|
171
|
+
if (sbp.cursor >= I_p1) {
|
172
|
+
v_2 = sbp.limit_backward;
|
173
|
+
sbp.limit_backward = I_p1;
|
174
|
+
sbp.ket = sbp.cursor;
|
175
|
+
if (sbp.find_among_b(a_1, 2)) {
|
176
|
+
sbp.bra = sbp.cursor;
|
177
|
+
sbp.limit_backward = v_2;
|
178
|
+
sbp.cursor = sbp.limit - v_1;
|
179
|
+
if (sbp.cursor > sbp.limit_backward) {
|
180
|
+
sbp.cursor--;
|
181
|
+
sbp.bra = sbp.cursor;
|
182
|
+
sbp.slice_del();
|
183
|
+
}
|
184
|
+
} else
|
185
|
+
sbp.limit_backward = v_2;
|
186
|
+
}
|
187
|
+
}
|
188
|
+
|
189
|
+
function r_other_suffix() {
|
190
|
+
var among_var, v_1;
|
191
|
+
if (sbp.cursor >= I_p1) {
|
192
|
+
v_1 = sbp.limit_backward;
|
193
|
+
sbp.limit_backward = I_p1;
|
194
|
+
sbp.ket = sbp.cursor;
|
195
|
+
among_var = sbp.find_among_b(a_2, 11);
|
196
|
+
if (among_var) {
|
197
|
+
sbp.bra = sbp.cursor;
|
198
|
+
sbp.limit_backward = v_1;
|
199
|
+
if (among_var == 1)
|
200
|
+
sbp.slice_del();
|
201
|
+
} else
|
202
|
+
sbp.limit_backward = v_1;
|
203
|
+
}
|
204
|
+
}
|
205
|
+
this.stem = function() {
|
206
|
+
var v_1 = sbp.cursor;
|
207
|
+
r_mark_regions();
|
208
|
+
sbp.limit_backward = v_1;
|
209
|
+
sbp.cursor = sbp.limit;
|
210
|
+
r_main_suffix();
|
211
|
+
sbp.cursor = sbp.limit;
|
212
|
+
r_consonant_pair();
|
213
|
+
sbp.cursor = sbp.limit;
|
214
|
+
r_other_suffix();
|
215
|
+
return true;
|
216
|
+
}
|
217
|
+
};
|
218
|
+
|
219
|
+
/* and return a function that stems a word for the current locale */
|
220
|
+
return function(word) {
|
221
|
+
st.setCurrent(word);
|
222
|
+
st.stem();
|
223
|
+
return st.getCurrent();
|
224
|
+
}
|
225
|
+
})();
|
226
|
+
|
227
|
+
lunr.Pipeline.registerFunction(lunr.no.stemmer, 'stemmer-no');
|
228
|
+
|
229
|
+
/* stop word filter function */
|
230
|
+
lunr.no.stopWordFilter = function(token) {
|
231
|
+
if (lunr.no.stopWordFilter.stopWords.indexOf(token) === -1) {
|
232
|
+
return token;
|
233
|
+
}
|
234
|
+
};
|
235
|
+
|
236
|
+
lunr.no.stopWordFilter.stopWords = new lunr.SortedSet();
|
237
|
+
lunr.no.stopWordFilter.stopWords.length = 177;
|
238
|
+
|
239
|
+
// The space at the beginning is crucial: It marks the empty string
|
240
|
+
// as a stop word. lunr.js crashes during search when documents
|
241
|
+
// processed by the pipeline still contain the empty string.
|
242
|
+
lunr.no.stopWordFilter.stopWords.elements = ' alle at av bare begge ble blei bli blir blitt både båe da de deg dei deim deira deires dem den denne der dere deres det dette di din disse ditt du dykk dykkar då eg ein eit eitt eller elles en enn er et ett etter for fordi fra før ha hadde han hans har hennar henne hennes her hjå ho hoe honom hoss hossen hun hva hvem hver hvilke hvilken hvis hvor hvordan hvorfor i ikke ikkje ikkje ingen ingi inkje inn inni ja jeg kan kom korleis korso kun kunne kva kvar kvarhelst kven kvi kvifor man mange me med medan meg meget mellom men mi min mine mitt mot mykje ned no noe noen noka noko nokon nokor nokre nå når og også om opp oss over på samme seg selv si si sia sidan siden sin sine sitt sjøl skal skulle slik so som som somme somt så sånn til um upp ut uten var vart varte ved vere verte vi vil ville vore vors vort vår være være vært å'.split(' ');
|
243
|
+
|
244
|
+
lunr.Pipeline.registerFunction(lunr.no.stopWordFilter, 'stopWordFilter-no');
|
245
|
+
};
|
246
|
+
}))
|