Sample iPad app to work with JSon based Machine Learning System

For people in hurry get the iPad app Sample code and steps to run here.

GoSmarter is a JSon based Machine Learning System, to which, if you pass a Natural Language (NLP) Query, it will return a list of recommended products, primarily Used cars, Electronic Gadgets,  Video Consoles and others. This Machine Learning also uses Social networking capabilities to recommend products based on your friends.

In this sample, I have written a iPad based application, which is a 2 tabbed application, in the first tab, it will return all the popular items among GoSmarter user base. In the tab 2, we can pass any query and it will return list of products that are current from Amazon, eBay and other sources. Some of the iOS Programming capabilities it demonstrate are,

As a starter in Xcode it is easy to create a Tabbed Application with Default Storyboard with 2 Tabs. While creating the project, you just have to tell Xcode this application is better configured for iPad.

Refer this youtube Searchbar samples by iffytheperfect1983, In our sample, we got the query from the Searchbar and passed to GoSmarter JSon RESTful API Code is as below,

-(void)loadData: (NSString *)searchString {
NSString *baseUrlString = @"";
NSString* escapedUrlString = [searchString stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
NSString *urlString = [baseUrlString stringByAppendingString:escapedUrlString];
NSURL *url = [NSURL URLWithString:urlString];
NSURLRequest * request = [NSURLRequest requestWithURL:url];
connection = [NSURLConnection connectionWithRequest:request delegate:self];

webData = [[NSMutableData alloc]init];
[self.myTableView resignFirstResponder];

-(void)searchBarSearchButtonClicked:(UISearchBar *)searchBar{
NSString *searchQuery = searchBar.text;
[self loadData:searchQuery];

There is a good youtube demo for sharing data between 2 applications by iffytheperfect1983, there is also a good blog Storyboards Segue Tutorial: Pass Data Between View Controllers. These 2 show how to share data between 2 View Controllers. In our sample, the usecase is, when user selects a popular item, it should pass this query to the 2nd Tab View Controller and it should automatically return all the results in that query. UI is as below,

Storyboard Segue UI for sharing data between View Controller

Storyboard Segue UI for sharing data between View Controller

//First View Controller:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
SecondViewController *viewController = segue.destinationViewController;
NSIndexPath *indexPath = [self.myTableView indexPathForSelectedRow];
viewController.onLoad = YES;
viewController.searchString = [nameArray objectAtIndex:indexPath.row];

//Second View Controller</pre>
- (void)viewDidLoad
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[self loadData:searchString];

There is a youtube video on creating Custom Table View Cell. We created a Custom TableView cell and associated with 2 Label one for Name and another for Price as below,

Custom UITableViewCell

Custom UITableViewCell

The code for Custom Cell,

@interface CustomTableViewCell : UITableViewCell
@property (weak, nonatomic) IBOutlet UILabel *label1;
@property (weak, nonatomic) IBOutlet UILabel *label2;

To conclude in this sample, we demonstrated some of the fundamental capabilities of iOS Programming. 

You can also tryout NLP queries in this Machine Learning system as we have defined Product Ontology,

  • iPod below $25
  • Mario < $25
  • Mario > $25
  • Mario less than $25
  • iPad greater than $250
  • Car near 01702
  • Toys for boys, Toys for girls
  • Mobile phones for old people
  • “42” LED
  • Low cost Smartphones
  • Cheap Phones
  • New LED
  • Samsung: will return Samsung Smartphone, because in Product Ontology, brand identification for Samsung is Smartphone

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s