• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html><body>
2<style>
3
4body, h1, h2, h3, div, span, p, pre, a {
5  margin: 0;
6  padding: 0;
7  border: 0;
8  font-weight: inherit;
9  font-style: inherit;
10  font-size: 100%;
11  font-family: inherit;
12  vertical-align: baseline;
13}
14
15body {
16  font-size: 13px;
17  padding: 1em;
18}
19
20h1 {
21  font-size: 26px;
22  margin-bottom: 1em;
23}
24
25h2 {
26  font-size: 24px;
27  margin-bottom: 1em;
28}
29
30h3 {
31  font-size: 20px;
32  margin-bottom: 1em;
33  margin-top: 1em;
34}
35
36pre, code {
37  line-height: 1.5;
38  font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Lucida Console', monospace;
39}
40
41pre {
42  margin-top: 0.5em;
43}
44
45h1, h2, h3, p {
46  font-family: Arial, sans serif;
47}
48
49h1, h2, h3 {
50  border-bottom: solid #CCC 1px;
51}
52
53.toc_element {
54  margin-top: 0.5em;
55}
56
57.firstline {
58  margin-left: 2 em;
59}
60
61.method  {
62  margin-top: 1em;
63  border: solid 1px #CCC;
64  padding: 1em;
65  background: #EEE;
66}
67
68.details {
69  font-weight: bold;
70  font-size: 14px;
71}
72
73</style>
74
75<h1><a href="language_v1beta1.html">Google Cloud Natural Language API</a> . <a href="language_v1beta1.documents.html">documents</a></h1>
76<h2>Instance Methods</h2>
77<p class="toc_element">
78  <code><a href="#analyzeEntities">analyzeEntities(body, x__xgafv=None)</a></code></p>
79<p class="firstline">Finds named entities (currently proper names and common nouns) in the text</p>
80<p class="toc_element">
81  <code><a href="#analyzeSentiment">analyzeSentiment(body, x__xgafv=None)</a></code></p>
82<p class="firstline">Analyzes the sentiment of the provided text.</p>
83<p class="toc_element">
84  <code><a href="#analyzeSyntax">analyzeSyntax(body, x__xgafv=None)</a></code></p>
85<p class="firstline">Analyzes the syntax of the text and provides sentence boundaries and</p>
86<p class="toc_element">
87  <code><a href="#annotateText">annotateText(body, x__xgafv=None)</a></code></p>
88<p class="firstline">A convenience method that provides all the features that analyzeSentiment,</p>
89<h3>Method Details</h3>
90<div class="method">
91    <code class="details" id="analyzeEntities">analyzeEntities(body, x__xgafv=None)</code>
92  <pre>Finds named entities (currently proper names and common nouns) in the text
93along with entity types, salience, mentions for each entity, and
94other properties.
95
96Args:
97  body: object, The request body. (required)
98    The object takes the form of:
99
100{ # The entity analysis request message.
101    "encodingType": "A String", # The encoding type used by the API to calculate offsets.
102    "document": { # ################################################################ # # Input document.
103        #
104        # Represents the input to API methods.
105      "content": "A String", # The content of the input in string format.
106      "type": "A String", # Required. If the type is not set or is `TYPE_UNSPECIFIED`,
107          # returns an `INVALID_ARGUMENT` error.
108      "language": "A String", # The language of the document (if not specified, the language is
109          # automatically detected). Both ISO and BCP-47 language codes are
110          # accepted.<br>
111          # [Language Support](/natural-language/docs/languages)
112          # lists currently supported languages for each API method.
113          # If the language (either specified by the caller or automatically detected)
114          # is not supported by the called API method, an `INVALID_ARGUMENT` error
115          # is returned.
116      "gcsContentUri": "A String", # The Google Cloud Storage URI where the file content is located.
117          # This URI must be of the form: gs://bucket_name/object_name. For more
118          # details, see https://cloud.google.com/storage/docs/reference-uris.
119          # NOTE: Cloud Storage object versioning is not supported.
120    },
121  }
122
123  x__xgafv: string, V1 error format.
124    Allowed values
125      1 - v1 error format
126      2 - v2 error format
127
128Returns:
129  An object of the form:
130
131    { # The entity analysis response message.
132    "entities": [ # The recognized entities in the input document.
133      { # Represents a phrase in the text that is a known entity, such as
134          # a person, an organization, or location. The API associates information, such
135          # as salience and mentions, with entities.
136        "mentions": [ # The mentions of this entity in the input document. The API currently
137            # supports proper noun mentions.
138          { # Represents a mention for an entity in the text. Currently, proper noun
139              # mentions are supported.
140            "text": { # Represents an output piece of text. # The mention text.
141              "content": "A String", # The content of the output text.
142              "beginOffset": 42, # The API calculates the beginning offset of the content in the original
143                  # document according to the EncodingType specified in the API request.
144            },
145            "type": "A String", # The type of the entity mention.
146          },
147        ],
148        "salience": 3.14, # The salience score associated with the entity in the [0, 1.0] range.
149            #
150            # The salience score for an entity provides information about the
151            # importance or centrality of that entity to the entire document text.
152            # Scores closer to 0 are less salient, while scores closer to 1.0 are highly
153            # salient.
154        "type": "A String", # The entity type.
155        "name": "A String", # The representative name for the entity.
156        "metadata": { # Metadata associated with the entity.
157            #
158            # Currently, Wikipedia URLs and Knowledge Graph MIDs are provided, if
159            # available. The associated keys are "wikipedia_url" and "mid", respectively.
160          "a_key": "A String",
161        },
162      },
163    ],
164    "language": "A String", # The language of the text, which will be the same as the language specified
165        # in the request or, if not specified, the automatically-detected language.
166        # See Document.language field for more details.
167  }</pre>
168</div>
169
170<div class="method">
171    <code class="details" id="analyzeSentiment">analyzeSentiment(body, x__xgafv=None)</code>
172  <pre>Analyzes the sentiment of the provided text.
173
174Args:
175  body: object, The request body. (required)
176    The object takes the form of:
177
178{ # The sentiment analysis request message.
179    "encodingType": "A String", # The encoding type used by the API to calculate sentence offsets for the
180        # sentence sentiment.
181    "document": { # ################################################################ # # Input document.
182        #
183        # Represents the input to API methods.
184      "content": "A String", # The content of the input in string format.
185      "type": "A String", # Required. If the type is not set or is `TYPE_UNSPECIFIED`,
186          # returns an `INVALID_ARGUMENT` error.
187      "language": "A String", # The language of the document (if not specified, the language is
188          # automatically detected). Both ISO and BCP-47 language codes are
189          # accepted.<br>
190          # [Language Support](/natural-language/docs/languages)
191          # lists currently supported languages for each API method.
192          # If the language (either specified by the caller or automatically detected)
193          # is not supported by the called API method, an `INVALID_ARGUMENT` error
194          # is returned.
195      "gcsContentUri": "A String", # The Google Cloud Storage URI where the file content is located.
196          # This URI must be of the form: gs://bucket_name/object_name. For more
197          # details, see https://cloud.google.com/storage/docs/reference-uris.
198          # NOTE: Cloud Storage object versioning is not supported.
199    },
200  }
201
202  x__xgafv: string, V1 error format.
203    Allowed values
204      1 - v1 error format
205      2 - v2 error format
206
207Returns:
208  An object of the form:
209
210    { # The sentiment analysis response message.
211    "documentSentiment": { # Represents the feeling associated with the entire text or entities in # The overall sentiment of the input document.
212        # the text.
213      "polarity": 3.14, # DEPRECATED FIELD - This field is being deprecated in
214          # favor of score. Please refer to our documentation at
215          # https://cloud.google.com/natural-language/docs for more information.
216      "score": 3.14, # Sentiment score between -1.0 (negative sentiment) and 1.0
217          # (positive sentiment).
218      "magnitude": 3.14, # A non-negative number in the [0, +inf) range, which represents
219          # the absolute magnitude of sentiment regardless of score (positive or
220          # negative).
221    },
222    "language": "A String", # The language of the text, which will be the same as the language specified
223        # in the request or, if not specified, the automatically-detected language.
224        # See Document.language field for more details.
225    "sentences": [ # The sentiment for all the sentences in the document.
226      { # Represents a sentence in the input document.
227        "text": { # Represents an output piece of text. # The sentence text.
228          "content": "A String", # The content of the output text.
229          "beginOffset": 42, # The API calculates the beginning offset of the content in the original
230              # document according to the EncodingType specified in the API request.
231        },
232        "sentiment": { # Represents the feeling associated with the entire text or entities in # For calls to AnalyzeSentiment or if
233            # AnnotateTextRequest.Features.extract_document_sentiment is set to
234            # true, this field will contain the sentiment for the sentence.
235            # the text.
236          "polarity": 3.14, # DEPRECATED FIELD - This field is being deprecated in
237              # favor of score. Please refer to our documentation at
238              # https://cloud.google.com/natural-language/docs for more information.
239          "score": 3.14, # Sentiment score between -1.0 (negative sentiment) and 1.0
240              # (positive sentiment).
241          "magnitude": 3.14, # A non-negative number in the [0, +inf) range, which represents
242              # the absolute magnitude of sentiment regardless of score (positive or
243              # negative).
244        },
245      },
246    ],
247  }</pre>
248</div>
249
250<div class="method">
251    <code class="details" id="analyzeSyntax">analyzeSyntax(body, x__xgafv=None)</code>
252  <pre>Analyzes the syntax of the text and provides sentence boundaries and
253tokenization along with part of speech tags, dependency trees, and other
254properties.
255
256Args:
257  body: object, The request body. (required)
258    The object takes the form of:
259
260{ # The syntax analysis request message.
261    "encodingType": "A String", # The encoding type used by the API to calculate offsets.
262    "document": { # ################################################################ # # Input document.
263        #
264        # Represents the input to API methods.
265      "content": "A String", # The content of the input in string format.
266      "type": "A String", # Required. If the type is not set or is `TYPE_UNSPECIFIED`,
267          # returns an `INVALID_ARGUMENT` error.
268      "language": "A String", # The language of the document (if not specified, the language is
269          # automatically detected). Both ISO and BCP-47 language codes are
270          # accepted.<br>
271          # [Language Support](/natural-language/docs/languages)
272          # lists currently supported languages for each API method.
273          # If the language (either specified by the caller or automatically detected)
274          # is not supported by the called API method, an `INVALID_ARGUMENT` error
275          # is returned.
276      "gcsContentUri": "A String", # The Google Cloud Storage URI where the file content is located.
277          # This URI must be of the form: gs://bucket_name/object_name. For more
278          # details, see https://cloud.google.com/storage/docs/reference-uris.
279          # NOTE: Cloud Storage object versioning is not supported.
280    },
281  }
282
283  x__xgafv: string, V1 error format.
284    Allowed values
285      1 - v1 error format
286      2 - v2 error format
287
288Returns:
289  An object of the form:
290
291    { # The syntax analysis response message.
292    "tokens": [ # Tokens, along with their syntactic information, in the input document.
293      { # Represents the smallest syntactic building block of the text.
294        "text": { # Represents an output piece of text. # The token text.
295          "content": "A String", # The content of the output text.
296          "beginOffset": 42, # The API calculates the beginning offset of the content in the original
297              # document according to the EncodingType specified in the API request.
298        },
299        "partOfSpeech": { # Represents part of speech information for a token. # Parts of speech tag for this token.
300          "case": "A String", # The grammatical case.
301          "reciprocity": "A String", # The grammatical reciprocity.
302          "mood": "A String", # The grammatical mood.
303          "form": "A String", # The grammatical form.
304          "gender": "A String", # The grammatical gender.
305          "number": "A String", # The grammatical number.
306          "person": "A String", # The grammatical person.
307          "tag": "A String", # The part of speech tag.
308          "tense": "A String", # The grammatical tense.
309          "aspect": "A String", # The grammatical aspect.
310          "proper": "A String", # The grammatical properness.
311          "voice": "A String", # The grammatical voice.
312        },
313        "dependencyEdge": { # Represents dependency parse tree information for a token. # Dependency tree parse for this token.
314          "headTokenIndex": 42, # Represents the head of this token in the dependency tree.
315              # This is the index of the token which has an arc going to this token.
316              # The index is the position of the token in the array of tokens returned
317              # by the API method. If this token is a root token, then the
318              # `head_token_index` is its own index.
319          "label": "A String", # The parse label for the token.
320        },
321        "lemma": "A String", # [Lemma](https://en.wikipedia.org/wiki/Lemma_%28morphology%29) of the token.
322      },
323    ],
324    "language": "A String", # The language of the text, which will be the same as the language specified
325        # in the request or, if not specified, the automatically-detected language.
326        # See Document.language field for more details.
327    "sentences": [ # Sentences in the input document.
328      { # Represents a sentence in the input document.
329        "text": { # Represents an output piece of text. # The sentence text.
330          "content": "A String", # The content of the output text.
331          "beginOffset": 42, # The API calculates the beginning offset of the content in the original
332              # document according to the EncodingType specified in the API request.
333        },
334        "sentiment": { # Represents the feeling associated with the entire text or entities in # For calls to AnalyzeSentiment or if
335            # AnnotateTextRequest.Features.extract_document_sentiment is set to
336            # true, this field will contain the sentiment for the sentence.
337            # the text.
338          "polarity": 3.14, # DEPRECATED FIELD - This field is being deprecated in
339              # favor of score. Please refer to our documentation at
340              # https://cloud.google.com/natural-language/docs for more information.
341          "score": 3.14, # Sentiment score between -1.0 (negative sentiment) and 1.0
342              # (positive sentiment).
343          "magnitude": 3.14, # A non-negative number in the [0, +inf) range, which represents
344              # the absolute magnitude of sentiment regardless of score (positive or
345              # negative).
346        },
347      },
348    ],
349  }</pre>
350</div>
351
352<div class="method">
353    <code class="details" id="annotateText">annotateText(body, x__xgafv=None)</code>
354  <pre>A convenience method that provides all the features that analyzeSentiment,
355analyzeEntities, and analyzeSyntax provide in one call.
356
357Args:
358  body: object, The request body. (required)
359    The object takes the form of:
360
361{ # The request message for the text annotation API, which can perform multiple
362      # analysis types (sentiment, entities, and syntax) in one call.
363    "encodingType": "A String", # The encoding type used by the API to calculate offsets.
364    "features": { # All available features for sentiment, syntax, and semantic analysis. # The enabled features.
365        # Setting each one to true will enable that specific analysis for the input.
366      "extractDocumentSentiment": True or False, # Extract document-level sentiment.
367      "extractEntities": True or False, # Extract entities.
368      "extractSyntax": True or False, # Extract syntax information.
369    },
370    "document": { # ################################################################ # # Input document.
371        #
372        # Represents the input to API methods.
373      "content": "A String", # The content of the input in string format.
374      "type": "A String", # Required. If the type is not set or is `TYPE_UNSPECIFIED`,
375          # returns an `INVALID_ARGUMENT` error.
376      "language": "A String", # The language of the document (if not specified, the language is
377          # automatically detected). Both ISO and BCP-47 language codes are
378          # accepted.<br>
379          # [Language Support](/natural-language/docs/languages)
380          # lists currently supported languages for each API method.
381          # If the language (either specified by the caller or automatically detected)
382          # is not supported by the called API method, an `INVALID_ARGUMENT` error
383          # is returned.
384      "gcsContentUri": "A String", # The Google Cloud Storage URI where the file content is located.
385          # This URI must be of the form: gs://bucket_name/object_name. For more
386          # details, see https://cloud.google.com/storage/docs/reference-uris.
387          # NOTE: Cloud Storage object versioning is not supported.
388    },
389  }
390
391  x__xgafv: string, V1 error format.
392    Allowed values
393      1 - v1 error format
394      2 - v2 error format
395
396Returns:
397  An object of the form:
398
399    { # The text annotations response message.
400    "tokens": [ # Tokens, along with their syntactic information, in the input document.
401        # Populated if the user enables
402        # AnnotateTextRequest.Features.extract_syntax.
403      { # Represents the smallest syntactic building block of the text.
404        "text": { # Represents an output piece of text. # The token text.
405          "content": "A String", # The content of the output text.
406          "beginOffset": 42, # The API calculates the beginning offset of the content in the original
407              # document according to the EncodingType specified in the API request.
408        },
409        "partOfSpeech": { # Represents part of speech information for a token. # Parts of speech tag for this token.
410          "case": "A String", # The grammatical case.
411          "reciprocity": "A String", # The grammatical reciprocity.
412          "mood": "A String", # The grammatical mood.
413          "form": "A String", # The grammatical form.
414          "gender": "A String", # The grammatical gender.
415          "number": "A String", # The grammatical number.
416          "person": "A String", # The grammatical person.
417          "tag": "A String", # The part of speech tag.
418          "tense": "A String", # The grammatical tense.
419          "aspect": "A String", # The grammatical aspect.
420          "proper": "A String", # The grammatical properness.
421          "voice": "A String", # The grammatical voice.
422        },
423        "dependencyEdge": { # Represents dependency parse tree information for a token. # Dependency tree parse for this token.
424          "headTokenIndex": 42, # Represents the head of this token in the dependency tree.
425              # This is the index of the token which has an arc going to this token.
426              # The index is the position of the token in the array of tokens returned
427              # by the API method. If this token is a root token, then the
428              # `head_token_index` is its own index.
429          "label": "A String", # The parse label for the token.
430        },
431        "lemma": "A String", # [Lemma](https://en.wikipedia.org/wiki/Lemma_%28morphology%29) of the token.
432      },
433    ],
434    "entities": [ # Entities, along with their semantic information, in the input document.
435        # Populated if the user enables
436        # AnnotateTextRequest.Features.extract_entities.
437      { # Represents a phrase in the text that is a known entity, such as
438          # a person, an organization, or location. The API associates information, such
439          # as salience and mentions, with entities.
440        "mentions": [ # The mentions of this entity in the input document. The API currently
441            # supports proper noun mentions.
442          { # Represents a mention for an entity in the text. Currently, proper noun
443              # mentions are supported.
444            "text": { # Represents an output piece of text. # The mention text.
445              "content": "A String", # The content of the output text.
446              "beginOffset": 42, # The API calculates the beginning offset of the content in the original
447                  # document according to the EncodingType specified in the API request.
448            },
449            "type": "A String", # The type of the entity mention.
450          },
451        ],
452        "salience": 3.14, # The salience score associated with the entity in the [0, 1.0] range.
453            #
454            # The salience score for an entity provides information about the
455            # importance or centrality of that entity to the entire document text.
456            # Scores closer to 0 are less salient, while scores closer to 1.0 are highly
457            # salient.
458        "type": "A String", # The entity type.
459        "name": "A String", # The representative name for the entity.
460        "metadata": { # Metadata associated with the entity.
461            #
462            # Currently, Wikipedia URLs and Knowledge Graph MIDs are provided, if
463            # available. The associated keys are "wikipedia_url" and "mid", respectively.
464          "a_key": "A String",
465        },
466      },
467    ],
468    "documentSentiment": { # Represents the feeling associated with the entire text or entities in # The overall sentiment for the document. Populated if the user enables
469        # AnnotateTextRequest.Features.extract_document_sentiment.
470        # the text.
471      "polarity": 3.14, # DEPRECATED FIELD - This field is being deprecated in
472          # favor of score. Please refer to our documentation at
473          # https://cloud.google.com/natural-language/docs for more information.
474      "score": 3.14, # Sentiment score between -1.0 (negative sentiment) and 1.0
475          # (positive sentiment).
476      "magnitude": 3.14, # A non-negative number in the [0, +inf) range, which represents
477          # the absolute magnitude of sentiment regardless of score (positive or
478          # negative).
479    },
480    "language": "A String", # The language of the text, which will be the same as the language specified
481        # in the request or, if not specified, the automatically-detected language.
482        # See Document.language field for more details.
483    "sentences": [ # Sentences in the input document. Populated if the user enables
484        # AnnotateTextRequest.Features.extract_syntax.
485      { # Represents a sentence in the input document.
486        "text": { # Represents an output piece of text. # The sentence text.
487          "content": "A String", # The content of the output text.
488          "beginOffset": 42, # The API calculates the beginning offset of the content in the original
489              # document according to the EncodingType specified in the API request.
490        },
491        "sentiment": { # Represents the feeling associated with the entire text or entities in # For calls to AnalyzeSentiment or if
492            # AnnotateTextRequest.Features.extract_document_sentiment is set to
493            # true, this field will contain the sentiment for the sentence.
494            # the text.
495          "polarity": 3.14, # DEPRECATED FIELD - This field is being deprecated in
496              # favor of score. Please refer to our documentation at
497              # https://cloud.google.com/natural-language/docs for more information.
498          "score": 3.14, # Sentiment score between -1.0 (negative sentiment) and 1.0
499              # (positive sentiment).
500          "magnitude": 3.14, # A non-negative number in the [0, +inf) range, which represents
501              # the absolute magnitude of sentiment regardless of score (positive or
502              # negative).
503        },
504      },
505    ],
506  }</pre>
507</div>
508
509</body></html>