mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-24 04:24:09 +00:00
opt: stardict's findHeadwordsForSynonym method does not seem necessary
🎨 apply clang-format changes 🎨 apply clang-format changes
This commit is contained in:
parent
d9b81e7a68
commit
9ca02a1e23
|
@ -64,7 +64,8 @@ void BtreeIndex::openIndex( IndexInfo const & indexInfo, File::Class & file, QMu
|
|||
rootNode.clear();
|
||||
}
|
||||
|
||||
vector< WordArticleLink > BtreeIndex::findArticles( wstring const & search_word, bool ignoreDiacritics )
|
||||
vector< WordArticleLink >
|
||||
BtreeIndex::findArticles( wstring const & search_word, bool ignoreDiacritics, uint32_t maxMatchCount )
|
||||
{
|
||||
//First trim ending zero
|
||||
wstring word = gd::removeTrailingZero( search_word );
|
||||
|
@ -89,7 +90,7 @@ vector< WordArticleLink > BtreeIndex::findArticles( wstring const & search_word,
|
|||
|
||||
if ( chainOffset && exactMatch )
|
||||
{
|
||||
result = readChain( chainOffset );
|
||||
result = readChain( chainOffset, maxMatchCount );
|
||||
|
||||
antialias( word, result, ignoreDiacritics );
|
||||
}
|
||||
|
@ -108,6 +109,7 @@ vector< WordArticleLink > BtreeIndex::findArticles( wstring const & search_word,
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
BtreeWordSearchRequest::BtreeWordSearchRequest( BtreeDictionary & dict_,
|
||||
wstring const & str_,
|
||||
unsigned minLength_,
|
||||
|
@ -752,7 +754,7 @@ char const * BtreeIndex::findChainOffsetExactOrPrefix( wstring const & target,
|
|||
}
|
||||
}
|
||||
|
||||
vector< WordArticleLink > BtreeIndex::readChain( char const * & ptr )
|
||||
vector< WordArticleLink > BtreeIndex::readChain( char const *& ptr, uint32_t maxMatchCount )
|
||||
{
|
||||
uint32_t chainSize;
|
||||
|
||||
|
@ -762,8 +764,7 @@ vector< WordArticleLink > BtreeIndex::readChain( char const * & ptr )
|
|||
|
||||
vector< WordArticleLink > result;
|
||||
|
||||
while( chainSize )
|
||||
{
|
||||
while ( chainSize && ( maxMatchCount < 0 || result.size() < maxMatchCount ) ) {
|
||||
string str = ptr;
|
||||
ptr += str.size() + 1;
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ public:
|
|||
|
||||
/// Finds articles that match the given string. A case-insensitive search
|
||||
/// is performed.
|
||||
vector< WordArticleLink > findArticles( wstring const &, bool ignoreDiacritics = false );
|
||||
vector< WordArticleLink > findArticles( wstring const &, bool ignoreDiacritics = false, uint32_t maxMatchCount = -1 );
|
||||
|
||||
/// Find all unique article links in the index
|
||||
void findAllArticleLinks( QVector< WordArticleLink > & articleLinks );
|
||||
|
@ -133,7 +133,7 @@ protected:
|
|||
|
||||
/// Reads the word-article links' chain at the given offset. The pointer
|
||||
/// is updated to point to the next chain, if there's any.
|
||||
vector< WordArticleLink > readChain( char const * & );
|
||||
vector< WordArticleLink > readChain( char const *&, uint32_t maxMatchCount = -1 );
|
||||
|
||||
/// Drops any aliases which arose due to folding. Only case-folded aliases
|
||||
/// are left.
|
||||
|
|
|
@ -1258,7 +1258,8 @@ void StardictHeadwordsRequest::run()
|
|||
|
||||
try
|
||||
{
|
||||
vector< WordArticleLink > chain = dict.findArticles( word );
|
||||
//limited the synomys to at most 10 entries
|
||||
vector< WordArticleLink > chain = dict.findArticles( word, false, 10 );
|
||||
|
||||
wstring caseFolded = Folding::applySimpleCaseOnly( word );
|
||||
|
||||
|
@ -1295,11 +1296,9 @@ void StardictHeadwordsRequest::run()
|
|||
finish();
|
||||
}
|
||||
|
||||
sptr< Dictionary::WordSearchRequest >
|
||||
StardictDictionary::findHeadwordsForSynonym( wstring const & word )
|
||||
|
||||
sptr< Dictionary::WordSearchRequest > StardictDictionary::findHeadwordsForSynonym( wstring const & word )
|
||||
{
|
||||
return synonymSearchEnabled ? std::make_shared<StardictHeadwordsRequest>( word, *this ) :
|
||||
return synonymSearchEnabled ? std::make_shared< StardictHeadwordsRequest >( word, *this ) :
|
||||
Class::findHeadwordsForSynonym( word );
|
||||
}
|
||||
|
||||
|
@ -1371,10 +1370,9 @@ void StardictArticleRequest::run()
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
multimap< wstring, pair< string, string > > mainArticles, alternateArticles;
|
||||
|
||||
set< uint32_t > articlesIncluded; // Some synonms make it that the articles
|
||||
set< uint32_t > articlesIncluded; // Some synonyms make it that the articles
|
||||
// appear several times. We combat this
|
||||
// by only allowing them to appear once.
|
||||
|
||||
|
|
Loading…
Reference in a new issue