CNS // Phase 6: Unit Tests to make sure CSV loads.
This commit is contained in:
parent
2a0c088fcd
commit
50cdb6be6c
|
@ -169,7 +169,8 @@ static double FindHighestScore(const vector<NodeAnchor>& nodes, double epsilon)
|
|||
[menu addItemWithTitle:NSLocalizedString(@"About vChewing…", @"") action:@selector(showAbout:) keyEquivalent:@""];
|
||||
if (optionKeyPressed) {
|
||||
[menu addItemWithTitle:NSLocalizedString(@"Reboot vChewing…", @"") action:@selector(selfTerminate:) keyEquivalent:@""];
|
||||
[menu addItemWithTitle:NSLocalizedString(@"Deploy Zip Data…", @"") action:@selector(cnsDeploy:) keyEquivalent:@""];
|
||||
[menu addItemWithTitle:NSLocalizedString(@"Deploy CNS Data…", @"") action:@selector(cnsDeploy:) keyEquivalent:@""];
|
||||
[menu addItemWithTitle:NSLocalizedString(@"Load CNS Data…", @"") action:@selector(loadCNSData:) keyEquivalent:@""];
|
||||
}
|
||||
return menu;
|
||||
}
|
||||
|
@ -1551,6 +1552,16 @@ NS_INLINE size_t max(size_t a, size_t b) { return a > b ? a : b; }
|
|||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)_checkCNSFile
|
||||
{
|
||||
if (![LanguageModelManager checkIfCNSDataExistAndHashMatched]) {
|
||||
[self beep];
|
||||
NSLog(@"_checkCNSFile failed in the InputMethodController.");
|
||||
return NO;
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)cnsDeploy:(id)sender
|
||||
{
|
||||
[LanguageModelManager deployZipDataFile:@"UNICHARS"];
|
||||
|
@ -1586,6 +1597,15 @@ NS_INLINE size_t max(size_t a, size_t b) { return a > b ? a : b; }
|
|||
[LanguageModelManager loadUserPhraseReplacement];
|
||||
}
|
||||
|
||||
- (void)loadCNSData:(id)sender
|
||||
{
|
||||
if (!self._checkCNSFile) {
|
||||
[self beep];
|
||||
} else {
|
||||
[LanguageModelManager loadCNSData];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)showAbout:(id)sender
|
||||
{
|
||||
// show the About window, and also make the IME app itself the focus
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#import "UserOverrideModel.h"
|
||||
#import "vChewingLM.h"
|
||||
#import "SSZipArchive.h"
|
||||
#import "AWFileHash.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#import <set>
|
||||
#import "OVStringHelper.h"
|
||||
#import "OVUTF8Helper.h"
|
||||
#import "AWFileHash.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace Taiyan::Gramambular;
|
||||
|
@ -74,7 +73,9 @@ static void LTLoadLanguageModelFile(NSString *filenameWithoutExtension, vChewing
|
|||
NSLog(@"Extracted CNS Data Not Found.");
|
||||
return NO;
|
||||
}
|
||||
if ([AWFileHash md5HashOfFileAtPath:[self cnsDataPath]] != [[NSUserDefaults standardUserDefaults] objectForKey:kMD5HashCNSData]) {
|
||||
if (![[AWFileHash md5HashOfFileAtPath:[self cnsDataPath]] isEqualToString: [[NSUserDefaults standardUserDefaults] objectForKey:kMD5HashCNSData]]) {
|
||||
NSLog(@"Existing CNS CSV Data Fingerprint: %@", [AWFileHash md5HashOfFileAtPath:[self cnsDataPath]]);
|
||||
NSLog(@"UserPlist CNS CSV Data Fingerprint: %@", [[NSUserDefaults standardUserDefaults] objectForKey:kMD5HashCNSData]);
|
||||
NSLog(@"Existing CNS CSV Data fingerprint mismatch, must be tampered since it gets extracted.");
|
||||
return NO;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue