From 32689d71ad400343d57836704fb25cad900a4401 Mon Sep 17 00:00:00 2001 From: Xiao YiFang Date: Wed, 5 Oct 2022 16:33:59 +0800 Subject: [PATCH 1/2] fix: epwing remove unused parameter --- epwing.cc | 24 +++++------------------- epwing_book.cc | 2 +- epwing_book.hh | 2 +- 3 files changed, 7 insertions(+), 21 deletions(-) diff --git a/epwing.cc b/epwing.cc index d61ad57d..771496e8 100644 --- a/epwing.cc +++ b/epwing.cc @@ -173,8 +173,7 @@ private: string & articleHeadword, string & articleText, int & articlePage, - int & articleOffset, - QString word = 0 ); + int & articleOffset ); void loadArticle( int articlePage, int articleOffset, string & articleHeadword, string & articleText ); @@ -287,16 +286,8 @@ void EpwingDictionary::removeDirectory( QString const & directory ) dir.rmdir( directory ); } -void EpwingDictionary::loadArticle( quint32 address, - - string & articleHeadword, - - string & articleText, - - int & articlePage, - - int & articleOffset, - QString word) +void EpwingDictionary::loadArticle( + quint32 address, string & articleHeadword, string & articleText, int & articlePage, int & articleOffset ) { vector< char > chunk; @@ -316,7 +307,7 @@ void EpwingDictionary::loadArticle( quint32 address, try { Mutex::Lock _( eBook.getLibMutex() ); - eBook.getArticle( headword, text, articlePage, articleOffset, false, word ); + eBook.getArticle( headword, text, articlePage, articleOffset, false); } catch( std::exception & e ) { @@ -531,15 +522,10 @@ void EpwingArticleRequest::run() try { dict.loadArticle( chain[ x ].articleOffset, - headword, - articleText, - articlePage, - - articleOffset, - gd::toQString(word) ); + articleOffset ); } catch(...) { diff --git a/epwing_book.cc b/epwing_book.cc index 2e89be1d..21e1244e 100644 --- a/epwing_book.cc +++ b/epwing_book.cc @@ -1073,7 +1073,7 @@ void EpwingBook::fixHeadword( QString & headword ) } void EpwingBook::getArticle( QString & headword, QString & articleText, - int page, int offset, bool text_only, QString word) + int page, int offset, bool text_only) { error_string.clear(); char buffer[ TextBufferSize + 1 ]; diff --git a/epwing_book.hh b/epwing_book.hh index e5b00f0f..25b29c92 100644 --- a/epwing_book.hh +++ b/epwing_book.hh @@ -195,7 +195,7 @@ public: // Retrieve article from dictionary void getArticle( QString & headword, QString & articleText, - int page, int offset, bool text_only, QString word=0 ); + int page, int offset, bool text_only ); const char * beginDecoration( unsigned int code ); const char * endDecoration( unsigned int code ); From 53c1db8eaf17564fbe66fea85fbcde3aebf9cc07 Mon Sep 17 00:00:00 2001 From: Xiao YiFang Date: Wed, 5 Oct 2022 20:00:23 +0800 Subject: [PATCH 2/2] fix: epwing dictionary headword correction MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit such as headword "1gulp n. →" was corrected as " gulp n " --- epwing_book.cc | 5 ++++- folding.cc | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/epwing_book.cc b/epwing_book.cc index 21e1244e..8477916d 100644 --- a/epwing_book.cc +++ b/epwing_book.cc @@ -1032,6 +1032,9 @@ void EpwingBook::fixHeadword( QString & headword ) headword.remove( QChar( 0x30FB ) ); // Used in Japan transcription + //replace any unicode Number ,Symbol ,Punctuation ,Mark character to whitespace + headword.replace( QRegularExpression( "[\\p{N}\\p{S}\\p{P}\\p{M}]" ), " " ); + //if( isHeadwordCorrect( headword) ) // return; @@ -1046,7 +1049,7 @@ void EpwingBook::fixHeadword( QString & headword ) //} gd::wstring folded = Folding::applyPunctOnly( gd::toWString( fixed ) ); - fixed = gd::toQString( folded ); + //fixed = gd::toQString( folded ); //if( isHeadwordCorrect( fixed ) ) //{ diff --git a/folding.cc b/folding.cc index 9cbeb136..6136b817 100644 --- a/folding.cc +++ b/folding.cc @@ -596,7 +596,7 @@ bool isPunct( wchar ch ) case 0xFF64: // HALFWIDTH IDEOGRAPHIC COMMA return true; default: - return QChar::isPunct(ch)||QChar::isSymbol(ch); + return false; } }