language_service.proto 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969
  1. // Copyright 2017 Google Inc.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. syntax = "proto3";
  15. package google.cloud.language.v1beta1;
  16. import "google/api/annotations.proto";
  17. option go_package = "google.golang.org/genproto/googleapis/cloud/language/v1beta1;language";
  18. option java_multiple_files = true;
  19. option java_outer_classname = "LanguageServiceProto";
  20. option java_package = "com.google.cloud.language.v1beta1";
  21. // Provides text analysis operations such as sentiment analysis and entity
  22. // recognition.
  23. service LanguageService {
  24. // Analyzes the sentiment of the provided text.
  25. rpc AnalyzeSentiment(AnalyzeSentimentRequest)
  26. returns (AnalyzeSentimentResponse) {
  27. option (google.api.http) = {
  28. post: "/v1beta1/documents:analyzeSentiment"
  29. body: "*"
  30. };
  31. }
  32. // Finds named entities (currently proper names and common nouns) in the text
  33. // along with entity types, salience, mentions for each entity, and
  34. // other properties.
  35. rpc AnalyzeEntities(AnalyzeEntitiesRequest)
  36. returns (AnalyzeEntitiesResponse) {
  37. option (google.api.http) = {
  38. post: "/v1beta1/documents:analyzeEntities"
  39. body: "*"
  40. };
  41. }
  42. // Analyzes the syntax of the text and provides sentence boundaries and
  43. // tokenization along with part of speech tags, dependency trees, and other
  44. // properties.
  45. rpc AnalyzeSyntax(AnalyzeSyntaxRequest) returns (AnalyzeSyntaxResponse) {
  46. option (google.api.http) = {
  47. post: "/v1beta1/documents:analyzeSyntax"
  48. body: "*"
  49. };
  50. }
  51. // A convenience method that provides all the features that analyzeSentiment,
  52. // analyzeEntities, and analyzeSyntax provide in one call.
  53. rpc AnnotateText(AnnotateTextRequest) returns (AnnotateTextResponse) {
  54. option (google.api.http) = {
  55. post: "/v1beta1/documents:annotateText"
  56. body: "*"
  57. };
  58. }
  59. }
  60. //
  61. // Represents the input to API methods.
  62. message Document {
  63. // The document types enum.
  64. enum Type {
  65. // The content type is not specified.
  66. TYPE_UNSPECIFIED = 0;
  67. // Plain text
  68. PLAIN_TEXT = 1;
  69. // HTML
  70. HTML = 2;
  71. }
  72. // Required. If the type is not set or is `TYPE_UNSPECIFIED`,
  73. // returns an `INVALID_ARGUMENT` error.
  74. Type type = 1;
  75. // The source of the document: a string containing the content or a
  76. // Google Cloud Storage URI.
  77. oneof source {
  78. // The content of the input in string format.
  79. string content = 2;
  80. // The Google Cloud Storage URI where the file content is located.
  81. // This URI must be of the form: gs://bucket_name/object_name. For more
  82. // details, see https://cloud.google.com/storage/docs/reference-uris.
  83. // NOTE: Cloud Storage object versioning is not supported.
  84. string gcs_content_uri = 3;
  85. }
  86. // The language of the document (if not specified, the language is
  87. // automatically detected). Both ISO and BCP-47 language codes are
  88. // accepted.<br>
  89. // [Language
  90. // Support](https://cloud.google.com/natural-language/docs/languages) lists
  91. // currently supported languages for each API method. If the language (either
  92. // specified by the caller or automatically detected) is not supported by the
  93. // called API method, an `INVALID_ARGUMENT` error is returned.
  94. string language = 4;
  95. }
  96. // Represents a sentence in the input document.
  97. message Sentence {
  98. // The sentence text.
  99. TextSpan text = 1;
  100. // For calls to [AnalyzeSentiment][] or if
  101. // [AnnotateTextRequest.Features.extract_document_sentiment][google.cloud.language.v1beta1.AnnotateTextRequest.Features.extract_document_sentiment]
  102. // is set to true, this field will contain the sentiment for the sentence.
  103. Sentiment sentiment = 2;
  104. }
  105. // Represents a phrase in the text that is a known entity, such as
  106. // a person, an organization, or location. The API associates information, such
  107. // as salience and mentions, with entities.
  108. message Entity {
  109. // The type of the entity.
  110. enum Type {
  111. // Unknown
  112. UNKNOWN = 0;
  113. // Person
  114. PERSON = 1;
  115. // Location
  116. LOCATION = 2;
  117. // Organization
  118. ORGANIZATION = 3;
  119. // Event
  120. EVENT = 4;
  121. // Work of art
  122. WORK_OF_ART = 5;
  123. // Consumer goods
  124. CONSUMER_GOOD = 6;
  125. // Other types
  126. OTHER = 7;
  127. }
  128. // The representative name for the entity.
  129. string name = 1;
  130. // The entity type.
  131. Type type = 2;
  132. // Metadata associated with the entity.
  133. //
  134. // Currently, Wikipedia URLs and Knowledge Graph MIDs are provided, if
  135. // available. The associated keys are "wikipedia_url" and "mid", respectively.
  136. map<string, string> metadata = 3;
  137. // The salience score associated with the entity in the [0, 1.0] range.
  138. //
  139. // The salience score for an entity provides information about the
  140. // importance or centrality of that entity to the entire document text.
  141. // Scores closer to 0 are less salient, while scores closer to 1.0 are highly
  142. // salient.
  143. float salience = 4;
  144. // The mentions of this entity in the input document. The API currently
  145. // supports proper noun mentions.
  146. repeated EntityMention mentions = 5;
  147. }
  148. // Represents the smallest syntactic building block of the text.
  149. message Token {
  150. // The token text.
  151. TextSpan text = 1;
  152. // Parts of speech tag for this token.
  153. PartOfSpeech part_of_speech = 2;
  154. // Dependency tree parse for this token.
  155. DependencyEdge dependency_edge = 3;
  156. // [Lemma](https://en.wikipedia.org/wiki/Lemma_%28morphology%29) of the token.
  157. string lemma = 4;
  158. }
  159. // Represents the feeling associated with the entire text or entities in
  160. // the text.
  161. message Sentiment {
  162. // DEPRECATED FIELD - This field is being deprecated in
  163. // favor of score. Please refer to our documentation at
  164. // https://cloud.google.com/natural-language/docs for more information.
  165. float polarity = 1;
  166. // A non-negative number in the [0, +inf) range, which represents
  167. // the absolute magnitude of sentiment regardless of score (positive or
  168. // negative).
  169. float magnitude = 2;
  170. // Sentiment score between -1.0 (negative sentiment) and 1.0
  171. // (positive sentiment).
  172. float score = 3;
  173. }
  174. // Represents part of speech information for a token.
  175. message PartOfSpeech {
  176. // The part of speech tags enum.
  177. enum Tag {
  178. // Unknown
  179. UNKNOWN = 0;
  180. // Adjective
  181. ADJ = 1;
  182. // Adposition (preposition and postposition)
  183. ADP = 2;
  184. // Adverb
  185. ADV = 3;
  186. // Conjunction
  187. CONJ = 4;
  188. // Determiner
  189. DET = 5;
  190. // Noun (common and proper)
  191. NOUN = 6;
  192. // Cardinal number
  193. NUM = 7;
  194. // Pronoun
  195. PRON = 8;
  196. // Particle or other function word
  197. PRT = 9;
  198. // Punctuation
  199. PUNCT = 10;
  200. // Verb (all tenses and modes)
  201. VERB = 11;
  202. // Other: foreign words, typos, abbreviations
  203. X = 12;
  204. // Affix
  205. AFFIX = 13;
  206. }
  207. // The characteristic of a verb that expresses time flow during an event.
  208. enum Aspect {
  209. // Aspect is not applicable in the analyzed language or is not predicted.
  210. ASPECT_UNKNOWN = 0;
  211. // Perfective
  212. PERFECTIVE = 1;
  213. // Imperfective
  214. IMPERFECTIVE = 2;
  215. // Progressive
  216. PROGRESSIVE = 3;
  217. }
  218. // The grammatical function performed by a noun or pronoun in a phrase,
  219. // clause, or sentence. In some languages, other parts of speech, such as
  220. // adjective and determiner, take case inflection in agreement with the noun.
  221. enum Case {
  222. // Case is not applicable in the analyzed language or is not predicted.
  223. CASE_UNKNOWN = 0;
  224. // Accusative
  225. ACCUSATIVE = 1;
  226. // Adverbial
  227. ADVERBIAL = 2;
  228. // Complementive
  229. COMPLEMENTIVE = 3;
  230. // Dative
  231. DATIVE = 4;
  232. // Genitive
  233. GENITIVE = 5;
  234. // Instrumental
  235. INSTRUMENTAL = 6;
  236. // Locative
  237. LOCATIVE = 7;
  238. // Nominative
  239. NOMINATIVE = 8;
  240. // Oblique
  241. OBLIQUE = 9;
  242. // Partitive
  243. PARTITIVE = 10;
  244. // Prepositional
  245. PREPOSITIONAL = 11;
  246. // Reflexive
  247. REFLEXIVE_CASE = 12;
  248. // Relative
  249. RELATIVE_CASE = 13;
  250. // Vocative
  251. VOCATIVE = 14;
  252. }
  253. // Depending on the language, Form can be categorizing different forms of
  254. // verbs, adjectives, adverbs, etc. For example, categorizing inflected
  255. // endings of verbs and adjectives or distinguishing between short and long
  256. // forms of adjectives and participles
  257. enum Form {
  258. // Form is not applicable in the analyzed language or is not predicted.
  259. FORM_UNKNOWN = 0;
  260. // Adnomial
  261. ADNOMIAL = 1;
  262. // Auxiliary
  263. AUXILIARY = 2;
  264. // Complementizer
  265. COMPLEMENTIZER = 3;
  266. // Final ending
  267. FINAL_ENDING = 4;
  268. // Gerund
  269. GERUND = 5;
  270. // Realis
  271. REALIS = 6;
  272. // Irrealis
  273. IRREALIS = 7;
  274. // Short form
  275. SHORT = 8;
  276. // Long form
  277. LONG = 9;
  278. // Order form
  279. ORDER = 10;
  280. // Specific form
  281. SPECIFIC = 11;
  282. }
  283. // Gender classes of nouns reflected in the behaviour of associated words.
  284. enum Gender {
  285. // Gender is not applicable in the analyzed language or is not predicted.
  286. GENDER_UNKNOWN = 0;
  287. // Feminine
  288. FEMININE = 1;
  289. // Masculine
  290. MASCULINE = 2;
  291. // Neuter
  292. NEUTER = 3;
  293. }
  294. // The grammatical feature of verbs, used for showing modality and attitude.
  295. enum Mood {
  296. // Mood is not applicable in the analyzed language or is not predicted.
  297. MOOD_UNKNOWN = 0;
  298. // Conditional
  299. CONDITIONAL_MOOD = 1;
  300. // Imperative
  301. IMPERATIVE = 2;
  302. // Indicative
  303. INDICATIVE = 3;
  304. // Interrogative
  305. INTERROGATIVE = 4;
  306. // Jussive
  307. JUSSIVE = 5;
  308. // Subjunctive
  309. SUBJUNCTIVE = 6;
  310. }
  311. // Count distinctions.
  312. enum Number {
  313. // Number is not applicable in the analyzed language or is not predicted.
  314. NUMBER_UNKNOWN = 0;
  315. // Singular
  316. SINGULAR = 1;
  317. // Plural
  318. PLURAL = 2;
  319. // Dual
  320. DUAL = 3;
  321. }
  322. // The distinction between the speaker, second person, third person, etc.
  323. enum Person {
  324. // Person is not applicable in the analyzed language or is not predicted.
  325. PERSON_UNKNOWN = 0;
  326. // First
  327. FIRST = 1;
  328. // Second
  329. SECOND = 2;
  330. // Third
  331. THIRD = 3;
  332. // Reflexive
  333. REFLEXIVE_PERSON = 4;
  334. }
  335. // This category shows if the token is part of a proper name.
  336. enum Proper {
  337. // Proper is not applicable in the analyzed language or is not predicted.
  338. PROPER_UNKNOWN = 0;
  339. // Proper
  340. PROPER = 1;
  341. // Not proper
  342. NOT_PROPER = 2;
  343. }
  344. // Reciprocal features of a pronoun.
  345. enum Reciprocity {
  346. // Reciprocity is not applicable in the analyzed language or is not
  347. // predicted.
  348. RECIPROCITY_UNKNOWN = 0;
  349. // Reciprocal
  350. RECIPROCAL = 1;
  351. // Non-reciprocal
  352. NON_RECIPROCAL = 2;
  353. }
  354. // Time reference.
  355. enum Tense {
  356. // Tense is not applicable in the analyzed language or is not predicted.
  357. TENSE_UNKNOWN = 0;
  358. // Conditional
  359. CONDITIONAL_TENSE = 1;
  360. // Future
  361. FUTURE = 2;
  362. // Past
  363. PAST = 3;
  364. // Present
  365. PRESENT = 4;
  366. // Imperfect
  367. IMPERFECT = 5;
  368. // Pluperfect
  369. PLUPERFECT = 6;
  370. }
  371. // The relationship between the action that a verb expresses and the
  372. // participants identified by its arguments.
  373. enum Voice {
  374. // Voice is not applicable in the analyzed language or is not predicted.
  375. VOICE_UNKNOWN = 0;
  376. // Active
  377. ACTIVE = 1;
  378. // Causative
  379. CAUSATIVE = 2;
  380. // Passive
  381. PASSIVE = 3;
  382. }
  383. // The part of speech tag.
  384. Tag tag = 1;
  385. // The grammatical aspect.
  386. Aspect aspect = 2;
  387. // The grammatical case.
  388. Case case = 3;
  389. // The grammatical form.
  390. Form form = 4;
  391. // The grammatical gender.
  392. Gender gender = 5;
  393. // The grammatical mood.
  394. Mood mood = 6;
  395. // The grammatical number.
  396. Number number = 7;
  397. // The grammatical person.
  398. Person person = 8;
  399. // The grammatical properness.
  400. Proper proper = 9;
  401. // The grammatical reciprocity.
  402. Reciprocity reciprocity = 10;
  403. // The grammatical tense.
  404. Tense tense = 11;
  405. // The grammatical voice.
  406. Voice voice = 12;
  407. }
  408. // Represents dependency parse tree information for a token.
  409. message DependencyEdge {
  410. // The parse label enum for the token.
  411. enum Label {
  412. // Unknown
  413. UNKNOWN = 0;
  414. // Abbreviation modifier
  415. ABBREV = 1;
  416. // Adjectival complement
  417. ACOMP = 2;
  418. // Adverbial clause modifier
  419. ADVCL = 3;
  420. // Adverbial modifier
  421. ADVMOD = 4;
  422. // Adjectival modifier of an NP
  423. AMOD = 5;
  424. // Appositional modifier of an NP
  425. APPOS = 6;
  426. // Attribute dependent of a copular verb
  427. ATTR = 7;
  428. // Auxiliary (non-main) verb
  429. AUX = 8;
  430. // Passive auxiliary
  431. AUXPASS = 9;
  432. // Coordinating conjunction
  433. CC = 10;
  434. // Clausal complement of a verb or adjective
  435. CCOMP = 11;
  436. // Conjunct
  437. CONJ = 12;
  438. // Clausal subject
  439. CSUBJ = 13;
  440. // Clausal passive subject
  441. CSUBJPASS = 14;
  442. // Dependency (unable to determine)
  443. DEP = 15;
  444. // Determiner
  445. DET = 16;
  446. // Discourse
  447. DISCOURSE = 17;
  448. // Direct object
  449. DOBJ = 18;
  450. // Expletive
  451. EXPL = 19;
  452. // Goes with (part of a word in a text not well edited)
  453. GOESWITH = 20;
  454. // Indirect object
  455. IOBJ = 21;
  456. // Marker (word introducing a subordinate clause)
  457. MARK = 22;
  458. // Multi-word expression
  459. MWE = 23;
  460. // Multi-word verbal expression
  461. MWV = 24;
  462. // Negation modifier
  463. NEG = 25;
  464. // Noun compound modifier
  465. NN = 26;
  466. // Noun phrase used as an adverbial modifier
  467. NPADVMOD = 27;
  468. // Nominal subject
  469. NSUBJ = 28;
  470. // Passive nominal subject
  471. NSUBJPASS = 29;
  472. // Numeric modifier of a noun
  473. NUM = 30;
  474. // Element of compound number
  475. NUMBER = 31;
  476. // Punctuation mark
  477. P = 32;
  478. // Parataxis relation
  479. PARATAXIS = 33;
  480. // Participial modifier
  481. PARTMOD = 34;
  482. // The complement of a preposition is a clause
  483. PCOMP = 35;
  484. // Object of a preposition
  485. POBJ = 36;
  486. // Possession modifier
  487. POSS = 37;
  488. // Postverbal negative particle
  489. POSTNEG = 38;
  490. // Predicate complement
  491. PRECOMP = 39;
  492. // Preconjunt
  493. PRECONJ = 40;
  494. // Predeterminer
  495. PREDET = 41;
  496. // Prefix
  497. PREF = 42;
  498. // Prepositional modifier
  499. PREP = 43;
  500. // The relationship between a verb and verbal morpheme
  501. PRONL = 44;
  502. // Particle
  503. PRT = 45;
  504. // Associative or possessive marker
  505. PS = 46;
  506. // Quantifier phrase modifier
  507. QUANTMOD = 47;
  508. // Relative clause modifier
  509. RCMOD = 48;
  510. // Complementizer in relative clause
  511. RCMODREL = 49;
  512. // Ellipsis without a preceding predicate
  513. RDROP = 50;
  514. // Referent
  515. REF = 51;
  516. // Remnant
  517. REMNANT = 52;
  518. // Reparandum
  519. REPARANDUM = 53;
  520. // Root
  521. ROOT = 54;
  522. // Suffix specifying a unit of number
  523. SNUM = 55;
  524. // Suffix
  525. SUFF = 56;
  526. // Temporal modifier
  527. TMOD = 57;
  528. // Topic marker
  529. TOPIC = 58;
  530. // Clause headed by an infinite form of the verb that modifies a noun
  531. VMOD = 59;
  532. // Vocative
  533. VOCATIVE = 60;
  534. // Open clausal complement
  535. XCOMP = 61;
  536. // Name suffix
  537. SUFFIX = 62;
  538. // Name title
  539. TITLE = 63;
  540. // Adverbial phrase modifier
  541. ADVPHMOD = 64;
  542. // Causative auxiliary
  543. AUXCAUS = 65;
  544. // Helper auxiliary
  545. AUXVV = 66;
  546. // Rentaishi (Prenominal modifier)
  547. DTMOD = 67;
  548. // Foreign words
  549. FOREIGN = 68;
  550. // Keyword
  551. KW = 69;
  552. // List for chains of comparable items
  553. LIST = 70;
  554. // Nominalized clause
  555. NOMC = 71;
  556. // Nominalized clausal subject
  557. NOMCSUBJ = 72;
  558. // Nominalized clausal passive
  559. NOMCSUBJPASS = 73;
  560. // Compound of numeric modifier
  561. NUMC = 74;
  562. // Copula
  563. COP = 75;
  564. // Dislocated relation (for fronted/topicalized elements)
  565. DISLOCATED = 76;
  566. }
  567. // Represents the head of this token in the dependency tree.
  568. // This is the index of the token which has an arc going to this token.
  569. // The index is the position of the token in the array of tokens returned
  570. // by the API method. If this token is a root token, then the
  571. // `head_token_index` is its own index.
  572. int32 head_token_index = 1;
  573. // The parse label for the token.
  574. Label label = 2;
  575. }
  576. // Represents a mention for an entity in the text. Currently, proper noun
  577. // mentions are supported.
  578. message EntityMention {
  579. // The supported types of mentions.
  580. enum Type {
  581. // Unknown
  582. TYPE_UNKNOWN = 0;
  583. // Proper name
  584. PROPER = 1;
  585. // Common noun (or noun compound)
  586. COMMON = 2;
  587. }
  588. // The mention text.
  589. TextSpan text = 1;
  590. // The type of the entity mention.
  591. Type type = 2;
  592. }
  593. // Represents an output piece of text.
  594. message TextSpan {
  595. // The content of the output text.
  596. string content = 1;
  597. // The API calculates the beginning offset of the content in the original
  598. // document according to the
  599. // [EncodingType][google.cloud.language.v1beta1.EncodingType] specified in the
  600. // API request.
  601. int32 begin_offset = 2;
  602. }
  603. // The sentiment analysis request message.
  604. message AnalyzeSentimentRequest {
  605. // Input document.
  606. Document document = 1;
  607. // The encoding type used by the API to calculate sentence offsets for the
  608. // sentence sentiment.
  609. EncodingType encoding_type = 2;
  610. }
  611. // The sentiment analysis response message.
  612. message AnalyzeSentimentResponse {
  613. // The overall sentiment of the input document.
  614. Sentiment document_sentiment = 1;
  615. // The language of the text, which will be the same as the language specified
  616. // in the request or, if not specified, the automatically-detected language.
  617. // See [Document.language][google.cloud.language.v1beta1.Document.language]
  618. // field for more details.
  619. string language = 2;
  620. // The sentiment for all the sentences in the document.
  621. repeated Sentence sentences = 3;
  622. }
  623. // The entity analysis request message.
  624. message AnalyzeEntitiesRequest {
  625. // Input document.
  626. Document document = 1;
  627. // The encoding type used by the API to calculate offsets.
  628. EncodingType encoding_type = 2;
  629. }
  630. // The entity analysis response message.
  631. message AnalyzeEntitiesResponse {
  632. // The recognized entities in the input document.
  633. repeated Entity entities = 1;
  634. // The language of the text, which will be the same as the language specified
  635. // in the request or, if not specified, the automatically-detected language.
  636. // See [Document.language][google.cloud.language.v1beta1.Document.language]
  637. // field for more details.
  638. string language = 2;
  639. }
  640. // The syntax analysis request message.
  641. message AnalyzeSyntaxRequest {
  642. // Input document.
  643. Document document = 1;
  644. // The encoding type used by the API to calculate offsets.
  645. EncodingType encoding_type = 2;
  646. }
  647. // The syntax analysis response message.
  648. message AnalyzeSyntaxResponse {
  649. // Sentences in the input document.
  650. repeated Sentence sentences = 1;
  651. // Tokens, along with their syntactic information, in the input document.
  652. repeated Token tokens = 2;
  653. // The language of the text, which will be the same as the language specified
  654. // in the request or, if not specified, the automatically-detected language.
  655. // See [Document.language][google.cloud.language.v1beta1.Document.language]
  656. // field for more details.
  657. string language = 3;
  658. }
  659. // The request message for the text annotation API, which can perform multiple
  660. // analysis types (sentiment, entities, and syntax) in one call.
  661. message AnnotateTextRequest {
  662. // All available features for sentiment, syntax, and semantic analysis.
  663. // Setting each one to true will enable that specific analysis for the input.
  664. message Features {
  665. // Extract syntax information.
  666. bool extract_syntax = 1;
  667. // Extract entities.
  668. bool extract_entities = 2;
  669. // Extract document-level sentiment.
  670. bool extract_document_sentiment = 3;
  671. }
  672. // Input document.
  673. Document document = 1;
  674. // The enabled features.
  675. Features features = 2;
  676. // The encoding type used by the API to calculate offsets.
  677. EncodingType encoding_type = 3;
  678. }
  679. // The text annotations response message.
  680. message AnnotateTextResponse {
  681. // Sentences in the input document. Populated if the user enables
  682. // [AnnotateTextRequest.Features.extract_syntax][google.cloud.language.v1beta1.AnnotateTextRequest.Features.extract_syntax].
  683. repeated Sentence sentences = 1;
  684. // Tokens, along with their syntactic information, in the input document.
  685. // Populated if the user enables
  686. // [AnnotateTextRequest.Features.extract_syntax][google.cloud.language.v1beta1.AnnotateTextRequest.Features.extract_syntax].
  687. repeated Token tokens = 2;
  688. // Entities, along with their semantic information, in the input document.
  689. // Populated if the user enables
  690. // [AnnotateTextRequest.Features.extract_entities][google.cloud.language.v1beta1.AnnotateTextRequest.Features.extract_entities].
  691. repeated Entity entities = 3;
  692. // The overall sentiment for the document. Populated if the user enables
  693. // [AnnotateTextRequest.Features.extract_document_sentiment][google.cloud.language.v1beta1.AnnotateTextRequest.Features.extract_document_sentiment].
  694. Sentiment document_sentiment = 4;
  695. // The language of the text, which will be the same as the language specified
  696. // in the request or, if not specified, the automatically-detected language.
  697. // See [Document.language][google.cloud.language.v1beta1.Document.language]
  698. // field for more details.
  699. string language = 5;
  700. }
  701. // Represents the text encoding that the caller uses to process the output.
  702. // Providing an `EncodingType` is recommended because the API provides the
  703. // beginning offsets for various outputs, such as tokens and mentions, and
  704. // languages that natively use different text encodings may access offsets
  705. // differently.
  706. enum EncodingType {
  707. // If `EncodingType` is not specified, encoding-dependent information (such as
  708. // `begin_offset`) will be set at `-1`.
  709. NONE = 0;
  710. // Encoding-dependent information (such as `begin_offset`) is calculated based
  711. // on the UTF-8 encoding of the input. C++ and Go are examples of languages
  712. // that use this encoding natively.
  713. UTF8 = 1;
  714. // Encoding-dependent information (such as `begin_offset`) is calculated based
  715. // on the UTF-16 encoding of the input. Java and Javascript are examples of
  716. // languages that use this encoding natively.
  717. UTF16 = 2;
  718. // Encoding-dependent information (such as `begin_offset`) is calculated based
  719. // on the UTF-32 encoding of the input. Python is an example of a language
  720. // that uses this encoding natively.
  721. UTF32 = 3;
  722. }