Skip to content

Commit

Permalink
optimize judgment
Browse files Browse the repository at this point in the history
  • Loading branch information
choykarl committed Nov 27, 2023
1 parent 6b661b6 commit 906af43
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions Easydict/Feature/Service/Bing/EZBingService.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 906af43

Please sign in to comment.