mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 19:24:08 +00:00
Fix full-text search for case of partially matched sequence
This commit is contained in:
parent
6262047e18
commit
4ef7046327
|
@ -459,6 +459,7 @@ void FTSResultsRequest::checkArticles( QVector< uint32_t > const & offsets,
|
|||
int pos = 0;
|
||||
int matchWordNom = 0;
|
||||
int unmatchWordNom = 0;
|
||||
int nextNotFoundPos = 0;
|
||||
|
||||
QVector< QStringList > allOrders;
|
||||
QStringList order;
|
||||
|
@ -539,8 +540,15 @@ void FTSResultsRequest::checkArticles( QVector< uint32_t > const & offsets,
|
|||
if( i < wordsList.size() )
|
||||
{
|
||||
// Word found
|
||||
|
||||
matchWordNom += 1;
|
||||
|
||||
if( matchWordNom == 1 )
|
||||
{
|
||||
// Store position to remake search if sequence will not be found
|
||||
nextNotFoundPos = pos + ( s.isEmpty() ? 1 : s.length() );
|
||||
}
|
||||
|
||||
if( matchWordNom >= words.size() )
|
||||
{
|
||||
// All words are found
|
||||
|
@ -563,6 +571,7 @@ void FTSResultsRequest::checkArticles( QVector< uint32_t > const & offsets,
|
|||
unmatchWordNom = 0;
|
||||
for( int i = 0; i < wordsList.size(); i++ )
|
||||
wordsList[ i ].second = true;
|
||||
nextNotFoundPos = 0;
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -592,6 +601,12 @@ void FTSResultsRequest::checkArticles( QVector< uint32_t > const & offsets,
|
|||
{
|
||||
matchWordNom += 1;
|
||||
|
||||
if( matchWordNom == 1 )
|
||||
{
|
||||
// Store position to remake search if sequence will not be found
|
||||
nextNotFoundPos = pos + ( s.isEmpty() ? 1 : s.length() );
|
||||
}
|
||||
|
||||
if( needHandleBrackets )
|
||||
{
|
||||
if( parsedWords.size() > 1 )
|
||||
|
@ -628,6 +643,7 @@ void FTSResultsRequest::checkArticles( QVector< uint32_t > const & offsets,
|
|||
matchWordNom = 0;
|
||||
unmatchWordNom = 0;
|
||||
order.clear();
|
||||
nextNotFoundPos = 0;
|
||||
}
|
||||
else
|
||||
breakSearch = true;
|
||||
|
@ -652,7 +668,13 @@ void FTSResultsRequest::checkArticles( QVector< uint32_t > const & offsets,
|
|||
}
|
||||
if( breakSearch )
|
||||
break;
|
||||
pos += s.isEmpty() ? 1 : s.length();
|
||||
if( nextNotFoundPos > 0 && matchWordNom == 0 )
|
||||
{
|
||||
pos = nextNotFoundPos;
|
||||
nextNotFoundPos = 0;
|
||||
}
|
||||
else
|
||||
pos += s.isEmpty() ? 1 : s.length();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue