mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-24 00:14:06 +00:00
Fix keywords per one article limitation for DSL dictionaries
This commit is contained in:
parent
4bca0270c4
commit
0da4b83dd7
10
dsl.cc
10
dsl.cc
|
@ -577,7 +577,7 @@ void DslDictionary::loadArticle( uint32_t address,
|
|||
|
||||
list< wstring > lst;
|
||||
|
||||
expandOptionalParts( tildeValue, lst );
|
||||
expandOptionalParts( tildeValue, &lst );
|
||||
|
||||
if ( lst.size() ) // Should always be
|
||||
tildeValue = lst.front();
|
||||
|
@ -597,7 +597,7 @@ void DslDictionary::loadArticle( uint32_t address,
|
|||
str = Folding::applySimpleCaseOnly( str );
|
||||
|
||||
list< wstring > lst;
|
||||
expandOptionalParts( str, lst );
|
||||
expandOptionalParts( str, &lst );
|
||||
|
||||
// Does one of the results match the requested word? If so, we'd choose
|
||||
// it as our headword.
|
||||
|
@ -1500,7 +1500,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries(
|
|||
if ( keys.size() )
|
||||
expandTildes( curString, keys.front() );
|
||||
|
||||
expandOptionalParts( curString, keys );
|
||||
expandOptionalParts( curString, &keys );
|
||||
|
||||
if ( !abrvScanner.readNextLine( curString, curOffset ) || curString.empty() )
|
||||
{
|
||||
|
@ -1602,7 +1602,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries(
|
|||
list< wstring > allEntryWords;
|
||||
|
||||
processUnsortedParts( curString, true );
|
||||
expandOptionalParts( curString, allEntryWords );
|
||||
expandOptionalParts( curString, &allEntryWords );
|
||||
|
||||
uint32_t articleOffset = curOffset;
|
||||
|
||||
|
@ -1629,7 +1629,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries(
|
|||
|
||||
processUnsortedParts( curString, true );
|
||||
expandTildes( curString, allEntryWords.front() );
|
||||
expandOptionalParts( curString, allEntryWords );
|
||||
expandOptionalParts( curString, &allEntryWords );
|
||||
}
|
||||
|
||||
if ( !hasString )
|
||||
|
|
|
@ -873,9 +873,13 @@ void processUnsortedParts( wstring & str, bool strip )
|
|||
}
|
||||
}
|
||||
|
||||
void expandOptionalParts( wstring & str, list< wstring > & result,
|
||||
size_t x )
|
||||
void expandOptionalParts( wstring & str, list< wstring > * result,
|
||||
size_t x, bool inside_recurse )
|
||||
{
|
||||
list< wstring > expanded;
|
||||
list< wstring > * headwords;
|
||||
headwords = inside_recurse ? result : &expanded;
|
||||
|
||||
for( ; x < str.size(); )
|
||||
{
|
||||
wchar ch = str[ x ];
|
||||
|
@ -918,7 +922,7 @@ void expandOptionalParts( wstring & str, list< wstring > & result,
|
|||
wstring removed( str, 0, x );
|
||||
removed.append( str, y + 1, str.size() - y - 1 );
|
||||
|
||||
expandOptionalParts( removed, result, x );
|
||||
expandOptionalParts( removed, headwords, x, true );
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -933,10 +937,14 @@ void expandOptionalParts( wstring & str, list< wstring > & result,
|
|||
wstring removed( str, 0, x );
|
||||
|
||||
// Limit the amount of results to avoid excessive resource consumption
|
||||
if ( result.size() < 32 )
|
||||
result.push_back( removed );
|
||||
if ( headwords->size() < 32 )
|
||||
headwords->push_back( removed );
|
||||
else
|
||||
{
|
||||
if( !inside_recurse )
|
||||
result->merge( expanded );
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -956,8 +964,10 @@ void expandOptionalParts( wstring & str, list< wstring > & result,
|
|||
}
|
||||
|
||||
// Limit the amount of results to avoid excessive resource consumption
|
||||
if ( result.size() < 32 )
|
||||
result.push_back( str );
|
||||
if ( headwords->size() < 32 )
|
||||
headwords->push_back( str );
|
||||
if( !inside_recurse )
|
||||
result->merge( expanded );
|
||||
}
|
||||
|
||||
void expandTildes( wstring & str, wstring const & tildeReplacement )
|
||||
|
|
|
@ -161,8 +161,8 @@ void processUnsortedParts( wstring & str, bool strip );
|
|||
|
||||
/// Expands optional parts of a headword (ones marked with parentheses),
|
||||
/// producing all possible combinations where they are present or absent.
|
||||
void expandOptionalParts( wstring & str, list< wstring > & result,
|
||||
size_t x = 0 );
|
||||
void expandOptionalParts( wstring & str, list< wstring > * result,
|
||||
size_t x = 0, bool inside_recurse = false );
|
||||
|
||||
/// Expands all unescaped tildes, inserting tildeReplacement text instead of
|
||||
/// them.
|
||||
|
|
Loading…
Reference in a new issue