From 906af435a6c08f9d60989f102f139aad281e60c9 Mon Sep 17 00:00:00 2001 From: choykarl <253440030@qq.com> Date: Mon, 27 Nov 2023 17:33:30 +0800 Subject: [PATCH] optimize judgment --- Easydict/Feature/Service/Bing/EZBingService.m | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/Easydict/Feature/Service/Bing/EZBingService.m b/Easydict/Feature/Service/Bing/EZBingService.m index 454cdc846..95c5525ca 100644 --- a/Easydict/Feature/Service/Bing/EZBingService.m +++ b/Easydict/Feature/Service/Bing/EZBingService.m @@ -91,11 +91,7 @@ - (EZQueryTextType)intelligentQueryTextType { } - (BOOL)isEnglishWordToChinese:(NSString *)text from:(nonnull EZLanguage)from to:(nonnull EZLanguage)to { - BOOL should = [text shouldQueryDictionaryWithLanguage:from maxWordCount:1]; - if (!should) { - return NO; - } - if ([from isEqualToString:EZLanguageEnglish] && [to isEqualToString:EZLanguageSimplifiedChinese]) { + if ([from isEqualToString:EZLanguageEnglish] && [to isEqualToString:EZLanguageSimplifiedChinese] && [text shouldQueryDictionaryWithLanguage:from maxWordCount:1]) { return YES; } return NO; @@ -108,7 +104,7 @@ - (void)translate:(NSString *)text from:(nonnull EZLanguage)from to:(nonnull EZL if ([self isEnglishWordToChinese:text from:from to:to]) { [self.request translateTextFromDict:text completion:^(NSDictionary * _Nullable json, NSError * _Nullable error) { - [self parseBindDictTranslate:json word:text completion:completion]; + [self parseBingDictTranslate:json word:text completion:completion]; }]; return; } @@ -326,7 +322,7 @@ - (void)processWordSimpleWordAndPart:(NSData *)lookupData { } } -- (void)parseBindDictTranslate:(NSDictionary *)json word:(NSString *)word completion:(nonnull void (^)(EZQueryResult *, NSError *_Nullable))completion { +- (void)parseBingDictTranslate:(NSDictionary *)json word:(NSString *)word completion:(nonnull void (^)(EZQueryResult *, NSError *_Nullable))completion { @try { NSArray *value = json[@"value"]; if (value.count == 0) {