Using a CoreML model

Applications can utilize CoreML for many different purposes. One of these purposes is text analysis. You can use a trained model to detect whether a particular piece of text has a positive or negative sentiment. To implement a feature like this, you can use a trained and converted CoreML model.

The code bundle for this chapter includes a project named TextAnalyzer. If you open the start version of this project, you'll find a project that has an implementation of a simple layout along with a button that is hooked up to an @IBAction, named analyze(). The project folder also contains a file called SentimentPolarity.mlmodel. This file is a trained CoreML model that analyzes the sentiment associated with a certain text. Drag ...

Get Mastering iOS 12 Programming - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.