add doc v1.1.2

This commit is contained in:
刘可亮
2025-01-23 16:37:00 +08:00
parent ba327e0931
commit b4033d8696
1883 changed files with 417094 additions and 0 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,22 @@
var words = {};
Object.assign(words, index1, index2, index3);
var index = {
/**
* The object with indexed words.
*
* {"word" : "topicID*score, topicID*score"}
*/
w : words,
/**
* Auto generated list of analyzer stop words that must be ignored by search.
*/
stopWords : stopwords,
/**
* File info list.
*/
fil : htmlFileInfoList,
link2parent : linkToParent
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,2 @@
/*Maps current topic to its parent: "topicIndex:parentIndex". -1 represents the map.*/
var linkToParent = {346:348,773:774,354:348,264:312,485:492,364:370,653:670,603:604,955:960,266:312,392:396,487:492,72:219,860:928,348:358,503:510,363:370,593:588,268:312,985:986,219:-1,67:66,710:707,173:219,648:650,709:707,6:218,797:2,278:264,575:577,176:174,441:6,73:76,572:4,24:40,647:650,501:510,405:407,558:554,681:685,361:370,574:577,984:986,68:66,308:312,390:407,499:510,508:510,649:650,223:227,708:707,2:218,576:577,211:217,646:650,510:2,778:774,381:378,517:525,225:237,707:219,652:670,536:542,417:423,215:217,350:358,397:407,645:650,611:610,399:396,455:449,246:243,968:960,235:237,207:217,415:423,729:732,440:441,459:2,607:610,352:348,548:542,286:312,356:358,983:986,523:525,319:338,262:272,259:258,57:60,163:162,750:748,715:726,331:326,495:494,174:219,97:98,18:-1,564:568,494:4,37:60,982:986,257:258,436:441,556:562,791:797,358:4,465:469,101:98,529:531,489:494,688:219,199:2,578:588,760:766,20:60,520:521,386:396,243:249,293:272,554:562,947:949,798:219,588:219,189:193,795:797,295:312,344:358,75:76,573:577,763:766,233:227,552:562,180:174,546:572,577:6,758:766,789:797,253:249,272:312,981:986,340:358,187:193,544:542,249:6,324:326,313:76,251:243,665:661,461:469,486:492,661:670,928:935,326:338,289:264,439:441,986:219,191:193,241:249,312:4,284:286,570:572,687:685,177:174,185:193,438:441,50:27,667:670,255:249,239:243,670:6,80:82,587:588,335:338,274:264,25:60,938:949,179:174,594:604,583:588,290:264,258:219,949:4,98:218,732:5,181:174,261:258,521:525,71:219,227:237,66:219,388:396,766:3,787:797,631:632,217:5,375:373,95:98,342:348,3:218,473:469,609:610,530:531,777:785,604:596,193:2,463:479,372:373,315:76,527:531,100:98,237:2,595:596,27:60,165:162,608:610,429:2,644:2,683:685,449:459,79:82,38:60,62:374,60:-1,76:219,526:531,162:-1,597:604,974:6,624:627,677:685,260:258,628:632,457:459,55:27,657:670,605:596,531:4,492:494,183:193,623:627,675:685,447:459,58:21,632:3,542:572,685:2,281:312,596:-1,402:396,480:6,496:494,92:21,471:479,40:60,218:-1,753:748,719:726,475:469,482:480,522:525,81:82,19:60,697:706,307:264,625:627,380:373,374:373,196:199,52:60,793:797,170:173,785:6,694:706,167:162,373:-1,756:748,32:60,749:748,622:627,77:82,481:480,724:726,566:568,198:199,581:588,29:60,256:258,164:162,745:748,270:312,53:60,525:6,317:315,959:960,21:40,82:4,770:774,703:706,310:312,717:726,175:174,565:568,491:494,711:707,579:588,276:312,194:199,562:4,640:644,965:960,445:449,524:525,34:40,178:174,377:378,314:76,493:494,567:568,490:494,421:423,376:378,443:459,423:2,935:2,172:173,650:2,601:604,338:6,4:218,221:237,606:610,748:3,820:928,781:774,412:423,488:492,407:4,733:732,197:199,726:2,774:785,656:661,960:974,846:928,610:6,540:572,550:562,727:732,660:661,969:974,5:218,782:785,620:627,538:572,590:588,334:326,505:510,602:604,316:76,427:429,409:423,479:4,171:173,771:785,956:974,560:562,627:2,426:429,692:706,638:644,321:326,952:974,469:479,563:568,767:785,69:66,169:162,428:429,229:237,396:407,944:949,642:644,689:706,437:441,74:76,519:521,518:521,636:644,706:3,166:162,630:632,378:373,425:429,663:661,231:227,323:338,453:449,70:66,634:644,679:685,168:162,629:632,599:604,379:373,424:429,483:21,721:726,754:748,568:4,96:98,370:5,528:531,951:949,477:479,533:542};

View File

@@ -0,0 +1,2 @@
// Auto generated list of analyzer stop words that must be ignored by search.
var stopwords = ["呢,的,啊,哎,呀,我,靠","s","t","should","www"];

View File

@@ -0,0 +1,17 @@
David Cramer
<david AT thingbag DOT net>
Kasun Gajasinghe
<kasunbg AT gmail DOT com>
Copyright <20> 2008-2012 Kasun Gajasinghe, David Cramer
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the <20>Software<72>), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
1. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
2. Except as contained in this notice, the names of individuals credited with contribution to this software shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from the individuals in question.
3. Any stylesheet derived from this Software that is publicly distributed will be identified with a different name and the version strings in any derived Software will be changed so that no possibility of confusion between the derived package and this Software will exist.
Warranty: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL DAVID CRAMER, KASUN GAJASINGHE, OR ANY OTHER CONTRIBUTOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,247 @@
/*
* Author: Joder Illi
*
* Copyright (c) 2010, FormBlitz AG
* All rights reserved.
* Implementation of the stemming algorithm from http://snowball.tartarus.org/algorithms/german/stemmer.html
* Copyright of the algorithm is: Copyright (c) 2001, Dr Martin Porter and can be found at http://snowball.tartarus.org/license.php
*
* Redistribution and use in source and binary forms, with or without modification, is covered by the standard BSD license.
*
*/
//var stemmer = function Stemmer() {
/*
German includes the following accented forms,
ä ö ü
and a special letter, ß, equivalent to double s.
The following letters are vowels:
a e i o u y ä ö ü
*/
define(function () {
return function (word) {
/*
Put u and y between vowels into upper case
*/
word = word.replace(/([aeiouyäöü])u([aeiouyäöü])/g, '$1U$2');
word = word.replace(/([aeiouyäöü])y([aeiouyäöü])/g, '$1Y$2');
/*
and then do the following mappings,
(a) replace ß with ss,
(a) replace ae with ä, Not doing these, have trouble with diphtongs
(a) replace oe with ö, Not doing these, have trouble with diphtongs
(a) replace ue with ü unless preceded by q. Not doing these, have trouble with diphtongs
So in quelle, ue is not mapped to ü because it follows q, and in feuer it is not mapped because the first part of the rule changes it to feUer, so the u is not found.
*/
word = word.replace(/ß/g, 'ss');
//word = word.replace(/ae/g, 'ä');
//word = word.replace(/oe/g, 'ö');
//word = word.replace(/([^q])ue/g, '$1ü');
/*
R1 and R2 are first set up in the standard way (see the note on R1 and R2), but then R1 is adjusted so that the region before it contains at least 3 letters.
R1 is the region after the first non-vowel following a vowel, or is the null region at the end of the word if there is no such non-vowel.
R2 is the region after the first non-vowel following a vowel in R1, or is the null region at the end of the word if there is no such non-vowel.
*/
var r1Index = word.search(/[aeiouyäöü][^aeiouyäöü]/);
var r1 = '';
if (r1Index != -1) {
r1Index += 2;
r1 = word.substring(r1Index);
}
var r2Index = -1;
var r2 = '';
if (r1Index != -1) {
var r2Index = r1.search(/[aeiouyäöü][^aeiouyäöü]/);
if (r2Index != -1) {
r2Index += 2;
r2 = r1.substring(r2Index);
r2Index += r1Index;
} else {
r2 = '';
}
}
if (r1Index != -1 && r1Index < 3) {
r1Index = 3;
r1 = word.substring(r1Index);
}
/*
Define a valid s-ending as one of b, d, f, g, h, k, l, m, n, r or t.
Define a valid st-ending as the same list, excluding letter r.
*/
/*
Do each of steps 1, 2 and 3.
*/
/*
Step 1:
Search for the longest among the following suffixes,
(a) em ern er
(b) e en es
(c) s (preceded by a valid s-ending)
*/
var a1Index = word.search(/(em|ern|er)$/g);
var b1Index = word.search(/(e|en|es)$/g);
var c1Index = word.search(/([bdfghklmnrt]s)$/g);
if (c1Index != -1) {
c1Index++;
}
var index1 = 10000;
var optionUsed1 = '';
if (a1Index != -1 && a1Index < index1) {
optionUsed1 = 'a';
index1 = a1Index;
}
if (b1Index != -1 && b1Index < index1) {
optionUsed1 = 'b';
index1 = b1Index;
}
if (c1Index != -1 && c1Index < index1) {
optionUsed1 = 'c';
index1 = c1Index;
}
/*
and delete if in R1. (Of course the letter of the valid s-ending is not necessarily in R1.) If an ending of group (b) is deleted, and the ending is preceded by niss, delete the final s.
(For example, äckern -> äck, ackers -> acker, armes -> arm, bedürfnissen -> bedürfnis)
*/
if (index1 != 10000 && r1Index != -1) {
if (index1 >= r1Index) {
word = word.substring(0, index1);
if (optionUsed1 == 'b') {
if (word.search(/niss$/) != -1) {
word = word.substring(0, word.length - 1);
}
}
}
}
/*
Step 2:
Search for the longest among the following suffixes,
(a) en er est
(b) st (preceded by a valid st-ending, itself preceded by at least 3 letters)
*/
var a2Index = word.search(/(en|er|est)$/g);
var b2Index = word.search(/(.{3}[bdfghklmnt]st)$/g);
if (b2Index != -1) {
b2Index += 4;
}
var index2 = 10000;
var optionUsed2 = '';
if (a2Index != -1 && a2Index < index2) {
optionUsed2 = 'a';
index2 = a2Index;
}
if (b2Index != -1 && b2Index < index2) {
optionUsed2 = 'b';
index2 = b2Index;
}
/*
and delete if in R1.
(For example, derbsten -> derbst by step 1, and derbst -> derb by step 2, since b is a valid st-ending, and is preceded by just 3 letters)
*/
if (index2 != 10000 && r1Index != -1) {
if (index2 >= r1Index) {
word = word.substring(0, index2);
}
}
/*
Step 3: d-suffixes (*)
Search for the longest among the following suffixes, and perform the action indicated.
end ung
delete if in R2
if preceded by ig, delete if in R2 and not preceded by e
ig ik isch
delete if in R2 and not preceded by e
lich heit
delete if in R2
if preceded by er or en, delete if in R1
keit
delete if in R2
if preceded by lich or ig, delete if in R2
*/
var a3Index = word.search(/(end|ung)$/g);
var b3Index = word.search(/[^e](ig|ik|isch)$/g);
var c3Index = word.search(/(lich|heit)$/g);
var d3Index = word.search(/(keit)$/g);
if (b3Index != -1) {
b3Index++;
}
var index3 = 10000;
var optionUsed3 = '';
if (a3Index != -1 && a3Index < index3) {
optionUsed3 = 'a';
index3 = a3Index;
}
if (b3Index != -1 && b3Index < index3) {
optionUsed3 = 'b';
index3 = b3Index;
}
if (c3Index != -1 && c3Index < index3) {
optionUsed3 = 'c';
index3 = c3Index;
}
if (d3Index != -1 && d3Index < index3) {
optionUsed3 = 'd';
index3 = d3Index;
}
if (index3 != 10000 && r2Index != -1) {
if (index3 >= r2Index) {
word = word.substring(0, index3);
var optionIndex = -1;
var optionSubsrt = '';
if (optionUsed3 == 'a') {
optionIndex = word.search(/[^e](ig)$/);
if (optionIndex != -1) {
optionIndex++;
if (optionIndex >= r2Index) {
word = word.substring(0, optionIndex);
}
}
} else if (optionUsed3 == 'c') {
optionIndex = word.search(/(er|en)$/);
if (optionIndex != -1) {
if (optionIndex >= r1Index) {
word = word.substring(0, optionIndex);
}
}
} else if (optionUsed3 == 'd') {
optionIndex = word.search(/(lich|ig)$/);
if (optionIndex != -1) {
if (optionIndex >= r2Index) {
word = word.substring(0, optionIndex);
}
}
}
}
}
/*
Finally,
turn U and Y back into lower case, and remove the umlaut accent from a, o and u.
*/
word = word.replace(/U/g, 'u');
word = word.replace(/Y/g, 'y');
word = word.replace(/ä/g, 'a');
word = word.replace(/ö/g, 'o');
word = word.replace(/ü/g, 'u');
return word;
};
});

View File

@@ -0,0 +1,204 @@
// Porter stemmer in Javascript. Few comments, but it's easy to follow against the rules in the original
// paper, in
//
// Porter, 1980, An algorithm for suffix stripping, Program, Vol. 14,
// no. 3, pp 130-137,
//
// see also http://www.tartarus.org/~martin/PorterStemmer
// Release 1 be 'andargor', Jul 2004
// Release 2 (substantially revised) by Christopher McKenzie, Aug 2009
define(function () {
return (function () {
var step2list = {
"ational": "ate",
"tional": "tion",
"enci": "ence",
"anci": "ance",
"izer": "ize",
"bli": "ble",
"alli": "al",
"entli": "ent",
"eli": "e",
"ousli": "ous",
"ization": "ize",
"ation": "ate",
"ator": "ate",
"alism": "al",
"iveness": "ive",
"fulness": "ful",
"ousness": "ous",
"aliti": "al",
"iviti": "ive",
"biliti": "ble",
"logi": "log"
},
step3list = {
"icate": "ic",
"ative": "",
"alize": "al",
"iciti": "ic",
"ical": "ic",
"ful": "",
"ness": ""
},
c = "[^aeiou]", // consonant
v = "[aeiouy]", // vowel
C = c + "[^aeiouy]*", // consonant sequence
V = v + "[aeiou]*", // vowel sequence
mgr0 = "^(" + C + ")?" + V + C, // [C]VC... is m>0
meq1 = "^(" + C + ")?" + V + C + "(" + V + ")?$", // [C]VC[V] is m=1
mgr1 = "^(" + C + ")?" + V + C + V + C, // [C]VCVC... is m>1
s_v = "^(" + C + ")?" + v; // vowel in stem
return function (w) {
var stem,
suffix,
firstch,
re,
re2,
re3,
re4,
origword = w;
if (w.length < 3) {
return w;
}
firstch = w.substr(0, 1);
if (firstch == "y") {
w = firstch.toUpperCase() + w.substr(1);
}
// Step 1a
re = /^(.+?)(ss|i)es$/;
re2 = /^(.+?)([^s])s$/;
if (re.test(w)) {
w = w.replace(re, "$1$2");
}
else if (re2.test(w)) {
w = w.replace(re2, "$1$2");
}
// Step 1b
re = /^(.+?)eed$/;
re2 = /^(.+?)(ed|ing)$/;
if (re.test(w)) {
var fp = re.exec(w);
re = new RegExp(mgr0);
if (re.test(fp[1])) {
re = /.$/;
w = w.replace(re, "");
}
} else if (re2.test(w)) {
var fp = re2.exec(w);
stem = fp[1];
re2 = new RegExp(s_v);
if (re2.test(stem)) {
w = stem;
re2 = /(at|bl|iz)$/;
re3 = new RegExp("([^aeiouylsz])\\1$");
re4 = new RegExp("^" + C + v + "[^aeiouwxy]$");
if (re2.test(w)) {
w = w + "e";
}
else if (re3.test(w)) {
re = /.$/;
w = w.replace(re, "");
}
else if (re4.test(w)) {
w = w + "e";
}
}
}
// Step 1c
re = /^(.+?)y$/;
if (re.test(w)) {
var fp = re.exec(w);
stem = fp[1];
re = new RegExp(s_v);
if (re.test(stem)) {
w = stem + "i";
}
}
// Step 2
re = /^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/;
if (re.test(w)) {
var fp = re.exec(w);
stem = fp[1];
suffix = fp[2];
re = new RegExp(mgr0);
if (re.test(stem)) {
w = stem + step2list[suffix];
}
}
// Step 3
re = /^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/;
if (re.test(w)) {
var fp = re.exec(w);
stem = fp[1];
suffix = fp[2];
re = new RegExp(mgr0);
if (re.test(stem)) {
w = stem + step3list[suffix];
}
}
// Step 4
re = /^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/;
re2 = /^(.+?)(s|t)(ion)$/;
if (re.test(w)) {
var fp = re.exec(w);
stem = fp[1];
re = new RegExp(mgr1);
if (re.test(stem)) {
w = stem;
}
} else if (re2.test(w)) {
var fp = re2.exec(w);
stem = fp[1] + fp[2];
re2 = new RegExp(mgr1);
if (re2.test(stem)) {
w = stem;
}
}
// Step 5
re = /^(.+?)e$/;
if (re.test(w)) {
var fp = re.exec(w);
stem = fp[1];
re = new RegExp(mgr1);
re2 = new RegExp(meq1);
re3 = new RegExp("^" + C + v + "[^aeiouwxy]$");
if (re.test(stem) || (re2.test(stem) && !(re3.test(stem)))) {
w = stem;
}
}
re = /ll$/;
re2 = new RegExp(mgr1);
if (re.test(w) && re2.test(w)) {
re = /.$/;
w = w.replace(re, "");
}
// and turn initial Y back to y
if (firstch == "y") {
w = firstch.toLowerCase() + w.substr(1);
}
return w;
}
})();
});

View File

@@ -0,0 +1,276 @@
/*
* Author: Kasun Gajasinghe
* E-Mail: kasunbg AT gmail DOT com
* Date: 09.08.2010
*
* usage: stemmer(word);
* ex: var stem = stemmer(foobar);
* Implementation of the stemming algorithm from http://snowball.tartarus.org/algorithms/french/stemmer.html
*
* LICENSE:
*
* Copyright (c) 2010, Kasun Gajasinghe. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
*
* THIS SOFTWARE IS PROVIDED BY KASUN GAJASINGHE ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KASUN GAJASINGHE BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
define(function () {
return function (word) {
// Letters in French include the following accented forms,
// â à ç ë é ê è ï î ô û ù
// The following letters are vowels:
// a e i o u y â à ë é ê è ï î ô û ù
word = word.toLowerCase();
var oriWord = word;
word = word.replace(/qu/g, 'qU'); //have to perform first, as after the operation, capital U is not treated as a vowel
word = word.replace(/([aeiouyâàëéêèïîôûù])u([aeiouyâàëéêèïîôûù])/g, '$1U$2');
word = word.replace(/([aeiouyâàëéêèïîôûù])i([aeiouyâàëéêèïîôûù])/g, '$1I$2');
word = word.replace(/([aeiouyâàëéêèïîôûù])y/g, '$1Y');
word = word.replace(/y([aeiouyâàëéêèïîôûù])/g, 'Y$1');
var rv = '';
var rvIndex = -1;
if (word.search(/^(par|col|tap)/) != -1 || word.search(/^[aeiouyâàëéêèïîôûù]{2}/) != -1) {
rv = word.substring(3);
rvIndex = 3;
} else {
rvIndex = word.substring(1).search(/[aeiouyâàëéêèïîôûù]/);
if (rvIndex != -1) {
rvIndex += 2; //+2 is to supplement the substring(1) used to find rvIndex
rv = word.substring(rvIndex);
} else {
rvIndex = word.length;
}
}
// R1 is the region after the first non-vowel following a vowel, or the end of the word if there is no such non-vowel.
// R2 is the region after the first non-vowel following a vowel in R1, or the end of the word if there is no such non-vowel
var r1Index = word.search(/[aeiouyâàëéêèïîôûù][^aeiouyâàëéêèïîôûù]/);
var r1 = '';
if (r1Index != -1) {
r1Index += 2;
r1 = word.substring(r1Index);
} else {
r1Index = word.length;
}
var r2Index = -1;
var r2 = '';
if (r1Index != -1) {
r2Index = r1.search(/[aeiouyâàëéêèïîôûù][^aeiouyâàëéêèïîôûù]/);
if (r2Index != -1) {
r2Index += 2;
r2 = r1.substring(r2Index);
r2Index += r1Index;
} else {
r2 = '';
r2Index = word.length;
}
}
if (r1Index != -1 && r1Index < 3) {
r1Index = 3;
r1 = word.substring(r1Index);
}
/*
Step 1: Standard suffix removal
*/
var a1Index = word.search(/(ance|iqUe|isme|able|iste|eux|ances|iqUes|ismes|ables|istes)$/);
var a2Index = word.search(/(atrice|ateur|ation|atrices|ateurs|ations)$/);
var a3Index = word.search(/(logie|logies)$/);
var a4Index = word.search(/(usion|ution|usions|utions)$/);
var a5Index = word.search(/(ence|ences)$/);
var a6Index = word.search(/(ement|ements)$/);
var a7Index = word.search(/(ité|ités)$/);
var a8Index = word.search(/(if|ive|ifs|ives)$/);
var a9Index = word.search(/(eaux)$/);
var a10Index = word.search(/(aux)$/);
var a11Index = word.search(/(euse|euses)$/);
var a12Index = word.search(/[^aeiouyâàëéêèïîôûù](issement|issements)$/);
var a13Index = word.search(/(amment)$/);
var a14Index = word.search(/(emment)$/);
var a15Index = word.search(/[aeiouyâàëéêèïîôûù](ment|ments)$/);
if (a1Index != -1 && a1Index >= r2Index) {
word = word.substring(0, a1Index);
} else if (a2Index != -1 && a2Index >= r2Index) {
word = word.substring(0, a2Index);
var a2Index2 = word.search(/(ic)$/);
if (a2Index2 != -1 && a2Index2 >= r2Index) {
word = word.substring(0, a2Index2); //if preceded by ic, delete if in R2,
} else { //else replace by iqU
word = word.replace(/(ic)$/, 'iqU');
}
} else if (a3Index != -1 && a3Index >= r2Index) {
word = word.replace(/(logie|logies)$/, 'log'); //replace with log if in R2
} else if (a4Index != -1 && a4Index >= r2Index) {
word = word.replace(/(usion|ution|usions|utions)$/, 'u'); //replace with u if in R2
} else if (a5Index != -1 && a5Index >= r2Index) {
word = word.replace(/(ence|ences)$/, 'ent'); //replace with ent if in R2
} else if (a6Index != -1 && a6Index >= rvIndex) {
word = word.substring(0, a6Index);
if (word.search(/(iv)$/) >= r2Index) {
word = word.replace(/(iv)$/, '');
if (word.search(/(at)$/) >= r2Index) {
word = word.replace(/(at)$/, '');
}
} else if (word.search(/(eus)$/) != -1) {
var a6Index2 = word.search(/(eus)$/);
if (a6Index2 >= r2Index) {
word = word.substring(0, a6Index2);
} else if (a6Index2 >= r1Index) {
word = word.substring(0, a6Index2) + "eux";
}
} else if (word.search(/(abl|iqU)$/) >= r2Index) {
word = word.replace(/(abl|iqU)$/, ''); //if preceded by abl or iqU, delete if in R2,
} else if (word.search(/(ièr|Ièr)$/) >= rvIndex) {
word = word.replace(/(ièr|Ièr)$/, 'i'); //if preceded by abl or iqU, delete if in R2,
}
} else if (a7Index != -1 && a7Index >= r2Index) {
word = word.substring(0, a7Index); //delete if in R2
if (word.search(/(abil)$/) != -1) { //if preceded by abil, delete if in R2, else replace by abl, otherwise,
var a7Index2 = word.search(/(abil)$/);
if (a7Index2 >= r2Index) {
word = word.substring(0, a7Index2);
} else {
word = word.substring(0, a7Index2) + "abl";
}
} else if (word.search(/(ic)$/) != -1) {
var a7Index3 = word.search(/(ic)$/);
if (a7Index3 != -1 && a7Index3 >= r2Index) {
word = word.substring(0, a7Index3); //if preceded by ic, delete if in R2,
} else { //else replace by iqU
word = word.replace(/(ic)$/, 'iqU');
}
} else if (word.search(/(iv)$/) != r2Index) {
word = word.replace(/(iv)$/, '');
}
} else if (a8Index != -1 && a8Index >= r2Index) {
word = word.substring(0, a8Index);
if (word.search(/(at)$/) >= r2Index) {
word = word.replace(/(at)$/, '');
if (word.search(/(ic)$/) >= r2Index) {
word = word.replace(/(ic)$/, '');
} else {
word = word.replace(/(ic)$/, 'iqU');
}
}
} else if (a9Index != -1) {
word = word.replace(/(eaux)/, 'eau')
} else if (a10Index >= r1Index) {
word = word.replace(/(aux)/, 'al')
} else if (a11Index != -1) {
var a11Index2 = word.search(/(euse|euses)$/);
if (a11Index2 >= r2Index) {
word = word.substring(0, a11Index2);
} else if (a11Index2 >= r1Index) {
word = word.substring(0, a11Index2) + "eux";
}
} else if (a12Index != -1 && a12Index >= r1Index) {
word = word.substring(0, a12Index + 1); //+1- amendment to non-vowel
} else if (a13Index != -1 && a13Index >= rvIndex) {
word = word.replace(/(amment)$/, 'ant');
} else if (a14Index != -1 && a14Index >= rvIndex) {
word = word.replace(/(emment)$/, 'ent');
} else if (a15Index != -1 && a15Index >= rvIndex) {
word = word.substring(0, a15Index + 1);
}
/* Step 2a: Verb suffixes beginning i*/
var wordStep1 = word;
var step2aDone = false;
if (oriWord == word.toLowerCase() || oriWord.search(/(amment|emment|ment|ments)$/) != -1) {
step2aDone = true;
var b1Regex = /([^aeiouyâàëéêèïîôûù])(îmes|ît|îtes|i|ie|ies|ir|ira|irai|iraIent|irais|irait|iras|irent|irez|iriez|irions|irons|iront|is|issaIent|issais|issait|issant|issante|issantes|issants|isse|issent|isses|issez|issiez|issions|issons|it)$/i;
if (word.search(b1Regex) >= rvIndex) {
word = word.replace(b1Regex, '$1');
}
}
/* Step 2b: Other verb suffixes*/
if (step2aDone && wordStep1 == word) {
if (word.search(/(ions)$/) >= r2Index) {
word = word.replace(/(ions)$/, '');
} else {
var b2Regex = /(é|ée|ées|és|èrent|er|era|erai|eraIent|erais|erait|eras|erez|eriez|erions|erons|eront|ez|iez)$/i;
if (word.search(b2Regex) >= rvIndex) {
word = word.replace(b2Regex, '');
} else {
var b3Regex = /e(âmes|ât|âtes|a|ai|aIent|ais|ait|ant|ante|antes|ants|as|asse|assent|asses|assiez|assions)$/i;
if (word.search(b3Regex) >= rvIndex) {
word = word.replace(b3Regex, '');
} else {
var b3Regex2 = /(âmes|ât|âtes|a|ai|aIent|ais|ait|ant|ante|antes|ants|as|asse|assent|asses|assiez|assions)$/i;
if (word.search(b3Regex2) >= rvIndex) {
word = word.replace(b3Regex2, '');
}
}
}
}
}
if (oriWord != word.toLowerCase()) {
/* Step 3 */
var rep = '';
if (word.search(/Y$/) != -1) {
word = word.replace(/Y$/, 'i');
} else if (word.search(/ç$/) != -1) {
word = word.replace(/ç$/, 'c');
}
} else {
/* Step 4 */
//If the word ends s, not preceded by a, i, o, u, è or s, delete it.
if (word.search(/([^aiouès])s$/) >= rvIndex) {
word = word.replace(/([^aiouès])s$/, '$1');
}
var e1Index = word.search(/ion$/);
if (e1Index >= r2Index && word.search(/[st]ion$/) >= rvIndex) {
word = word.substring(0, e1Index);
} else {
var e2Index = word.search(/(ier|ière|Ier|Ière)$/);
if (e2Index != -1 && e2Index >= rvIndex) {
word = word.substring(0, e2Index) + "i";
} else {
if (word.search(/e$/) >= rvIndex) {
word = word.replace(/e$/, ''); //delete last e
} else if (word.search(/guë$/) >= rvIndex) {
word = word.replace(/guë$/, 'gu');
}
}
}
}
/* Step 5: Undouble */
//word = word.replace(/(en|on|et|el|eil)(n|t|l)$/,'$1');
word = word.replace(/(en|on)(n)$/, '$1');
word = word.replace(/(ett)$/, 'et');
word = word.replace(/(el|eil)(l)$/, '$1');
/* Step 6: Un-accent */
word = word.replace(/[éè]([^aeiouyâàëéêèïîôûù]+)$/, 'e$1');
word = word.toLowerCase();
return word;
};
});

View File

@@ -0,0 +1,12 @@
define(["options", "en_stemmer", "de_stemmer", "fr_stemmer"], function(options, en_stemmer, de_stemmer, fr_stemmer) {
var indexerLang = options.getIndexerLanguage();
if (indexerLang == 'en') {
return en_stemmer;
} else if (indexerLang == 'de') {
return de_stemmer;
} else if (indexerLang == 'fr') {
return fr_stemmer;
} else {
// Do nothing
}
});