From d2bd0d3ef12eee6113665f76752bad317ca696a1 Mon Sep 17 00:00:00 2001 From: Devan Kuleindiren Date: Tue, 9 May 2017 00:17:51 +0100 Subject: [PATCH] Remove incorrect copyright. --- ios/keyboard/KeyboardViewController.h | 8 -------- ios/keyboard/KeyboardViewController.mm | 28 +++++++++----------------- 2 files changed, 10 insertions(+), 26 deletions(-) diff --git a/ios/keyboard/KeyboardViewController.h b/ios/keyboard/KeyboardViewController.h index 67e7c68..716aa89 100644 --- a/ios/keyboard/KeyboardViewController.h +++ b/ios/keyboard/KeyboardViewController.h @@ -1,11 +1,3 @@ -// -// KeyboardViewController.h -// keyboard -// -// Created by Devan Kuleindiren on 27/01/2017. -// Copyright © 2017 Google. All rights reserved. -// - #import #import #include "tensorflow/Source/lm/rnn/rnn.h" diff --git a/ios/keyboard/KeyboardViewController.mm b/ios/keyboard/KeyboardViewController.mm index 0e4b4c4..76a1a38 100644 --- a/ios/keyboard/KeyboardViewController.mm +++ b/ios/keyboard/KeyboardViewController.mm @@ -1,11 +1,3 @@ -// -// KeyboardViewController.m -// keyboard -// -// Created by Devan Kuleindiren on 27/01/2017. -// Copyright © 2017 Google. All rights reserved. -// - #import "KeyboardViewController.h" #include @@ -19,7 +11,7 @@ @implementation KeyboardViewController - (void)updateViewConstraints { [super updateViewConstraints]; - + // Add custom view sizing constraints here if (self.view.frame.size.width == 0 || self.view.frame.size.height == 0) return; @@ -36,17 +28,17 @@ - (id) init { if (self) { // Init here. } - + return self; } - (void)viewDidLoad { [super viewDidLoad]; - + usePrevStateRNN = false; predictionButtons = [[NSArray alloc] initWithObjects:firstPrediction, secondPrediction, thirdPrediction, nil]; - + // Initialise the shift button. shiftButtonState = SHIFT; UITapGestureRecognizer *shiftSingleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(shiftSingleTap)]; @@ -118,7 +110,7 @@ - (void)viewDidLoad { NSString* model_path = [[NSBundle mainBundle] pathForResource:@"graph" ofType:@"pb"]; NSRange range = [model_path rangeOfString: @"/" options: NSBackwardsSearch]; rnn = new RNN(std::string([[model_path substringToIndex: range.location] UTF8String])); - + charTrie = new CharTrie(); std::list blackList = std::list({".", ",", "?", "!", "'", "\"", "/", "\\", ":", ";", "(", ")", "{", "}", "@", "#", "£", "$", "%", "^", "&", "*", "-", "_", "+", "=", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"}); for (std::unordered_map::const_iterator it = rnn->GetVocab()->begin(); it != rnn->GetVocab()->end(); ++it) { @@ -201,7 +193,7 @@ - (IBAction)predictWord:(id)sender { if (![sender isKindOfClass:[UIButton class]]) { return; } - + NSArray *tokens = [self.textDocumentProxy.documentContextBeforeInput componentsSeparatedByString:@" "]; for (int i = 0; i < [[tokens lastObject] length];i++) { [self.textDocumentProxy deleteBackward]; @@ -299,10 +291,10 @@ - (IBAction)nextKeyboard:(id)sender { - (void)newPredictions { std::list seq; - + NSArray *tokens = [self.textDocumentProxy.documentContextBeforeInput componentsSeparatedByString:@" "]; unsigned long numTokens = [tokens count]; - + if (usePrevStateRNN) { seq.push_back(std::string([[[tokens objectAtIndex:(numTokens - 2)] lowercaseString] UTF8String])); } else { @@ -311,11 +303,11 @@ - (void)newPredictions { seq.push_back(std::string([[s lowercaseString] UTF8String])); } } - + rnn->ProbAllFollowing(seq, charTrie, usePrevStateRNN); std::list> top3 = charTrie->GetMaxKWithPrefix([[tokens lastObject] UTF8String], 3); [self setPredictionsWithTop3:&top3]; - + if (!usePrevStateRNN) { usePrevStateRNN = true; }