Amplify has re-imagined the way frontend developers build fullstack applications. Develop and deploy without the hassle.

Page updated Apr 29, 2024

Interpret sentiment

Amplify iOS v1 is now in Maintenance Mode until May 31st, 2024. This means that we will continue to include updates to ensure compatibility with backend services and security. No new features will be introduced in v1.

Please use the latest version (v2) of Amplify Library for Swift to get started.

If you are currently using v1, follow these instructions to upgrade to v2.

Amplify libraries should be used for all new cloud connected applications. If you are currently using the AWS Mobile SDK for iOS, you can access the documentation here.

The following API allows you to analyze text for language, entities (places, people), key phrases, sentiment (positive, neutral, negative), and syntax (pronouns, verbs, adjectives).

For analyzing language on iOS we use both AWS backend services as well as Apple's on-device Natural Language Framework to provide you with the most accurate results. If your device is offline, we will return results only Natural Language. On the other hand, if you are able to connect to AWS Services, we will return a unioned result from both the service and Natural Language. Switching between backend services and Natural Language is done automatically without any additional configuration required.

Set up your backend

This will allow you to determine key phrases, sentiment, language, syntax, and entities from text. If you haven't already done so, run amplify init inside your project and then amplify add auth (we recommend selecting the default configuration).

Run amplify add predictions, then use the following answers:

? Please select from one of the categories below
❯ Interpret
Learn More
? What would you like to interpret? (Use arrow keys)
❯ Interpret Text
? Provide a friendly name for your resource
<Enter a friendly name here>
? What kind of interpretation would you like?
❯ All
? Who should have access?
Auth users only
❯ Auth and Guest users

Run amplify push to create the resources in the cloud

Working with the API

Here is an example of sending text for interpretation such as sentiment analysis or natural language characteristics.

func interpret(text: String) {
Amplify.Predictions.interpret(text: text) { event in
switch event {
case let .success(result):
case let .failure(error):
func interpret(text: String) -> AnyCancellable {
Amplify.Predictions.interpret(text: text)
.sink {
if case let .failure(error) = $0 {
receiveValue: { result in