Skip to content

Commit

Permalink
perf: do not query Chinese dict if text is English words
Browse files Browse the repository at this point in the history
  • Loading branch information
tisfeng committed Dec 18, 2023
1 parent 706dc88 commit 17d2340
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions Easydict/Feature/Service/Apple/EZAppleService.m
Original file line number Diff line number Diff line change
Expand Up @@ -505,10 +505,19 @@ - (EZLanguage)detectTextLanguage:(NSString *)text printLog:(BOOL)logFlag {

// TODO: Maybe we can use this way to detect other language.

NSArray *needCorrectedLanguages = @[
NSMutableArray *needCorrectedLanguages = @[
EZLanguageEnglish, // si
EZLanguageSimplifiedChinese, //
];
].mutableCopy;

/**
Fix: cuda was detectde as SimplifiedChinese, --> 粗大 cuda
Apple spell check 'cuda' as English, but sometimes Spanish 🥲
*/
if (![text isEnglishPhrase]) {
// 浦 was detected as Japanese, we need to correct it.
[needCorrectedLanguages addObject:EZLanguageSimplifiedChinese];
}

BOOL isWordLength = text.length <= EZEnglishWordMaxLength;

Expand Down

0 comments on commit 17d2340

Please sign in to comment.