> For the complete documentation index, see [llms.txt](https://calculatedsystems.gitbook.io/cloud-nifi-processors/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://calculatedsystems.gitbook.io/cloud-nifi-processors/google-cloud-platform/natural-language-api/annotatetext-processor.md).

# AnnotateText Processor

Part of the GCP Natural Language processor family

This processor is a convenience-based processor that combines the capabilities of the [AnalyzeSyntax](/cloud-nifi-processors/google-cloud-platform/natural-language-api/analyzesyntax-processor.md), [AnalyzeEntities](/cloud-nifi-processors/google-cloud-platform/natural-language-api/analyzeentities-processor.md), [AnalyzeSentiment](/cloud-nifi-processors/google-cloud-platform/natural-language-api/analyzesentiment-processor.md), and ClassifyText processors into one unit.

Both the entities and sentences returned from this processor will have a sentiment attached them.

{% hint style="warning" %}
The output of this processor can easily grow to be incredibly large, especially with large pieces of text. Unless you're actually looking for all of this information at once, consider using the processors with a more granular scope.
{% endhint %}

## Properties

{% hint style="info" %}
All of our Natural Language processors also include these [common properties](/cloud-nifi-processors/google-cloud-platform/natural-language-api.md#common-properties).
{% endhint %}

This processor does not have any unique properties outside of the common ones.

## Data Output

{% tabs %}
{% tab title="Output Format" %}

| Field Name       | Data Type         | Description                                              |
| ---------------- | ----------------- | -------------------------------------------------------- |
| sentences        | array of Sentence | The list of sentences found by the API                   |
| entities         | array of Entity   | The list of entities found by the API                    |
| categories       | array of Category | The list of categories found by the API                  |
| tokens           | array of Token    | The list of tokens found by the API                      |
| overallSentiment | Sentiment         | The sentiment of the text as a whole                     |
| language         | string            | The language code of the language the input string is in |
| {% endtab %}     |                   |                                                          |

{% tab title="Relevant Data Structures" %}

#### `Token` <a href="#token" id="token"></a>

| Field Name     | Data Type      | Description                                                                                                                      |
| -------------- | -------------- | -------------------------------------------------------------------------------------------------------------------------------- |
| text           | string         | The raw text of this token                                                                                                       |
| lemma          | string         | The root/bare version of this word. Read more about lemma [here](https://en.wikipedia.org/wiki/Lemma_\(morphology\)).            |
| beginOffset    | int            | The number of characters from the beginning of the input string to the beginning of this token                                   |
| partOfSpeech   | PartOfSpeech   | A comprehensive list of all of the syntactical information pertaining to this token, such as gender, quantity, person, etcetera. |
| dependencyEdge | DependencyEdge | Represents dependency tree information for this token. Read more [here](http://www.aclweb.org/anthology/P13-2017).               |

#### `Sentiment` <a href="#sentiment" id="sentiment"></a>

| Field Name | Data Type | Description                                                                                                                                                                                                                          |
| ---------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| score      | float     | A number ranging from -1.0 (negative sentiment) to 1.0 (positive sentiment)                                                                                                                                                          |
| magnitude  | float     | A number ranging from 0 to +inf representing the absolute magnitude of the sentiment (regardless of score). This number can be thought of as the strength of the emotion (e.g., something being very positive, or slightly negative) |

#### `Sentence` <a href="#sentence" id="sentence"></a>

| Field Name  | Data Type | Description                                                                                       |
| ----------- | --------- | ------------------------------------------------------------------------------------------------- |
| text        | string    | The raw text of this sentence                                                                     |
| beginOffset | int       | The number of characters from the beginning of the input string to the beginning of this sentence |
| sentiment   | Sentiment | The sentiment of this sentence                                                                    |

#### `DependencyEdge` <a href="#dependencyedge" id="dependencyedge"></a>

| Field Name     | Data Type                                                                                | Description                                             |
| -------------- | ---------------------------------------------------------------------------------------- | ------------------------------------------------------- |
| headTokenIndex | int                                                                                      | Represents the head of the token in the dependency tree |
| label          | string ([DependencyEdgeLabel](https://googleapis.dev/java/google-cloud-clients/latest/)) | The parse label for the token                           |

#### `PartOfSpeech` <a href="#partofspeech" id="partofspeech"></a>

| Field Name  | Data Type                                                                                                                             | Description                                                                                                 |
| ----------- | ------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- |
| aspect      | string ([Aspect](https://googleapis.dev/java/google-api-grpc/latest/com/google/cloud/language/v1/PartOfSpeech.Aspect.html))           | The characteristic of a verb that expresses time flow during an event                                       |
| case        | string ([Case](https://googleapis.dev/java/google-cloud-clients/latest/))                                                             | The grammatical function performed by a noun or pronoun in a phrase, clause, or sentence                    |
| form        | string ([Form](https://googleapis.dev/java/google-api-grpc/latest/com/google/cloud/language/v1/PartOfSpeech.Form.html))               | Depending on the language, Form can be categorizing different forms of verbs, adjectives, adverbs, etcetera |
| gender      | string ([Gender](https://googleapis.dev/java/google-api-grpc/latest/com/google/cloud/language/v1/PartOfSpeech.Gender.html))           | Gender classes of nouns reflected in the behavior of associated words                                       |
| mood        | string ([Mood](https://googleapis.dev/java/google-api-grpc/latest/com/google/cloud/language/v1/PartOfSpeech.Mood.html))               | The grammatical feature of verbs, used for showing modality and attitude                                    |
| number      | string ([Number](https://googleapis.dev/java/google-api-grpc/latest/com/google/cloud/language/v1/PartOfSpeech.Number.html))           | Count distinctions                                                                                          |
| person      | string ([Person](https://googleapis.dev/java/google-api-grpc/latest/com/google/cloud/language/v1/PartOfSpeech.Person.html))           | The distinction between the speaker, second person, third person, etcetera                                  |
| proper      | string ([Proper](https://googleapis.dev/java/google-api-grpc/latest/com/google/cloud/language/v1/PartOfSpeech.Proper.html))           | Distinguishes if the token is part of a proper name                                                         |
| reciprocity | string ([Reciprocity](https://googleapis.dev/java/google-api-grpc/latest/com/google/cloud/language/v1/PartOfSpeech.Reciprocity.html)) | Reciprocal features of a pronoun                                                                            |
| tag         | string ([Tag](https://googleapis.dev/java/google-api-grpc/latest/com/google/cloud/language/v1/PartOfSpeech.Tag.html))                 | A shorthand-tag for what part of speech the token is                                                        |
| tense       | string ([Tense](https://googleapis.dev/java/google-api-grpc/latest/com/google/cloud/language/v1/PartOfSpeech.Tense.html))             | Time reference                                                                                              |
| voice       | string ([Voice](https://googleapis.dev/java/google-api-grpc/latest/com/google/cloud/language/v1/PartOfSpeech.Voice.html))             | The relationship between the action that a verb expresses and the participants identified by its arguments  |

#### `Category`

| Field Name   | Data Type | Description                                                                                                                                     |
| ------------ | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| name         | string    | The name of the category. A list of all possible category names can be [found here.](https://cloud.google.com/natural-language/docs/categories) |
| confidence   | float     | How confident the API is in its response                                                                                                        |
| {% endtab %} |           |                                                                                                                                                 |

{% tab title="Example Output" %}

```javascript
// This example has the tokens field omitted for bevity. For an extensive
// example of the tokens field, view the AnalyzeSyntax processor's example output.
{
   "output":{
      "overallSentiment":{
         "score":0.5,
         "magnitude":1.7
      },
      "tokens": [],
      "entities":[
         {
            "metadata":{
               "wikipedia_url":"https:\/\/en.wikipedia.org\/wiki\/James_Adams_(entrepreneur)",
               "mid":"\/m\/0136zb57"
            },
            "mentions":[
               {
                  "sentiment":{
                     "score":0.9,
                     "magnitude":0.9
                  },
                  "text":"James Adams",
                  "type":"PROPER",
                  "beginOffset":-1
               },
               {
                  "sentiment":{
                     "score":0.9,
                     "magnitude":0.9
                  },
                  "text":"developer",
                  "type":"COMMON",
                  "beginOffset":-1
               }
            ],
            "type":"PERSON"
         },
         {
            "metadata":{

            },
            "mentions":[
               {
                  "sentiment":{
                     "score":0.0,
                     "magnitude":0.0
                  },
                  "text":"scene",
                  "type":"COMMON",
                  "beginOffset":-1
               }
            ],
            "type":"LOCATION"
         },
         {
            "metadata":{

            },
            "mentions":[
               {
                  "sentiment":{
                     "score":0.9,
                     "magnitude":0.9
                  },
                  "text":"attitude",
                  "type":"COMMON",
                  "beginOffset":-1
               }
            ],
            "type":"OTHER"
         },
         {
            "metadata":{

            },
            "mentions":[
               {
                  "sentiment":{
                     "score":0.9,
                     "magnitude":0.9
                  },
                  "text":"work ethic",
                  "type":"COMMON",
                  "beginOffset":-1
               }
            ],
            "type":"OTHER"
         },
         {
            "metadata":{

            },
            "mentions":[
               {
                  "sentiment":{
                     "score":0.0,
                     "magnitude":0.0
                  },
                  "text":"company",
                  "type":"COMMON",
                  "beginOffset":-1
               }
            ],
            "type":"ORGANIZATION"
         },
         {
            "metadata":{

            },
            "mentions":[
               {
                  "sentiment":{
                     "score":0.5,
                     "magnitude":0.5
                  },
                  "text":"character",
                  "type":"COMMON",
                  "beginOffset":-1
               }
            ],
            "type":"PERSON"
         }
      ],
      "sentences":[
         {
            "sentiment":{
               "score":0.6,
               "magnitude":0.6
            },
            "text":"James Adams is a fantastic developer who has been on the scene for over ten years.",
            "beginOffset":-1
         },
         {
            "sentiment":{
               "score":0.9,
               "magnitude":0.9
            },
            "text":"His excellent attitude and steady work ethic contribute to his character.",
            "beginOffset":-1
         },
         {
            "sentiment":{
               "score":0.2,
               "magnitude":0.2
            },
            "text":"May he stay with our company for many years to come.",
            "beginOffset":-1
         }
      ],
      "language":"en",
      "categories":[
         {
            "confidence":0.81,
            "name":"\/Arts & Entertainment"
         }
      ]
   },
   "raw-input":"James Adams is a fantastic developer who has been on the scene for over ten years. His excellent attitude and steady work ethic contribute to his character. May he stay with our company for many years to come."
}
```

{% endtab %}
{% endtabs %}
