language_data.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. /*
  2. * language_data.js
  3. * ~~~~~~~~~~~~~~~~
  4. *
  5. * This script contains the language-specific data used by searchtools.js,
  6. * namely the list of stopwords, stemmer, scorer and splitter.
  7. *
  8. * :copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.
  9. * :license: BSD, see LICENSE for details.
  10. *
  11. */
  12. var stopwords = ["a","and","are","as","at","be","but","by","for","if","in","into","is","it","near","no","not","of","on","or","such","that","the","their","then","there","these","they","this","to","was","will","with"];
  13. /* Non-minified version JS is _stemmer.js if file is provided */
  14. /**
  15. * Porter Stemmer
  16. */
  17. var Stemmer = function() {
  18. var step2list = {
  19. ational: 'ate',
  20. tional: 'tion',
  21. enci: 'ence',
  22. anci: 'ance',
  23. izer: 'ize',
  24. bli: 'ble',
  25. alli: 'al',
  26. entli: 'ent',
  27. eli: 'e',
  28. ousli: 'ous',
  29. ization: 'ize',
  30. ation: 'ate',
  31. ator: 'ate',
  32. alism: 'al',
  33. iveness: 'ive',
  34. fulness: 'ful',
  35. ousness: 'ous',
  36. aliti: 'al',
  37. iviti: 'ive',
  38. biliti: 'ble',
  39. logi: 'log'
  40. };
  41. var step3list = {
  42. icate: 'ic',
  43. ative: '',
  44. alize: 'al',
  45. iciti: 'ic',
  46. ical: 'ic',
  47. ful: '',
  48. ness: ''
  49. };
  50. var c = "[^aeiou]"; // consonant
  51. var v = "[aeiouy]"; // vowel
  52. var C = c + "[^aeiouy]*"; // consonant sequence
  53. var V = v + "[aeiou]*"; // vowel sequence
  54. var mgr0 = "^(" + C + ")?" + V + C; // [C]VC... is m>0
  55. var meq1 = "^(" + C + ")?" + V + C + "(" + V + ")?$"; // [C]VC[V] is m=1
  56. var mgr1 = "^(" + C + ")?" + V + C + V + C; // [C]VCVC... is m>1
  57. var s_v = "^(" + C + ")?" + v; // vowel in stem
  58. this.stemWord = function (w) {
  59. var stem;
  60. var suffix;
  61. var firstch;
  62. var origword = w;
  63. if (w.length < 3)
  64. return w;
  65. var re;
  66. var re2;
  67. var re3;
  68. var re4;
  69. firstch = w.substr(0,1);
  70. if (firstch == "y")
  71. w = firstch.toUpperCase() + w.substr(1);
  72. // Step 1a
  73. re = /^(.+?)(ss|i)es$/;
  74. re2 = /^(.+?)([^s])s$/;
  75. if (re.test(w))
  76. w = w.replace(re,"$1$2");
  77. else if (re2.test(w))
  78. w = w.replace(re2,"$1$2");
  79. // Step 1b
  80. re = /^(.+?)eed$/;
  81. re2 = /^(.+?)(ed|ing)$/;
  82. if (re.test(w)) {
  83. var fp = re.exec(w);
  84. re = new RegExp(mgr0);
  85. if (re.test(fp[1])) {
  86. re = /.$/;
  87. w = w.replace(re,"");
  88. }
  89. }
  90. else if (re2.test(w)) {
  91. var fp = re2.exec(w);
  92. stem = fp[1];
  93. re2 = new RegExp(s_v);
  94. if (re2.test(stem)) {
  95. w = stem;
  96. re2 = /(at|bl|iz)$/;
  97. re3 = new RegExp("([^aeiouylsz])\\1$");
  98. re4 = new RegExp("^" + C + v + "[^aeiouwxy]$");
  99. if (re2.test(w))
  100. w = w + "e";
  101. else if (re3.test(w)) {
  102. re = /.$/;
  103. w = w.replace(re,"");
  104. }
  105. else if (re4.test(w))
  106. w = w + "e";
  107. }
  108. }
  109. // Step 1c
  110. re = /^(.+?)y$/;
  111. if (re.test(w)) {
  112. var fp = re.exec(w);
  113. stem = fp[1];
  114. re = new RegExp(s_v);
  115. if (re.test(stem))
  116. w = stem + "i";
  117. }
  118. // Step 2
  119. re = /^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/;
  120. if (re.test(w)) {
  121. var fp = re.exec(w);
  122. stem = fp[1];
  123. suffix = fp[2];
  124. re = new RegExp(mgr0);
  125. if (re.test(stem))
  126. w = stem + step2list[suffix];
  127. }
  128. // Step 3
  129. re = /^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/;
  130. if (re.test(w)) {
  131. var fp = re.exec(w);
  132. stem = fp[1];
  133. suffix = fp[2];
  134. re = new RegExp(mgr0);
  135. if (re.test(stem))
  136. w = stem + step3list[suffix];
  137. }
  138. // Step 4
  139. re = /^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/;
  140. re2 = /^(.+?)(s|t)(ion)$/;
  141. if (re.test(w)) {
  142. var fp = re.exec(w);
  143. stem = fp[1];
  144. re = new RegExp(mgr1);
  145. if (re.test(stem))
  146. w = stem;
  147. }
  148. else if (re2.test(w)) {
  149. var fp = re2.exec(w);
  150. stem = fp[1] + fp[2];
  151. re2 = new RegExp(mgr1);
  152. if (re2.test(stem))
  153. w = stem;
  154. }
  155. // Step 5
  156. re = /^(.+?)e$/;
  157. if (re.test(w)) {
  158. var fp = re.exec(w);
  159. stem = fp[1];
  160. re = new RegExp(mgr1);
  161. re2 = new RegExp(meq1);
  162. re3 = new RegExp("^" + C + v + "[^aeiouwxy]$");
  163. if (re.test(stem) || (re2.test(stem) && !(re3.test(stem))))
  164. w = stem;
  165. }
  166. re = /ll$/;
  167. re2 = new RegExp(mgr1);
  168. if (re.test(w) && re2.test(w)) {
  169. re = /.$/;
  170. w = w.replace(re,"");
  171. }
  172. // and turn initial Y back to y
  173. if (firstch == "y")
  174. w = firstch.toLowerCase() + w.substr(1);
  175. return w;
  176. }
  177. }
  178. var splitChars = (function() {
  179. var result = {};
  180. var singles = [96, 180, 187, 191, 215, 247, 749, 885, 903, 907, 909, 930, 1014, 1648,
  181. 1748, 1809, 2416, 2473, 2481, 2526, 2601, 2609, 2612, 2615, 2653, 2702,
  182. 2706, 2729, 2737, 2740, 2857, 2865, 2868, 2910, 2928, 2948, 2961, 2971,
  183. 2973, 3085, 3089, 3113, 3124, 3213, 3217, 3241, 3252, 3295, 3341, 3345,
  184. 3369, 3506, 3516, 3633, 3715, 3721, 3736, 3744, 3748, 3750, 3756, 3761,
  185. 3781, 3912, 4239, 4347, 4681, 4695, 4697, 4745, 4785, 4799, 4801, 4823,
  186. 4881, 5760, 5901, 5997, 6313, 7405, 8024, 8026, 8028, 8030, 8117, 8125,
  187. 8133, 8181, 8468, 8485, 8487, 8489, 8494, 8527, 11311, 11359, 11687, 11695,
  188. 11703, 11711, 11719, 11727, 11735, 12448, 12539, 43010, 43014, 43019, 43587,
  189. 43696, 43713, 64286, 64297, 64311, 64317, 64319, 64322, 64325, 65141];
  190. var i, j, start, end;
  191. for (i = 0; i < singles.length; i++) {
  192. result[singles[i]] = true;
  193. }
  194. var ranges = [[0, 47], [58, 64], [91, 94], [123, 169], [171, 177], [182, 184], [706, 709],
  195. [722, 735], [741, 747], [751, 879], [888, 889], [894, 901], [1154, 1161],
  196. [1318, 1328], [1367, 1368], [1370, 1376], [1416, 1487], [1515, 1519], [1523, 1568],
  197. [1611, 1631], [1642, 1645], [1750, 1764], [1767, 1773], [1789, 1790], [1792, 1807],
  198. [1840, 1868], [1958, 1968], [1970, 1983], [2027, 2035], [2038, 2041], [2043, 2047],
  199. [2070, 2073], [2075, 2083], [2085, 2087], [2089, 2307], [2362, 2364], [2366, 2383],
  200. [2385, 2391], [2402, 2405], [2419, 2424], [2432, 2436], [2445, 2446], [2449, 2450],
  201. [2483, 2485], [2490, 2492], [2494, 2509], [2511, 2523], [2530, 2533], [2546, 2547],
  202. [2554, 2564], [2571, 2574], [2577, 2578], [2618, 2648], [2655, 2661], [2672, 2673],
  203. [2677, 2692], [2746, 2748], [2750, 2767], [2769, 2783], [2786, 2789], [2800, 2820],
  204. [2829, 2830], [2833, 2834], [2874, 2876], [2878, 2907], [2914, 2917], [2930, 2946],
  205. [2955, 2957], [2966, 2968], [2976, 2978], [2981, 2983], [2987, 2989], [3002, 3023],
  206. [3025, 3045], [3059, 3076], [3130, 3132], [3134, 3159], [3162, 3167], [3170, 3173],
  207. [3184, 3191], [3199, 3204], [3258, 3260], [3262, 3293], [3298, 3301], [3312, 3332],
  208. [3386, 3388], [3390, 3423], [3426, 3429], [3446, 3449], [3456, 3460], [3479, 3481],
  209. [3518, 3519], [3527, 3584], [3636, 3647], [3655, 3663], [3674, 3712], [3717, 3718],
  210. [3723, 3724], [3726, 3731], [3752, 3753], [3764, 3772], [3774, 3775], [3783, 3791],
  211. [3802, 3803], [3806, 3839], [3841, 3871], [3892, 3903], [3949, 3975], [3980, 4095],
  212. [4139, 4158], [4170, 4175], [4182, 4185], [4190, 4192], [4194, 4196], [4199, 4205],
  213. [4209, 4212], [4226, 4237], [4250, 4255], [4294, 4303], [4349, 4351], [4686, 4687],
  214. [4702, 4703], [4750, 4751], [4790, 4791], [4806, 4807], [4886, 4887], [4955, 4968],
  215. [4989, 4991], [5008, 5023], [5109, 5120], [5741, 5742], [5787, 5791], [5867, 5869],
  216. [5873, 5887], [5906, 5919], [5938, 5951], [5970, 5983], [6001, 6015], [6068, 6102],
  217. [6104, 6107], [6109, 6111], [6122, 6127], [6138, 6159], [6170, 6175], [6264, 6271],
  218. [6315, 6319], [6390, 6399], [6429, 6469], [6510, 6511], [6517, 6527], [6572, 6592],
  219. [6600, 6607], [6619, 6655], [6679, 6687], [6741, 6783], [6794, 6799], [6810, 6822],
  220. [6824, 6916], [6964, 6980], [6988, 6991], [7002, 7042], [7073, 7085], [7098, 7167],
  221. [7204, 7231], [7242, 7244], [7294, 7400], [7410, 7423], [7616, 7679], [7958, 7959],
  222. [7966, 7967], [8006, 8007], [8014, 8015], [8062, 8063], [8127, 8129], [8141, 8143],
  223. [8148, 8149], [8156, 8159], [8173, 8177], [8189, 8303], [8306, 8307], [8314, 8318],
  224. [8330, 8335], [8341, 8449], [8451, 8454], [8456, 8457], [8470, 8472], [8478, 8483],
  225. [8506, 8507], [8512, 8516], [8522, 8525], [8586, 9311], [9372, 9449], [9472, 10101],
  226. [10132, 11263], [11493, 11498], [11503, 11516], [11518, 11519], [11558, 11567],
  227. [11622, 11630], [11632, 11647], [11671, 11679], [11743, 11822], [11824, 12292],
  228. [12296, 12320], [12330, 12336], [12342, 12343], [12349, 12352], [12439, 12444],
  229. [12544, 12548], [12590, 12592], [12687, 12689], [12694, 12703], [12728, 12783],
  230. [12800, 12831], [12842, 12880], [12896, 12927], [12938, 12976], [12992, 13311],
  231. [19894, 19967], [40908, 40959], [42125, 42191], [42238, 42239], [42509, 42511],
  232. [42540, 42559], [42592, 42593], [42607, 42622], [42648, 42655], [42736, 42774],
  233. [42784, 42785], [42889, 42890], [42893, 43002], [43043, 43055], [43062, 43071],
  234. [43124, 43137], [43188, 43215], [43226, 43249], [43256, 43258], [43260, 43263],
  235. [43302, 43311], [43335, 43359], [43389, 43395], [43443, 43470], [43482, 43519],
  236. [43561, 43583], [43596, 43599], [43610, 43615], [43639, 43641], [43643, 43647],
  237. [43698, 43700], [43703, 43704], [43710, 43711], [43715, 43738], [43742, 43967],
  238. [44003, 44015], [44026, 44031], [55204, 55215], [55239, 55242], [55292, 55295],
  239. [57344, 63743], [64046, 64047], [64110, 64111], [64218, 64255], [64263, 64274],
  240. [64280, 64284], [64434, 64466], [64830, 64847], [64912, 64913], [64968, 65007],
  241. [65020, 65135], [65277, 65295], [65306, 65312], [65339, 65344], [65371, 65381],
  242. [65471, 65473], [65480, 65481], [65488, 65489], [65496, 65497]];
  243. for (i = 0; i < ranges.length; i++) {
  244. start = ranges[i][0];
  245. end = ranges[i][1];
  246. for (j = start; j <= end; j++) {
  247. result[j] = true;
  248. }
  249. }
  250. return result;
  251. })();
  252. function splitQuery(query) {
  253. var result = [];
  254. var start = -1;
  255. for (var i = 0; i < query.length; i++) {
  256. if (splitChars[query.charCodeAt(i)]) {
  257. if (start !== -1) {
  258. result.push(query.slice(start, i));
  259. start = -1;
  260. }
  261. } else if (start === -1) {
  262. start = i;
  263. }
  264. }
  265. if (start !== -1) {
  266. result.push(query.slice(start));
  267. }
  268. return result;
  269. }