design stemming option when search in robohelp
hi i need some help to understand how searching is working in robohelp i had an idea to include Arabic stemming feature so i tried to analyses the search how its works in adobe robohelp what i understand is but i'm no sure that index have alphabet structure to speed up the process of searching rather than search the whole index files,
so if i search for example "help" it will begin to to find the closet match words that start with this characters of the search words until find it and the code responsible for that is in mhfhodt.js:
this.getWordRec = function ( a_strQuery , bPhraseSearch)
{
if (!bPhraseSearch && IsStopWord(a_strQuery, gaFtsStop))
return ""; // Return empty if no phrase search and term is a stop word.
var i;
var begin = 0 ;
var end = this.curData.aNodes.length ;
var mid = Math.floor((end -begin ) / 2) ;
while (mid > 0 )
{
i++;
mid = mid + begin ;
var term = this.curData.aNodes[mid].aAttrs["nm"] ;
console.log(mid);
if (a_strQuery < term)
end = mid ;
else if (a_strQuery > term)
begin = mid ;
else
break ;
mid = Math.floor((end -begin ) / 2) ;
}
if (((end-begin) == 1)&&(!this.matchPrefix(a_strQuery,this.curData.aNodes[mid].aAttrs["nm"])))
{
mid = end ;
}
if (mid < this.curData.aNodes.length)
{
if (!bPhraseSearch && gsSubstrSrch)
{
//get all the records with matching prefix
var arrTopicRecs = new Array();
while( mid<this.curData.aNodes.length)
{
if (this.curData.aNodes[mid].aAttrs["sp"])
{
mid++ ;
continue ;
}
else if (this.matchPrefix(a_strQuery,this.curData.aNodes[mid].aAttrs["nm"]))
{
arrTopicRecs[arrTopicRecs.length] = this.curData.aNodes[mid].aAttrs["rd"] ;
mid++ ;
}
else
break ;
}
if (arrTopicRecs.length == 0 )
return "" ;
var mergedRec = arrTopicRecs[0] ;
for (var i = 1 ; i < arrTopicRecs.length ; i++)
{
mergedRec = mergeTopicRec(mergedRec , arrTopicRecs);
}
return mergedRec ;
}
else
{
//get the one with exact match
if ((this.curData.aNodes[mid].aAttrs["nm"])==a_strQuery)
{
if (bPhraseSearch || gsSubstrSrch){
return this.curData.aNodes[mid].aAttrs["rd"];
}
else
{
//do not return stop words
if (this.curData.aNodes[mid].aAttrs["sp"])
return "" ;
else
return this.curData.aNodes[mid].aAttrs["rd"] ;
}
}
else
return "" ;
}
}
}
my idea was to stem the searched word and compare it to index files and also the index words stemmed dynamically ;
let say i had stemmed function called stemmer() ;
so if i do this :
a_strQuery = stemmer( a_strQuery) ;
also the returned alphabet words from index like this:
var term = this.curData.aNodes[mid].aAttrs["nm"] ;
term= stemmer(term) ;
so if i compare the value "a_strQuery" with the value "term" is it possible to works ??
i tried it but its not working as i expected but i think the principle could be applied can some one give some hints i mean where should i modify the scripts to make work
Message was edited by: jomart mirza
