Math

Resources Rules: Columnar operations

Why is the 'Columnar operations' rule not included in the Maths ATK? Seems I would need that to setup adding / subtracting numbers using the arithmetic model.


Our new ATK and CDK offers are currently based on the same recognition engine, however, ATK has not been yet fully updated to support of all new Mathematical grammar notations.
Rest assured that we will communicate as soon as we will have news for you.
Best regards

Apologies in advance probably should go in Text forum group.

I'm trying to solve the issue by using an array of SCWSingleCharWidget from the ATK2.0 frameworks. Unfortunately I receive this error from the widgets delegate, Error Code:7 cannot create handwriting recogniser.

I locate the bundle path:

NSString *bundlePath = [[NSBundle mainBundle] pathForResource:@resources ofType:@bundle];
bundlePath = [bundlePath stringByAppendingPathComponent:@conf];

then create the array of widgets in a loop statement.

currentSingleCharWidget = [[SCWSingleCharWidget alloc] initWithFrame:CGRectMake(widgetXOrigin, widgetYOrigin, widgetWidth, widgetHeight)];
[currentSingleCharWidget setWordCandidateListSize:5];
[currentSingleCharWidget setCharacterCandidateListSize:1];
[currentSingleCharWidget addSearchDir:bundlePath];
[currentSingleCharWidget configureWithBundle:@en_US andConfig:@si_text];
currentSingleCharWidget.userInteractionEnabled = YES;
currentSingleCharWidget.autoCommitEnabled = NO;
currentSingleCharWidget.delegate = self;
currentSingleCharWidget.backgroundColor = [UIColor colorWithPatternImage:backgroundPattern];
currentSingleCharWidget.layer.borderWidth = 1.0;
currentSingleCharWidget.layer.borderColor = [[UIColor blueColor] CGColor];
currentSingleCharWidget.layer.cornerRadius=0.0f;
currentSingleCharWidget.layer.masksToBounds=NO;
currentSingleCharWidget.layer.edgeAntialiasingMask = kCALayerLeftEdge | kCALayerTopEdge;
currentSingleCharWidget.alpha=0.8;
[_containerView addSubview:currentSingleCharWidget];

Using the Simulator I see the bundle resources are correctly located, so should be available to the widget.


I also check to see widget is registered

if (![currentSingleCharWidget registerCertificate:certificate])
{
UIAlertController *alertController = [UIAlertController
alertControllerWithTitle:@Invalid certificate
message:@Please use a valid certificate.
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *okAction = [UIAlertAction
actionWithTitle:@Ok
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * _Nonnull action) {
exit(-1);
}];
[alertController addAction:okAction];
[self presentViewController:alertController animated:YES completion:nil];
}

From your ATK Dashboard, I can see that you were able to run it once today. Could you please confirm the error occurs with ATK iOS 2? Do you use the same certificate than for your previous project? Did you enable internet connection on this device?
Best regards

Yes, I am definitely using ATK 2.0. I use the same certificate from a previous project yet I give the new project the same Bundle Identifier. The device is a Simulator and my laptop is always connected to the internet. I am able to run the SCWSingleCharacterWidget example without problems.

Now I see this error from - (void)singleCharWidget:(SCWSingleCharWidget *)sender didConfigureWithSuccess:(BOOL)success.....Error Code:3 cannot load handwriting resource.

I get the bundlepath and check the handwriting resources are there, as I checked with the sample project.
Instead of using an array of widgets, I have tried loading just one, which result in the same error code.

We have been able to reproduce this behavior on our side and to find a workaround. Could you please try to had a short delay between each call to the 'registerCertificate' method, by adding this for instance:
[NSThread sleepForTimeInterval:0.02];
It could be added in the loop just after the configure or at the end; every instance of the widget should then be properly configured.

Please let us know if it works properly on your side.

Best regards

I've place the code within the loop to setup this array of SCWSingleCharacterWidget to no avail.

`
- (BOOL)setupForCurrentProblem
{
BOOL speakWord = YES;
MathsAnswers *answer = (MathsAnswers*)[currentMathsProblemsAnswersList objectAtIndex:currentProblemIndex];
if([answer.Correct boolValue])
{
[self nextProblem:self];
speakWord = NO;
}
self.problemLabel.text = (NSString*)[(NSDictionary*)[currentMathsProblemsList objectAtIndex:currentProblemIndex] objectForKey:kProblemStatementKey];

[_problemNumberLabel setText:[NSString stringWithFormat:NSLocalizedStringFromTable(@Problem N°%ld, @MathsProblemsLocalizable, nil), (long)currentProblemIndex+1]];

NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
[formatter setNumberStyle:NSNumberFormatterNoStyle];

NSNumber *numericTopLine = [formatter numberFromString:(NSString*)[(NSDictionary*)[currentMathsProblemsList objectAtIndex:currentProblemIndex] objectForKey:kTopLineKey]];
NSNumber *numericBtmLine = [formatter numberFromString:(NSString*)[(NSDictionary*)[currentMathsProblemsList objectAtIndex:currentProblemIndex] objectForKey:kBottomLineKey]];

double top = [numericTopLine doubleValue];
double btm = [numericBtmLine doubleValue];
_numberanswer = 0.0;
if([(NSString*)[(NSDictionary*)[currentMathsProblemsList objectAtIndex:currentProblemIndex] objectForKey:kOperatorKey] isEqualToString:@+])
_numberanswer = top + btm;
else if([(NSString*)[(NSDictionary*)[currentMathsProblemsList objectAtIndex:currentProblemIndex] objectForKey:kOperatorKey] isEqualToString:@-])
_numberanswer = top - btm;
else if([(NSString*)[(NSDictionary*)[currentMathsProblemsList objectAtIndex:currentProblemIndex] objectForKey:kOperatorKey] isEqualToString:@x])
_numberanswer = top * btm;
else if([(NSString*)[(NSDictionary*)[currentMathsProblemsList objectAtIndex:currentProblemIndex] objectForKey:kOperatorKey] isEqualToString:@÷])
_numberanswer = top / btm;
else
;

NSNumber *numericAnswer = [NSNumber numberWithDouble:_numberanswer];
NSString *stringAnswer = [formatter stringForObjectValue:numericAnswer];

if(DictArraySingleCharWidgets)
[self clearWidgetArray];

DictArraySingleCharWidgets = [NSMutableArray arrayWithCapacity:[(NSString*)[(NSDictionary*)[currentMathsProblemsList objectAtIndex:currentProblemIndex] objectForKey:kTopLineKey] length] + [(NSString*)[(NSDictionary*)[currentMathsProblemsList objectAtIndex:currentProblemIndex] objectForKey:kBottomLineKey] length] + 1 + [stringAnswer length]];
;

NSString *path = [[NSBundle mainBundle] bundlePath];
NSString *finalPath = [path stringByAppendingPathComponent:@maw_DefaultBackgroundPattern@2x.png];
UIImage *backgroundPattern = [UIImage imageWithContentsOfFile:finalPath];

CGFloat widgetWidth = 0.0, widgetHeight = 0.0;
widgetWidth = _containerView.frame.size.width / (CGFloat)[stringAnswer length] - 2.0;
widgetHeight = _containerView.frame.size.height / (CGFloat)3 - 2.0;
CGFloat widgetXOrigin = 0.0, widgetYOrigin = 1.0;
if([(NSString*)[(NSDictionary*)[currentMathsProblemsList objectAtIndex:currentProblemIndex] objectForKey:kTopLineKey] length] < [stringAnswer length])
widgetXOrigin = (CGFloat)([stringAnswer length] - [(NSString*)[(NSDictionary*)[currentMathsProblemsList objectAtIndex:currentProblemIndex] objectForKey:kTopLineKey] length]) * widgetWidth + 1.0;

for(NSInteger i = 0; i < [(NSString*)[(NSDictionary*)[currentMathsProblemsList objectAtIndex:currentProblemIndex] objectForKey:kTopLineKey] length]; i++)
{
currentSingleCharWidget = [[SCWSingleCharWidget alloc] initWithFrame:CGRectMake(widgetXOrigin, widgetYOrigin, widgetWidth, widgetHeight)];
widgetXOrigin += widgetWidth + 1.0;
[DictArraySingleCharWidgets addObject:[NSDictionary dictionaryWithObjectsAndKeys:currentSingleCharWidget, kObjectKey, [NSString stringWithFormat:@%ld, i], kXKey, @0, kYKey, nil]];

if (![currentSingleCharWidget registerCertificate:certificate])
{
UIAlertController *alertController = [UIAlertController
alertControllerWithTitle:@Invalid certificate
message:@Please use a valid certificate.
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *okAction = [UIAlertAction
actionWithTitle:@Ok
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * _Nonnull action) {
exit(-1);
}];
[alertController addAction:okAction];
[self presentViewController:alertController animated:YES completion:nil];
}
[NSThread sleepForTimeInterval:0.5];
[currentSingleCharWidget setInkColor:[UIColor colorWithRed:0.200f green:0.710f blue:0.898f alpha:1.0f]];
[currentSingleCharWidget setInkWidth:7.0f];
[currentSingleCharWidget setWordCandidateListSize:5];
[currentSingleCharWidget setCharacterCandidateListSize:1];
[currentSingleCharWidget addSearchDir:bundlePath];
[currentSingleCharWidget configureWithBundle:@en_US andConfig:@iso_number];
currentSingleCharWidget.userInteractionEnabled = YES;
currentSingleCharWidget.autoCommitEnabled = NO;
currentSingleCharWidget.delegate = self;
currentSingleCharWidget.backgroundColor = [UIColor colorWithPatternImage:backgroundPattern];
currentSingleCharWidget.layer.borderWidth = 1.0;
currentSingleCharWidget.layer.borderColor = [[UIColor blueColor] CGColor];
currentSingleCharWidget.layer.cornerRadius=0.0f;
currentSingleCharWidget.layer.masksToBounds=NO;
currentSingleCharWidget.layer.edgeAntialiasingMask = kCALayerLeftEdge | kCALayerTopEdge;
currentSingleCharWidget.alpha=1.0;
[_containerView addSubview:currentSingleCharWidget];
}
widgetXOrigin = 0.0;
if([(NSString*)[(NSDictionary*)[currentMathsProblemsList objectAtIndex:currentProblemIndex] objectForKey:kBottomLineKey] length] < [stringAnswer length])
widgetXOrigin = (CGFloat)([stringAnswer length] - [(NSString*)[(NSDictionary*)[currentMathsProblemsList objectAtIndex:currentProblemIndex] objectForKey:kBottomLineKey] length]) * widgetWidth + 1.0;
widgetYOrigin+= widgetHeight + 1.0;
for(NSInteger i = 0; i < [(NSString*)[(NSDictionary*)[currentMathsProblemsList objectAtIndex:currentProblemIndex] objectForKey:kBottomLineKey] length] + 1; i++)
{
currentSingleCharWidget = [[SCWSingleCharWidget alloc] initWithFrame:CGRectMake(widgetXOrigin, widgetYOrigin, widgetWidth, widgetHeight)];
widgetXOrigin += widgetWidth + 1.0;
[DictArraySingleCharWidgets addObject:[NSDictionary dictionaryWithObjectsAndKeys:currentSingleCharWidget, kObjectKey, [NSString stringWithFormat:@%ld, i], kXKey, @1, kYKey, nil]];
if (![currentSingleCharWidget registerCertificate:certificate])
{
UIAlertController *alertController = [UIAlertController
alertControllerWithTitle:@Invalid certificate
message:@Please use a valid certificate.
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *okAction = [UIAlertAction
actionWithTitle:@Ok
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * _Nonnull action) {
exit(-1);
}];
[alertController addAction:okAction];
[self presentViewController:alertController animated:YES completion:nil];
}
[NSThread sleepForTimeInterval:0.5];
[currentSingleCharWidget setInkColor:[UIColor colorWithRed:0.200f green:0.710f blue:0.898f alpha:1.0f]];
[currentSingleCharWidget setInkWidth:7.0f];
[currentSingleCharWidget setWordCandidateListSize:5];
[currentSingleCharWidget setCharacterCandidateListSize:1];
[currentSingleCharWidget addSearchDir:bundlePath];
[currentSingleCharWidget configureWithBundle:@en_US andConfig:@iso_number];
currentSingleCharWidget.autoCommitEnabled = NO;
currentSingleCharWidget.delegate = self;
currentSingleCharWidget.backgroundColor = [UIColor colorWithPatternImage:backgroundPattern];
currentSingleCharWidget.layer.borderWidth = 1.0;
currentSingleCharWidget.layer.borderColor = [[UIColor blueColor] CGColor];
currentSingleCharWidget.layer.cornerRadius=0.0f;
currentSingleCharWidget.layer.masksToBounds=NO;
currentSingleCharWidget.layer.edgeAntialiasingMask = kCALayerLeftEdge | kCALayerTopEdge;
currentSingleCharWidget.alpha=1.0;
[_containerView addSubview:currentSingleCharWidget];
}
widgetXOrigin = 0.0;
widgetYOrigin+= widgetHeight + 1.0;
for(NSInteger i = 0; i < [stringAnswer length]; i++)
{
currentSingleCharWidget = [[SCWSingleCharWidget alloc] initWithFrame:CGRectMake(widgetXOrigin, widgetYOrigin, widgetWidth, widgetHeight)];
widgetXOrigin += widgetWidth + 1.0;
[DictArraySingleCharWidgets addObject:[NSDictionary dictionaryWithObjectsAndKeys:currentSingleCharWidget, kObjectKey, [NSString stringWithFormat:@%ld, i], kXKey, @2, kYKey, nil]];
if (![currentSingleCharWidget registerCertificate:certificate])
{
UIAlertController *alertController = [UIAlertController
alertControllerWithTitle:@Invalid certificate
message:@Please use a valid certificate.
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *okAction = [UIAlertAction
actionWithTitle:@Ok
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * _Nonnull action) {
exit(-1);
}];
[alertController addAction:okAction];
[self presentViewController:alertController animated:YES completion:nil];
}
[NSThread sleepForTimeInterval:0.5];
[currentSingleCharWidget setInkColor:[UIColor colorWithRed:0.200f green:0.710f blue:0.898f alpha:1.0f]];
[currentSingleCharWidget setInkWidth:7.0f];
[currentSingleCharWidget setWordCandidateListSize:5];
[currentSingleCharWidget setCharacterCandidateListSize:1];
[currentSingleCharWidget addSearchDir:bundlePath];
[currentSingleCharWidget configureWithBundle:@en_US andConfig:@iso_number];
currentSingleCharWidget.autoCommitEnabled = NO;
currentSingleCharWidget.delegate = self;
currentSingleCharWidget.backgroundColor = [UIColor colorWithPatternImage:backgroundPattern];
currentSingleCharWidget.layer.borderWidth = 1.0;
currentSingleCharWidget.layer.borderColor = [[UIColor blueColor] CGColor];
currentSingleCharWidget.layer.cornerRadius=0.0f;
currentSingleCharWidget.layer.masksToBounds=YES;
currentSingleCharWidget.layer.edgeAntialiasingMask = kCALayerLeftEdge | kCALayerTopEdge;
currentSingleCharWidget.alpha=1.0;
[_containerView addSubview:currentSingleCharWidget];
}

return speakWord;
}

I even increased the time.

I see in your documentation: Configuration is a lengthy process that may take up to several seconds, depending on the handwriting resources to be configured. It is recommended to setup a configuration listener to detect the end of the configuration process.

Could you please make sure which configuration you need?
[currentSingleCharWidget configureWithBundle:@”en_US” andConfig:@”iso_number”];
There’s no iso_number mode in the conf file of EN_US package, you can use cur_number instead for instance.

Do you still have the same error? ‘Now I see this error from – (void)singleCharWidget:(SCWSingleCharWidget *)sender didConfigureWithSuccess:(BOOL)success…..Error Code:3 cannot load handwriting resource.’
Best regards

Look I tried with 'cur_number' previously and had the same errors.

I've created an 'iso_number' already which should be available within my version en_us.conf:

Name: iso_number
Type: Text
Configuration-Script:
AddResource en_US/en_US-ak-iso.lite.res
AddResource mul/mul-lk-gesture.res
AddResource mul/mul-lk-number.res
SetWordListSize 5


This is not the reason it's failing to load the handwriting resource.

Thanks for your testing and feedback. Actually, we have been able to run your code successfully on our side with 3x5 SingleCharWidget instances.
Do you any other idea of what is different with your project and the sample, so we can do additional testing?
Best regards

What I need to know is what conditions would cause your software to generate Error code 3, as the widget passes the registration, but fails on configuration. The sample works perfectly. The widgets actually work in terms of handwriting but obviously no recognition.

This error could be due to several causes:
- difference between '.conf' file and content of 'bundle resources' package
- wrong permissions to access resource files
- missing files in the resource package

The easiest way to move forward would be by providing us with your bundle resources package, so we can check and test it (using a Dropbox link or similar tool for instance).
Best regards

It's working!!
I originally copied the resources.bundle from the sample to the my project directory, but now I have linked the resources.bundle to my project from the samples project. I have to slow the [NSThread sleepForTimeInterval:0.1]; more than you recommended, as a couple of the widgets in the array don't load resource.
Why would my linking to sample instead of a copy make the difference?

appreciate your help over the last few days, thanks again.

I am glad you found the solution, I don't have an explanation why a copy of the resources was not efficient, but I will keep this in mind if another developer happens to report the same trouble in the future.
Thanks for your feedback!
Best regards

Login or Signup to post a comment