Skip to content

Commit

Permalink
fix: check isEnglishWord method is wrong
Browse files Browse the repository at this point in the history
  • Loading branch information
tisfeng committed Feb 25, 2024
1 parent 401bba0 commit 1eaa5ab
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Easydict/Feature/Service/Apple/EZAppleService.m
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ - (EZLanguage)getMostConfidentLanguage:(NSDictionary<NLLanguage, NSNumber *> *)d
}
}
}
NSLog(@"Spell check failed, use Most Confident Language: %@", ezLanguage);
NSLog(@"No spell checking, use Most Confident Language: %@", ezLanguage);

return ezLanguage;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ static NSArray *const EZDashCharacterList = @[ @"—", @"-", @"–" ];

- (BOOL)isEnglishWordWithLanguage:(EZLanguage)language;

/// Just use regex to check English word, ^[a-zA-Z]+$
- (BOOL)isEnglishWord;

- (BOOL)isEnglishWordWithMaxWordLength:(NSUInteger)maxWordLength;
Expand Down
15 changes: 5 additions & 10 deletions Easydict/Feature/Utility/EZCategory/NSString/NSString+EZUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -246,16 +246,11 @@ - (BOOL)isEnglishWordWithMaxWordLength:(NSUInteger)maxWordLength {
}

- (BOOL)isEnglishPhrase {
if (self.length > EZEnglishWordMaxLength) {
return NO;
}

NSInteger wordCount = [self wordCount];
if (wordCount <= 2) {
return YES;
}

return NO;
// hello word
NSString *text = [self stringByReplacingOccurrencesOfString:@" " withString:@""];
BOOL isEnglishPhraseLength = [text isEnglishWordWithMaxWordLength:EZEnglishWordMaxLength * 2];
BOOL isPhraseWordCount = [self wordCount] <= 2;
return isEnglishPhraseLength && isPhraseWordCount;
}

- (BOOL)isWord {
Expand Down

0 comments on commit 1eaa5ab

Please sign in to comment.