Skip to content

Commit

Permalink
Merge pull request #281 from dotnet/fix#279
Browse files Browse the repository at this point in the history
Fix #279: Provide with a config file to customize stop-words
  • Loading branch information
qinezh committed May 6, 2016
1 parent bdb3158 commit ca190ef
Show file tree
Hide file tree
Showing 2 changed files with 133 additions and 0 deletions.
121 changes: 121 additions & 0 deletions src/docfx.website.themes/default/search-stopwords.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
[
"a",
"able",
"about",
"across",
"after",
"all",
"almost",
"also",
"am",
"among",
"an",
"and",
"any",
"are",
"as",
"at",
"be",
"because",
"been",
"but",
"by",
"can",
"cannot",
"could",
"dear",
"did",
"do",
"does",
"either",
"else",
"ever",
"every",
"for",
"from",
"get",
"got",
"had",
"has",
"have",
"he",
"her",
"hers",
"him",
"his",
"how",
"however",
"i",
"if",
"in",
"into",
"is",
"it",
"its",
"just",
"least",
"let",
"like",
"likely",
"may",
"me",
"might",
"most",
"must",
"my",
"neither",
"no",
"nor",
"not",
"of",
"off",
"often",
"on",
"only",
"or",
"other",
"our",
"own",
"rather",
"said",
"say",
"says",
"she",
"should",
"since",
"so",
"some",
"than",
"that",
"the",
"their",
"them",
"then",
"there",
"these",
"they",
"this",
"tis",
"to",
"too",
"twas",
"us",
"wants",
"was",
"we",
"were",
"what",
"when",
"where",
"which",
"while",
"who",
"whom",
"why",
"will",
"with",
"would",
"yet",
"you",
"your"
]
12 changes: 12 additions & 0 deletions src/docfx.website.themes/default/styles/search-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,23 @@
importScripts('lunr.min.js');

var lunrIndex = lunr(function() {
this.pipeline.remove(lunr.stopWordFilter);
this.ref('href');
this.field('title', {boost: 50});
this.field('keywords', {boost: 20});
});
lunr.tokenizer.seperator = /[\s\-\.]+/;

var stopWordsRequest = new XMLHttpRequest();
stopWordsRequest.open('GET', '../search-stopwords.json');
stopWordsRequest.onload = function() {
var stopWords = JSON.parse(this.responseText);
var docfxStopWordFilter = lunr.generateStopWordFilter(stopWords);
lunr.Pipeline.registerFunction(docfxStopWordFilter, 'docfxStopWordFilter');
lunrIndex.pipeline.add(docfxStopWordFilter);
}
stopWordsRequest.send();

var searchData = {};
var searchDataRequest = new XMLHttpRequest();

Expand Down

0 comments on commit ca190ef

Please sign in to comment.