/*
* searchtools.js_t
* ~~~~~~~~~~~~~~~~
*
* Sphinx JavaScript utilties for the full-text search.
*
* :copyright: Copyright 2007-2014 by the Sphinx team, see AUTHORS.
* :license: BSD, see LICENSE for details.
*
*/
/**
* Porter Stemmer
*/
var Stemmer = 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'
};
var step3list = {
icate: 'ic',
ative: '',
alize: 'al',
iciti: 'ic',
ical: 'ic',
ful: '',
ness: ''
};
var c = "[^aeiou]"; // consonant
var v = "[aeiouy]"; // vowel
var C = c + "[^aeiouy]*"; // consonant sequence
var V = v + "[aeiou]*"; // vowel sequence
this.stemWord = function (w) {
var stem;
var suffix;
var firstch;
var origword = w;
if (w.length < 3)
return w;
var re;
var re2;
var re3;
var re4;
if (firstch == "y")
// Step 1a
// Step 1b
re = /.$/;
}
}
w = stem;
re3 = new RegExp("([^aeiouylsz])\\1$");
w = w + "e";
re = /.$/;
}
w = w + "e";
}
}
// Step 1c
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)$/;
}
// Step 3
}
// Step 4
w = stem;
}
w = stem;
}
// Step 5
w = stem;
}
re = /.$/;
}
// and turn initial Y back to y
if (firstch == "y")
return w;
}
}
/**
* Simple result scoring code.
*/
var Scorer = {
// Implement the following function to further tweak the score for each result
// The function takes a result array [filename, title, anchor, descr, score]
// and returns the new score.
/*
score: function(result) {
return result[4];
},
*/
// query matches the full name of an object
objNameMatch: 11,
// or matches in the last dotted part of the object name
objPartialMatch: 6,
// Additive scores depending on the priority of the object
1: 5, // used to be objectResults
2: -5}, // used to be unimportantResults
// Used when the priority is not in the mapping.
objPrioDefault: 0,
// query found in title
title: 15,
// query found in terms
term: 5
};
/**
* Search Module
*/
var Search = {
_index : null,
_queued_query : null,
_pulse_status : -1,
init : function() {
var params = $.getQueryParameters();
if (params.q) {
this.performSearch(query);
}
},
if (textstatus != "success") {
}
}});
},
var q;
if ((q = this._queued_query) !== null) {
this._queued_query = null;
}
},
hasIndex : function() {
return this._index !== null;
},
deferQuery : function(query) {
this._queued_query = query;
},
stopPulse : function() {
this._pulse_status = 0;
},
startPulse : function() {
if (this._pulse_status >= 0)
return;
function pulse() {
var i;
var dotString = '';
dotString += '.';
}
pulse();
},
/**
* perform a search for something (or wait until index is loaded)
*/
performSearch : function(query) {
// create the required interface elements
this.out = $('#search-results');
this.startPulse();
// index already loaded, the browser was quick!
if (this.hasIndex())
else
this.deferQuery(query);
},
/**
* execute search (requires search index to be loaded)
*/
var i;
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"];
// stem the searchterms and add them to the correct list
var searchterms = [];
var excluded = [];
var hlterms = [];
var objectterms = [];
if (tmp[i] !== "") {
}
tmp[i] === "") {
// skip this "word"
continue;
}
// stem the word
var toAppend;
// select the correct list
}
else {
}
// only add if not already in the list
}
// console.debug('SEARCH: searching for:');
// console.info('required: ', searchterms);
// console.info('excluded: ', excluded);
// prepare search
// array of [filename, title, anchor, descr, score]
var results = [];
$('#search-progress').empty();
// lookup as object
}
// lookup as search terms in fulltext
// let the scorer override scores with a custom scoring function
}
// now sort the results by score (in opposite order of appearance, since the
// display function below uses pop() to retrieve items) and then
// alphabetically
var left = a[4];
var right = b[4];
return 1;
return -1;
} else {
// same score: sort alphabetically
}
});
// for debugging
//Search.lastresults = results.slice(); // a copy
//console.info('search results:', Search.lastresults);
// print the results
function displayNextItem() {
// results left, load the summary and display it
var listItem = $('<li style="display:none"></li>');
// dirhtml builder
} else if (dirname == 'index/') {
dirname = '';
}
} else {
// normal html builders
}
if (item[3]) {
});
} else if (DOCUMENTATION_OPTIONS.HAS_SOURCE) {
dataType: "text",
if (data !== '') {
}
});
}});
} else {
// no source available, just display title
});
}
}
// search finished, update title and status message
else {
if (!resultCount)
Search.status.text(_('Your search did not match any documents. Please make sure that all words are spelled correctly and that you\'ve selected enough categories.'));
else
Search.status.text(_('Search finished, found %s page(s) matching the search query.').replace('%s', resultCount));
}
}
},
/**
* search for object names
*/
var i;
var results = [];
var score = 0;
// check for different match types: exact matches of full name or
// "last name" (i.e. last dotted part)
// matches in last name
}
// If more than one term searched for, we require other words to be
// found in the name/title/description
var allfound = true;
allfound = false;
break;
}
}
if (!allfound) {
continue;
}
}
if (anchor === '')
else if (anchor == '-')
// add custom score for some objects according to scorer
} else {
}
}
}
}
return results;
},
/**
* search for full-text terms in the index
*/
var fileMap = {};
var results = [];
// perform the search on the required terms
var word = searchterms[i];
// no match but word was a required one
break;
}
// create the mapping
else
}
}
// now check if the files don't contain excluded terms
var valid = true;
// check if all requirements are matched
continue;
// ensure that none of the excluded terms is in the search result
valid = false;
break;
}
}
// if we have still a valid result we can add it to the result list
if (valid) {
}
}
return results;
},
/**
* helper function to return a node containing the
* search summary for a given text. keywords is a list
* of stemmed words, hlwords is the list of normal, unstemmed
* words. the first one is used to find the occurance, the
* latter for highlighting it.
*/
if (i > -1)
start = i;
});
});
return rv;
}
};
});