Skip to content

Commit

Permalink
Remove incorrect copyright.
Browse files Browse the repository at this point in the history
  • Loading branch information
DevanKuleindiren committed May 8, 2017
1 parent c0a49f1 commit d2bd0d3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 26 deletions.
8 changes: 0 additions & 8 deletions ios/keyboard/KeyboardViewController.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
//
// KeyboardViewController.h
// keyboard
//
// Created by Devan Kuleindiren on 27/01/2017.
// Copyright © 2017 Google. All rights reserved.
//

#import <QuartzCore/QuartzCore.h>
#import <UIKit/UIKit.h>
#include "tensorflow/Source/lm/rnn/rnn.h"
Expand Down
28 changes: 10 additions & 18 deletions ios/keyboard/KeyboardViewController.mm
Original file line number Diff line number Diff line change
@@ -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 <list>
Expand All @@ -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;
Expand All @@ -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)];
Expand Down Expand Up @@ -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<std::string> blackList = std::list<std::string>({".", ",", "?", "!", "'", "\"", "/", "\\", ":", ";", "(", ")", "{", "}", "@", "#", "£", "$", "%", "^", "&", "*", "-", "_", "+", "=", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"});
for (std::unordered_map<std::string, size_t>::const_iterator it = rnn->GetVocab()->begin(); it != rnn->GetVocab()->end(); ++it) {
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -299,10 +291,10 @@ - (IBAction)nextKeyboard:(id)sender {

- (void)newPredictions {
std::list<std::string> 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 {
Expand All @@ -311,11 +303,11 @@ - (void)newPredictions {
seq.push_back(std::string([[s lowercaseString] UTF8String]));
}
}

rnn->ProbAllFollowing(seq, charTrie, usePrevStateRNN);
std::list<std::pair<std::string, double>> top3 = charTrie->GetMaxKWithPrefix([[tokens lastObject] UTF8String], 3);
[self setPredictionsWithTop3:&top3];

if (!usePrevStateRNN) {
usePrevStateRNN = true;
}
Expand Down

0 comments on commit d2bd0d3

Please sign in to comment.