fix:epwing performance improvement.

the head correction process seems takes too much time. The headword is returned by epwing api ,  there is no need to verify the headword again .
And at some cases , the headword verification never works.
This commit is contained in:
Xiao YiFang 2022-10-05 15:05:04 +08:00
parent a9b3a64f05
commit 53ce63fbf5
2 changed files with 24 additions and 22 deletions

View file

@ -1032,42 +1032,44 @@ void EpwingBook::fixHeadword( QString & headword )
headword.remove( QChar( 0x30FB ) ); // Used in Japan transcription headword.remove( QChar( 0x30FB ) ); // Used in Japan transcription
if( isHeadwordCorrect( headword) ) //if( isHeadwordCorrect( headword) )
return; // return;
QString fixed = headword; QString fixed = headword;
QRegularExpression leadingSlashRx( "/[^/]+/" ); QRegularExpression leadingSlashRx( "/[^/]+/" );
fixed.remove(leadingSlashRx ); fixed.remove(leadingSlashRx );
if( isHeadwordCorrect( fixed ) ) //if( isHeadwordCorrect( fixed ) )
{ //{
headword = fixed; // headword = fixed;
return; // return;
} //}
gd::wstring folded = Folding::applyPunctOnly( gd::toWString( fixed ) ); gd::wstring folded = Folding::applyPunctOnly( gd::toWString( fixed ) );
fixed = gd::toQString( folded ); fixed = gd::toQString( folded );
if( isHeadwordCorrect( fixed ) ) //if( isHeadwordCorrect( fixed ) )
{ //{
headword = fixed; // headword = fixed;
return; // return;
} //}
folded = Folding::applyDiacriticsOnly( folded ); folded = Folding::applyDiacriticsOnly( folded );
fixed = gd::toQString( folded ); fixed = gd::toQString( folded );
if( isHeadwordCorrect( fixed ) ) //if( isHeadwordCorrect( fixed ) )
{ //{
headword = fixed; // headword = fixed;
return; // return;
} //}
folded = Folding::applyWhitespaceOnly( folded ); //folded = Folding::applyWhitespaceOnly( folded );
fixed = gd::toQString( folded ); //fixed = gd::toQString( folded );
if( isHeadwordCorrect( fixed ) ) //if( isHeadwordCorrect( fixed ) )
headword = fixed; // headword = fixed;
headword = fixed;
} }
void EpwingBook::getArticle( QString & headword, QString & articleText, void EpwingBook::getArticle( QString & headword, QString & articleText,

View file

@ -596,7 +596,7 @@ bool isPunct( wchar ch )
case 0xFF64: // HALFWIDTH IDEOGRAPHIC COMMA case 0xFF64: // HALFWIDTH IDEOGRAPHIC COMMA
return true; return true;
default: default:
return false; return QChar::isPunct(ch)||QChar::isSymbol(ch);
} }
} }