You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

2273 lines
82 KiB

  1. // Package language provides access to the Cloud Natural Language API.
  2. //
  3. // See https://cloud.google.com/natural-language/
  4. //
  5. // Usage example:
  6. //
  7. // import "google.golang.org/api/language/v1"
  8. // ...
  9. // languageService, err := language.New(oauthHttpClient)
  10. package language // import "google.golang.org/api/language/v1"
  11. import (
  12. "bytes"
  13. "encoding/json"
  14. "errors"
  15. "fmt"
  16. context "golang.org/x/net/context"
  17. ctxhttp "golang.org/x/net/context/ctxhttp"
  18. gensupport "google.golang.org/api/gensupport"
  19. googleapi "google.golang.org/api/googleapi"
  20. "io"
  21. "net/http"
  22. "net/url"
  23. "strconv"
  24. "strings"
  25. )
  26. // Always reference these packages, just in case the auto-generated code
  27. // below doesn't.
  28. var _ = bytes.NewBuffer
  29. var _ = strconv.Itoa
  30. var _ = fmt.Sprintf
  31. var _ = json.NewDecoder
  32. var _ = io.Copy
  33. var _ = url.Parse
  34. var _ = gensupport.MarshalJSON
  35. var _ = googleapi.Version
  36. var _ = errors.New
  37. var _ = strings.Replace
  38. var _ = context.Canceled
  39. var _ = ctxhttp.Do
  40. const apiId = "language:v1"
  41. const apiName = "language"
  42. const apiVersion = "v1"
  43. const basePath = "https://language.googleapis.com/"
  44. // OAuth2 scopes used by this API.
  45. const (
  46. // Apply machine learning models to reveal the structure and meaning of
  47. // text
  48. CloudLanguageScope = "https://www.googleapis.com/auth/cloud-language"
  49. // View and manage your data across Google Cloud Platform services
  50. CloudPlatformScope = "https://www.googleapis.com/auth/cloud-platform"
  51. )
  52. func New(client *http.Client) (*Service, error) {
  53. if client == nil {
  54. return nil, errors.New("client is nil")
  55. }
  56. s := &Service{client: client, BasePath: basePath}
  57. s.Documents = NewDocumentsService(s)
  58. return s, nil
  59. }
  60. type Service struct {
  61. client *http.Client
  62. BasePath string // API endpoint base URL
  63. UserAgent string // optional additional User-Agent fragment
  64. Documents *DocumentsService
  65. }
  66. func (s *Service) userAgent() string {
  67. if s.UserAgent == "" {
  68. return googleapi.UserAgent
  69. }
  70. return googleapi.UserAgent + " " + s.UserAgent
  71. }
  72. func NewDocumentsService(s *Service) *DocumentsService {
  73. rs := &DocumentsService{s: s}
  74. return rs
  75. }
  76. type DocumentsService struct {
  77. s *Service
  78. }
  79. // AnalyzeEntitiesRequest: The entity analysis request message.
  80. type AnalyzeEntitiesRequest struct {
  81. // Document: Input document.
  82. Document *Document `json:"document,omitempty"`
  83. // EncodingType: The encoding type used by the API to calculate offsets.
  84. //
  85. // Possible values:
  86. // "NONE" - If `EncodingType` is not specified, encoding-dependent
  87. // information (such as
  88. // `begin_offset`) will be set at `-1`.
  89. // "UTF8" - Encoding-dependent information (such as `begin_offset`) is
  90. // calculated based
  91. // on the UTF-8 encoding of the input. C++ and Go are examples of
  92. // languages
  93. // that use this encoding natively.
  94. // "UTF16" - Encoding-dependent information (such as `begin_offset`)
  95. // is calculated based
  96. // on the UTF-16 encoding of the input. Java and Javascript are examples
  97. // of
  98. // languages that use this encoding natively.
  99. // "UTF32" - Encoding-dependent information (such as `begin_offset`)
  100. // is calculated based
  101. // on the UTF-32 encoding of the input. Python is an example of a
  102. // language
  103. // that uses this encoding natively.
  104. EncodingType string `json:"encodingType,omitempty"`
  105. // ForceSendFields is a list of field names (e.g. "Document") to
  106. // unconditionally include in API requests. By default, fields with
  107. // empty values are omitted from API requests. However, any non-pointer,
  108. // non-interface field appearing in ForceSendFields will be sent to the
  109. // server regardless of whether the field is empty or not. This may be
  110. // used to include empty fields in Patch requests.
  111. ForceSendFields []string `json:"-"`
  112. // NullFields is a list of field names (e.g. "Document") to include in
  113. // API requests with the JSON null value. By default, fields with empty
  114. // values are omitted from API requests. However, any field with an
  115. // empty value appearing in NullFields will be sent to the server as
  116. // null. It is an error if a field in this list has a non-empty value.
  117. // This may be used to include null fields in Patch requests.
  118. NullFields []string `json:"-"`
  119. }
  120. func (s *AnalyzeEntitiesRequest) MarshalJSON() ([]byte, error) {
  121. type NoMethod AnalyzeEntitiesRequest
  122. raw := NoMethod(*s)
  123. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  124. }
  125. // AnalyzeEntitiesResponse: The entity analysis response message.
  126. type AnalyzeEntitiesResponse struct {
  127. // Entities: The recognized entities in the input document.
  128. Entities []*Entity `json:"entities,omitempty"`
  129. // Language: The language of the text, which will be the same as the
  130. // language specified
  131. // in the request or, if not specified, the automatically-detected
  132. // language.
  133. // See Document.language field for more details.
  134. Language string `json:"language,omitempty"`
  135. // ServerResponse contains the HTTP response code and headers from the
  136. // server.
  137. googleapi.ServerResponse `json:"-"`
  138. // ForceSendFields is a list of field names (e.g. "Entities") to
  139. // unconditionally include in API requests. By default, fields with
  140. // empty values are omitted from API requests. However, any non-pointer,
  141. // non-interface field appearing in ForceSendFields will be sent to the
  142. // server regardless of whether the field is empty or not. This may be
  143. // used to include empty fields in Patch requests.
  144. ForceSendFields []string `json:"-"`
  145. // NullFields is a list of field names (e.g. "Entities") to include in
  146. // API requests with the JSON null value. By default, fields with empty
  147. // values are omitted from API requests. However, any field with an
  148. // empty value appearing in NullFields will be sent to the server as
  149. // null. It is an error if a field in this list has a non-empty value.
  150. // This may be used to include null fields in Patch requests.
  151. NullFields []string `json:"-"`
  152. }
  153. func (s *AnalyzeEntitiesResponse) MarshalJSON() ([]byte, error) {
  154. type NoMethod AnalyzeEntitiesResponse
  155. raw := NoMethod(*s)
  156. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  157. }
  158. // AnalyzeEntitySentimentRequest: The entity-level sentiment analysis
  159. // request message.
  160. type AnalyzeEntitySentimentRequest struct {
  161. // Document: Input document.
  162. Document *Document `json:"document,omitempty"`
  163. // EncodingType: The encoding type used by the API to calculate offsets.
  164. //
  165. // Possible values:
  166. // "NONE" - If `EncodingType` is not specified, encoding-dependent
  167. // information (such as
  168. // `begin_offset`) will be set at `-1`.
  169. // "UTF8" - Encoding-dependent information (such as `begin_offset`) is
  170. // calculated based
  171. // on the UTF-8 encoding of the input. C++ and Go are examples of
  172. // languages
  173. // that use this encoding natively.
  174. // "UTF16" - Encoding-dependent information (such as `begin_offset`)
  175. // is calculated based
  176. // on the UTF-16 encoding of the input. Java and Javascript are examples
  177. // of
  178. // languages that use this encoding natively.
  179. // "UTF32" - Encoding-dependent information (such as `begin_offset`)
  180. // is calculated based
  181. // on the UTF-32 encoding of the input. Python is an example of a
  182. // language
  183. // that uses this encoding natively.
  184. EncodingType string `json:"encodingType,omitempty"`
  185. // ForceSendFields is a list of field names (e.g. "Document") to
  186. // unconditionally include in API requests. By default, fields with
  187. // empty values are omitted from API requests. However, any non-pointer,
  188. // non-interface field appearing in ForceSendFields will be sent to the
  189. // server regardless of whether the field is empty or not. This may be
  190. // used to include empty fields in Patch requests.
  191. ForceSendFields []string `json:"-"`
  192. // NullFields is a list of field names (e.g. "Document") to include in
  193. // API requests with the JSON null value. By default, fields with empty
  194. // values are omitted from API requests. However, any field with an
  195. // empty value appearing in NullFields will be sent to the server as
  196. // null. It is an error if a field in this list has a non-empty value.
  197. // This may be used to include null fields in Patch requests.
  198. NullFields []string `json:"-"`
  199. }
  200. func (s *AnalyzeEntitySentimentRequest) MarshalJSON() ([]byte, error) {
  201. type NoMethod AnalyzeEntitySentimentRequest
  202. raw := NoMethod(*s)
  203. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  204. }
  205. // AnalyzeEntitySentimentResponse: The entity-level sentiment analysis
  206. // response message.
  207. type AnalyzeEntitySentimentResponse struct {
  208. // Entities: The recognized entities in the input document with
  209. // associated sentiments.
  210. Entities []*Entity `json:"entities,omitempty"`
  211. // Language: The language of the text, which will be the same as the
  212. // language specified
  213. // in the request or, if not specified, the automatically-detected
  214. // language.
  215. // See Document.language field for more details.
  216. Language string `json:"language,omitempty"`
  217. // ServerResponse contains the HTTP response code and headers from the
  218. // server.
  219. googleapi.ServerResponse `json:"-"`
  220. // ForceSendFields is a list of field names (e.g. "Entities") to
  221. // unconditionally include in API requests. By default, fields with
  222. // empty values are omitted from API requests. However, any non-pointer,
  223. // non-interface field appearing in ForceSendFields will be sent to the
  224. // server regardless of whether the field is empty or not. This may be
  225. // used to include empty fields in Patch requests.
  226. ForceSendFields []string `json:"-"`
  227. // NullFields is a list of field names (e.g. "Entities") to include in
  228. // API requests with the JSON null value. By default, fields with empty
  229. // values are omitted from API requests. However, any field with an
  230. // empty value appearing in NullFields will be sent to the server as
  231. // null. It is an error if a field in this list has a non-empty value.
  232. // This may be used to include null fields in Patch requests.
  233. NullFields []string `json:"-"`
  234. }
  235. func (s *AnalyzeEntitySentimentResponse) MarshalJSON() ([]byte, error) {
  236. type NoMethod AnalyzeEntitySentimentResponse
  237. raw := NoMethod(*s)
  238. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  239. }
  240. // AnalyzeSentimentRequest: The sentiment analysis request message.
  241. type AnalyzeSentimentRequest struct {
  242. // Document: Input document.
  243. Document *Document `json:"document,omitempty"`
  244. // EncodingType: The encoding type used by the API to calculate sentence
  245. // offsets.
  246. //
  247. // Possible values:
  248. // "NONE" - If `EncodingType` is not specified, encoding-dependent
  249. // information (such as
  250. // `begin_offset`) will be set at `-1`.
  251. // "UTF8" - Encoding-dependent information (such as `begin_offset`) is
  252. // calculated based
  253. // on the UTF-8 encoding of the input. C++ and Go are examples of
  254. // languages
  255. // that use this encoding natively.
  256. // "UTF16" - Encoding-dependent information (such as `begin_offset`)
  257. // is calculated based
  258. // on the UTF-16 encoding of the input. Java and Javascript are examples
  259. // of
  260. // languages that use this encoding natively.
  261. // "UTF32" - Encoding-dependent information (such as `begin_offset`)
  262. // is calculated based
  263. // on the UTF-32 encoding of the input. Python is an example of a
  264. // language
  265. // that uses this encoding natively.
  266. EncodingType string `json:"encodingType,omitempty"`
  267. // ForceSendFields is a list of field names (e.g. "Document") to
  268. // unconditionally include in API requests. By default, fields with
  269. // empty values are omitted from API requests. However, any non-pointer,
  270. // non-interface field appearing in ForceSendFields will be sent to the
  271. // server regardless of whether the field is empty or not. This may be
  272. // used to include empty fields in Patch requests.
  273. ForceSendFields []string `json:"-"`
  274. // NullFields is a list of field names (e.g. "Document") to include in
  275. // API requests with the JSON null value. By default, fields with empty
  276. // values are omitted from API requests. However, any field with an
  277. // empty value appearing in NullFields will be sent to the server as
  278. // null. It is an error if a field in this list has a non-empty value.
  279. // This may be used to include null fields in Patch requests.
  280. NullFields []string `json:"-"`
  281. }
  282. func (s *AnalyzeSentimentRequest) MarshalJSON() ([]byte, error) {
  283. type NoMethod AnalyzeSentimentRequest
  284. raw := NoMethod(*s)
  285. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  286. }
  287. // AnalyzeSentimentResponse: The sentiment analysis response message.
  288. type AnalyzeSentimentResponse struct {
  289. // DocumentSentiment: The overall sentiment of the input document.
  290. DocumentSentiment *Sentiment `json:"documentSentiment,omitempty"`
  291. // Language: The language of the text, which will be the same as the
  292. // language specified
  293. // in the request or, if not specified, the automatically-detected
  294. // language.
  295. // See Document.language field for more details.
  296. Language string `json:"language,omitempty"`
  297. // Sentences: The sentiment for all the sentences in the document.
  298. Sentences []*Sentence `json:"sentences,omitempty"`
  299. // ServerResponse contains the HTTP response code and headers from the
  300. // server.
  301. googleapi.ServerResponse `json:"-"`
  302. // ForceSendFields is a list of field names (e.g. "DocumentSentiment")
  303. // to unconditionally include in API requests. By default, fields with
  304. // empty values are omitted from API requests. However, any non-pointer,
  305. // non-interface field appearing in ForceSendFields will be sent to the
  306. // server regardless of whether the field is empty or not. This may be
  307. // used to include empty fields in Patch requests.
  308. ForceSendFields []string `json:"-"`
  309. // NullFields is a list of field names (e.g. "DocumentSentiment") to
  310. // include in API requests with the JSON null value. By default, fields
  311. // with empty values are omitted from API requests. However, any field
  312. // with an empty value appearing in NullFields will be sent to the
  313. // server as null. It is an error if a field in this list has a
  314. // non-empty value. This may be used to include null fields in Patch
  315. // requests.
  316. NullFields []string `json:"-"`
  317. }
  318. func (s *AnalyzeSentimentResponse) MarshalJSON() ([]byte, error) {
  319. type NoMethod AnalyzeSentimentResponse
  320. raw := NoMethod(*s)
  321. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  322. }
  323. // AnalyzeSyntaxRequest: The syntax analysis request message.
  324. type AnalyzeSyntaxRequest struct {
  325. // Document: Input document.
  326. Document *Document `json:"document,omitempty"`
  327. // EncodingType: The encoding type used by the API to calculate offsets.
  328. //
  329. // Possible values:
  330. // "NONE" - If `EncodingType` is not specified, encoding-dependent
  331. // information (such as
  332. // `begin_offset`) will be set at `-1`.
  333. // "UTF8" - Encoding-dependent information (such as `begin_offset`) is
  334. // calculated based
  335. // on the UTF-8 encoding of the input. C++ and Go are examples of
  336. // languages
  337. // that use this encoding natively.
  338. // "UTF16" - Encoding-dependent information (such as `begin_offset`)
  339. // is calculated based
  340. // on the UTF-16 encoding of the input. Java and Javascript are examples
  341. // of
  342. // languages that use this encoding natively.
  343. // "UTF32" - Encoding-dependent information (such as `begin_offset`)
  344. // is calculated based
  345. // on the UTF-32 encoding of the input. Python is an example of a
  346. // language
  347. // that uses this encoding natively.
  348. EncodingType string `json:"encodingType,omitempty"`
  349. // ForceSendFields is a list of field names (e.g. "Document") to
  350. // unconditionally include in API requests. By default, fields with
  351. // empty values are omitted from API requests. However, any non-pointer,
  352. // non-interface field appearing in ForceSendFields will be sent to the
  353. // server regardless of whether the field is empty or not. This may be
  354. // used to include empty fields in Patch requests.
  355. ForceSendFields []string `json:"-"`
  356. // NullFields is a list of field names (e.g. "Document") to include in
  357. // API requests with the JSON null value. By default, fields with empty
  358. // values are omitted from API requests. However, any field with an
  359. // empty value appearing in NullFields will be sent to the server as
  360. // null. It is an error if a field in this list has a non-empty value.
  361. // This may be used to include null fields in Patch requests.
  362. NullFields []string `json:"-"`
  363. }
  364. func (s *AnalyzeSyntaxRequest) MarshalJSON() ([]byte, error) {
  365. type NoMethod AnalyzeSyntaxRequest
  366. raw := NoMethod(*s)
  367. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  368. }
  369. // AnalyzeSyntaxResponse: The syntax analysis response message.
  370. type AnalyzeSyntaxResponse struct {
  371. // Language: The language of the text, which will be the same as the
  372. // language specified
  373. // in the request or, if not specified, the automatically-detected
  374. // language.
  375. // See Document.language field for more details.
  376. Language string `json:"language,omitempty"`
  377. // Sentences: Sentences in the input document.
  378. Sentences []*Sentence `json:"sentences,omitempty"`
  379. // Tokens: Tokens, along with their syntactic information, in the input
  380. // document.
  381. Tokens []*Token `json:"tokens,omitempty"`
  382. // ServerResponse contains the HTTP response code and headers from the
  383. // server.
  384. googleapi.ServerResponse `json:"-"`
  385. // ForceSendFields is a list of field names (e.g. "Language") to
  386. // unconditionally include in API requests. By default, fields with
  387. // empty values are omitted from API requests. However, any non-pointer,
  388. // non-interface field appearing in ForceSendFields will be sent to the
  389. // server regardless of whether the field is empty or not. This may be
  390. // used to include empty fields in Patch requests.
  391. ForceSendFields []string `json:"-"`
  392. // NullFields is a list of field names (e.g. "Language") to include in
  393. // API requests with the JSON null value. By default, fields with empty
  394. // values are omitted from API requests. However, any field with an
  395. // empty value appearing in NullFields will be sent to the server as
  396. // null. It is an error if a field in this list has a non-empty value.
  397. // This may be used to include null fields in Patch requests.
  398. NullFields []string `json:"-"`
  399. }
  400. func (s *AnalyzeSyntaxResponse) MarshalJSON() ([]byte, error) {
  401. type NoMethod AnalyzeSyntaxResponse
  402. raw := NoMethod(*s)
  403. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  404. }
  405. // AnnotateTextRequest: The request message for the text annotation API,
  406. // which can perform multiple
  407. // analysis types (sentiment, entities, and syntax) in one call.
  408. type AnnotateTextRequest struct {
  409. // Document: Input document.
  410. Document *Document `json:"document,omitempty"`
  411. // EncodingType: The encoding type used by the API to calculate offsets.
  412. //
  413. // Possible values:
  414. // "NONE" - If `EncodingType` is not specified, encoding-dependent
  415. // information (such as
  416. // `begin_offset`) will be set at `-1`.
  417. // "UTF8" - Encoding-dependent information (such as `begin_offset`) is
  418. // calculated based
  419. // on the UTF-8 encoding of the input. C++ and Go are examples of
  420. // languages
  421. // that use this encoding natively.
  422. // "UTF16" - Encoding-dependent information (such as `begin_offset`)
  423. // is calculated based
  424. // on the UTF-16 encoding of the input. Java and Javascript are examples
  425. // of
  426. // languages that use this encoding natively.
  427. // "UTF32" - Encoding-dependent information (such as `begin_offset`)
  428. // is calculated based
  429. // on the UTF-32 encoding of the input. Python is an example of a
  430. // language
  431. // that uses this encoding natively.
  432. EncodingType string `json:"encodingType,omitempty"`
  433. // Features: The enabled features.
  434. Features *Features `json:"features,omitempty"`
  435. // ForceSendFields is a list of field names (e.g. "Document") to
  436. // unconditionally include in API requests. By default, fields with
  437. // empty values are omitted from API requests. However, any non-pointer,
  438. // non-interface field appearing in ForceSendFields will be sent to the
  439. // server regardless of whether the field is empty or not. This may be
  440. // used to include empty fields in Patch requests.
  441. ForceSendFields []string `json:"-"`
  442. // NullFields is a list of field names (e.g. "Document") to include in
  443. // API requests with the JSON null value. By default, fields with empty
  444. // values are omitted from API requests. However, any field with an
  445. // empty value appearing in NullFields will be sent to the server as
  446. // null. It is an error if a field in this list has a non-empty value.
  447. // This may be used to include null fields in Patch requests.
  448. NullFields []string `json:"-"`
  449. }
  450. func (s *AnnotateTextRequest) MarshalJSON() ([]byte, error) {
  451. type NoMethod AnnotateTextRequest
  452. raw := NoMethod(*s)
  453. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  454. }
  455. // AnnotateTextResponse: The text annotations response message.
  456. type AnnotateTextResponse struct {
  457. // Categories: Categories identified in the input document.
  458. Categories []*ClassificationCategory `json:"categories,omitempty"`
  459. // DocumentSentiment: The overall sentiment for the document. Populated
  460. // if the user
  461. // enables
  462. // AnnotateTextRequest.Features.extract_document_sentiment.
  463. DocumentSentiment *Sentiment `json:"documentSentiment,omitempty"`
  464. // Entities: Entities, along with their semantic information, in the
  465. // input document.
  466. // Populated if the user
  467. // enables
  468. // AnnotateTextRequest.Features.extract_entities.
  469. Entities []*Entity `json:"entities,omitempty"`
  470. // Language: The language of the text, which will be the same as the
  471. // language specified
  472. // in the request or, if not specified, the automatically-detected
  473. // language.
  474. // See Document.language field for more details.
  475. Language string `json:"language,omitempty"`
  476. // Sentences: Sentences in the input document. Populated if the user
  477. // enables
  478. // AnnotateTextRequest.Features.extract_syntax.
  479. Sentences []*Sentence `json:"sentences,omitempty"`
  480. // Tokens: Tokens, along with their syntactic information, in the input
  481. // document.
  482. // Populated if the user
  483. // enables
  484. // AnnotateTextRequest.Features.extract_syntax.
  485. Tokens []*Token `json:"tokens,omitempty"`
  486. // ServerResponse contains the HTTP response code and headers from the
  487. // server.
  488. googleapi.ServerResponse `json:"-"`
  489. // ForceSendFields is a list of field names (e.g. "Categories") to
  490. // unconditionally include in API requests. By default, fields with
  491. // empty values are omitted from API requests. However, any non-pointer,
  492. // non-interface field appearing in ForceSendFields will be sent to the
  493. // server regardless of whether the field is empty or not. This may be
  494. // used to include empty fields in Patch requests.
  495. ForceSendFields []string `json:"-"`
  496. // NullFields is a list of field names (e.g. "Categories") to include in
  497. // API requests with the JSON null value. By default, fields with empty
  498. // values are omitted from API requests. However, any field with an
  499. // empty value appearing in NullFields will be sent to the server as
  500. // null. It is an error if a field in this list has a non-empty value.
  501. // This may be used to include null fields in Patch requests.
  502. NullFields []string `json:"-"`
  503. }
  504. func (s *AnnotateTextResponse) MarshalJSON() ([]byte, error) {
  505. type NoMethod AnnotateTextResponse
  506. raw := NoMethod(*s)
  507. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  508. }
  509. // ClassificationCategory: Represents a category returned from the text
  510. // classifier.
  511. type ClassificationCategory struct {
  512. // Confidence: The classifier's confidence of the category. Number
  513. // represents how certain
  514. // the classifier is that this category represents the given text.
  515. Confidence float64 `json:"confidence,omitempty"`
  516. // Name: The name of the category representing the document, from the
  517. // [predefined
  518. // taxonomy](/natural-language/docs/categories).
  519. Name string `json:"name,omitempty"`
  520. // ForceSendFields is a list of field names (e.g. "Confidence") to
  521. // unconditionally include in API requests. By default, fields with
  522. // empty values are omitted from API requests. However, any non-pointer,
  523. // non-interface field appearing in ForceSendFields will be sent to the
  524. // server regardless of whether the field is empty or not. This may be
  525. // used to include empty fields in Patch requests.
  526. ForceSendFields []string `json:"-"`
  527. // NullFields is a list of field names (e.g. "Confidence") to include in
  528. // API requests with the JSON null value. By default, fields with empty
  529. // values are omitted from API requests. However, any field with an
  530. // empty value appearing in NullFields will be sent to the server as
  531. // null. It is an error if a field in this list has a non-empty value.
  532. // This may be used to include null fields in Patch requests.
  533. NullFields []string `json:"-"`
  534. }
  535. func (s *ClassificationCategory) MarshalJSON() ([]byte, error) {
  536. type NoMethod ClassificationCategory
  537. raw := NoMethod(*s)
  538. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  539. }
  540. func (s *ClassificationCategory) UnmarshalJSON(data []byte) error {
  541. type NoMethod ClassificationCategory
  542. var s1 struct {
  543. Confidence gensupport.JSONFloat64 `json:"confidence"`
  544. *NoMethod
  545. }
  546. s1.NoMethod = (*NoMethod)(s)
  547. if err := json.Unmarshal(data, &s1); err != nil {
  548. return err
  549. }
  550. s.Confidence = float64(s1.Confidence)
  551. return nil
  552. }
  553. // ClassifyTextRequest: The document classification request message.
  554. type ClassifyTextRequest struct {
  555. // Document: Input document.
  556. Document *Document `json:"document,omitempty"`
  557. // ForceSendFields is a list of field names (e.g. "Document") to
  558. // unconditionally include in API requests. By default, fields with
  559. // empty values are omitted from API requests. However, any non-pointer,
  560. // non-interface field appearing in ForceSendFields will be sent to the
  561. // server regardless of whether the field is empty or not. This may be
  562. // used to include empty fields in Patch requests.
  563. ForceSendFields []string `json:"-"`
  564. // NullFields is a list of field names (e.g. "Document") to include in
  565. // API requests with the JSON null value. By default, fields with empty
  566. // values are omitted from API requests. However, any field with an
  567. // empty value appearing in NullFields will be sent to the server as
  568. // null. It is an error if a field in this list has a non-empty value.
  569. // This may be used to include null fields in Patch requests.
  570. NullFields []string `json:"-"`
  571. }
  572. func (s *ClassifyTextRequest) MarshalJSON() ([]byte, error) {
  573. type NoMethod ClassifyTextRequest
  574. raw := NoMethod(*s)
  575. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  576. }
  577. // ClassifyTextResponse: The document classification response message.
  578. type ClassifyTextResponse struct {
  579. // Categories: Categories representing the input document.
  580. Categories []*ClassificationCategory `json:"categories,omitempty"`
  581. // ServerResponse contains the HTTP response code and headers from the
  582. // server.
  583. googleapi.ServerResponse `json:"-"`
  584. // ForceSendFields is a list of field names (e.g. "Categories") to
  585. // unconditionally include in API requests. By default, fields with
  586. // empty values are omitted from API requests. However, any non-pointer,
  587. // non-interface field appearing in ForceSendFields will be sent to the
  588. // server regardless of whether the field is empty or not. This may be
  589. // used to include empty fields in Patch requests.
  590. ForceSendFields []string `json:"-"`
  591. // NullFields is a list of field names (e.g. "Categories") to include in
  592. // API requests with the JSON null value. By default, fields with empty
  593. // values are omitted from API requests. However, any field with an
  594. // empty value appearing in NullFields will be sent to the server as
  595. // null. It is an error if a field in this list has a non-empty value.
  596. // This may be used to include null fields in Patch requests.
  597. NullFields []string `json:"-"`
  598. }
  599. func (s *ClassifyTextResponse) MarshalJSON() ([]byte, error) {
  600. type NoMethod ClassifyTextResponse
  601. raw := NoMethod(*s)
  602. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  603. }
  604. // DependencyEdge: Represents dependency parse tree information for a
  605. // token. (For more
  606. // information on dependency labels,
  607. // see
  608. // http://www.aclweb.org/anthology/P13-2017
  609. type DependencyEdge struct {
  610. // HeadTokenIndex: Represents the head of this token in the dependency
  611. // tree.
  612. // This is the index of the token which has an arc going to this
  613. // token.
  614. // The index is the position of the token in the array of tokens
  615. // returned
  616. // by the API method. If this token is a root token, then
  617. // the
  618. // `head_token_index` is its own index.
  619. HeadTokenIndex int64 `json:"headTokenIndex,omitempty"`
  620. // Label: The parse label for the token.
  621. //
  622. // Possible values:
  623. // "UNKNOWN" - Unknown
  624. // "ABBREV" - Abbreviation modifier
  625. // "ACOMP" - Adjectival complement
  626. // "ADVCL" - Adverbial clause modifier
  627. // "ADVMOD" - Adverbial modifier
  628. // "AMOD" - Adjectival modifier of an NP
  629. // "APPOS" - Appositional modifier of an NP
  630. // "ATTR" - Attribute dependent of a copular verb
  631. // "AUX" - Auxiliary (non-main) verb
  632. // "AUXPASS" - Passive auxiliary
  633. // "CC" - Coordinating conjunction
  634. // "CCOMP" - Clausal complement of a verb or adjective
  635. // "CONJ" - Conjunct
  636. // "CSUBJ" - Clausal subject
  637. // "CSUBJPASS" - Clausal passive subject
  638. // "DEP" - Dependency (unable to determine)
  639. // "DET" - Determiner
  640. // "DISCOURSE" - Discourse
  641. // "DOBJ" - Direct object
  642. // "EXPL" - Expletive
  643. // "GOESWITH" - Goes with (part of a word in a text not well edited)
  644. // "IOBJ" - Indirect object
  645. // "MARK" - Marker (word introducing a subordinate clause)
  646. // "MWE" - Multi-word expression
  647. // "MWV" - Multi-word verbal expression
  648. // "NEG" - Negation modifier
  649. // "NN" - Noun compound modifier
  650. // "NPADVMOD" - Noun phrase used as an adverbial modifier
  651. // "NSUBJ" - Nominal subject
  652. // "NSUBJPASS" - Passive nominal subject
  653. // "NUM" - Numeric modifier of a noun
  654. // "NUMBER" - Element of compound number
  655. // "P" - Punctuation mark
  656. // "PARATAXIS" - Parataxis relation
  657. // "PARTMOD" - Participial modifier
  658. // "PCOMP" - The complement of a preposition is a clause
  659. // "POBJ" - Object of a preposition
  660. // "POSS" - Possession modifier
  661. // "POSTNEG" - Postverbal negative particle
  662. // "PRECOMP" - Predicate complement
  663. // "PRECONJ" - Preconjunt
  664. // "PREDET" - Predeterminer
  665. // "PREF" - Prefix
  666. // "PREP" - Prepositional modifier
  667. // "PRONL" - The relationship between a verb and verbal morpheme
  668. // "PRT" - Particle
  669. // "PS" - Associative or possessive marker
  670. // "QUANTMOD" - Quantifier phrase modifier
  671. // "RCMOD" - Relative clause modifier
  672. // "RCMODREL" - Complementizer in relative clause
  673. // "RDROP" - Ellipsis without a preceding predicate
  674. // "REF" - Referent
  675. // "REMNANT" - Remnant
  676. // "REPARANDUM" - Reparandum
  677. // "ROOT" - Root
  678. // "SNUM" - Suffix specifying a unit of number
  679. // "SUFF" - Suffix
  680. // "TMOD" - Temporal modifier
  681. // "TOPIC" - Topic marker
  682. // "VMOD" - Clause headed by an infinite form of the verb that
  683. // modifies a noun
  684. // "VOCATIVE" - Vocative
  685. // "XCOMP" - Open clausal complement
  686. // "SUFFIX" - Name suffix
  687. // "TITLE" - Name title
  688. // "ADVPHMOD" - Adverbial phrase modifier
  689. // "AUXCAUS" - Causative auxiliary
  690. // "AUXVV" - Helper auxiliary
  691. // "DTMOD" - Rentaishi (Prenominal modifier)
  692. // "FOREIGN" - Foreign words
  693. // "KW" - Keyword
  694. // "LIST" - List for chains of comparable items
  695. // "NOMC" - Nominalized clause
  696. // "NOMCSUBJ" - Nominalized clausal subject
  697. // "NOMCSUBJPASS" - Nominalized clausal passive
  698. // "NUMC" - Compound of numeric modifier
  699. // "COP" - Copula
  700. // "DISLOCATED" - Dislocated relation (for fronted/topicalized
  701. // elements)
  702. // "ASP" - Aspect marker
  703. // "GMOD" - Genitive modifier
  704. // "GOBJ" - Genitive object
  705. // "INFMOD" - Infinitival modifier
  706. // "MES" - Measure
  707. // "NCOMP" - Nominal complement of a noun
  708. Label string `json:"label,omitempty"`
  709. // ForceSendFields is a list of field names (e.g. "HeadTokenIndex") to
  710. // unconditionally include in API requests. By default, fields with
  711. // empty values are omitted from API requests. However, any non-pointer,
  712. // non-interface field appearing in ForceSendFields will be sent to the
  713. // server regardless of whether the field is empty or not. This may be
  714. // used to include empty fields in Patch requests.
  715. ForceSendFields []string `json:"-"`
  716. // NullFields is a list of field names (e.g. "HeadTokenIndex") to
  717. // include in API requests with the JSON null value. By default, fields
  718. // with empty values are omitted from API requests. However, any field
  719. // with an empty value appearing in NullFields will be sent to the
  720. // server as null. It is an error if a field in this list has a
  721. // non-empty value. This may be used to include null fields in Patch
  722. // requests.
  723. NullFields []string `json:"-"`
  724. }
  725. func (s *DependencyEdge) MarshalJSON() ([]byte, error) {
  726. type NoMethod DependencyEdge
  727. raw := NoMethod(*s)
  728. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  729. }
  730. // Document:
  731. // ################################################################
  732. // #
  733. //
  734. // Represents the input to API methods.
  735. type Document struct {
  736. // Content: The content of the input in string format.
  737. // Cloud audit logging exempt since it is based on user data.
  738. Content string `json:"content,omitempty"`
  739. // GcsContentUri: The Google Cloud Storage URI where the file content is
  740. // located.
  741. // This URI must be of the form: gs://bucket_name/object_name. For
  742. // more
  743. // details, see
  744. // https://cloud.google.com/storage/docs/reference-uris.
  745. // NOTE: Cloud Storage object versioning is not supported.
  746. GcsContentUri string `json:"gcsContentUri,omitempty"`
  747. // Language: The language of the document (if not specified, the
  748. // language is
  749. // automatically detected). Both ISO and BCP-47 language codes
  750. // are
  751. // accepted.<br>
  752. // [Language Support](/natural-language/docs/languages)
  753. // lists currently supported languages for each API method.
  754. // If the language (either specified by the caller or automatically
  755. // detected)
  756. // is not supported by the called API method, an `INVALID_ARGUMENT`
  757. // error
  758. // is returned.
  759. Language string `json:"language,omitempty"`
  760. // Type: Required. If the type is not set or is
  761. // `TYPE_UNSPECIFIED`,
  762. // returns an `INVALID_ARGUMENT` error.
  763. //
  764. // Possible values:
  765. // "TYPE_UNSPECIFIED" - The content type is not specified.
  766. // "PLAIN_TEXT" - Plain text
  767. // "HTML" - HTML
  768. Type string `json:"type,omitempty"`
  769. // ForceSendFields is a list of field names (e.g. "Content") to
  770. // unconditionally include in API requests. By default, fields with
  771. // empty values are omitted from API requests. However, any non-pointer,
  772. // non-interface field appearing in ForceSendFields will be sent to the
  773. // server regardless of whether the field is empty or not. This may be
  774. // used to include empty fields in Patch requests.
  775. ForceSendFields []string `json:"-"`
  776. // NullFields is a list of field names (e.g. "Content") to include in
  777. // API requests with the JSON null value. By default, fields with empty
  778. // values are omitted from API requests. However, any field with an
  779. // empty value appearing in NullFields will be sent to the server as
  780. // null. It is an error if a field in this list has a non-empty value.
  781. // This may be used to include null fields in Patch requests.
  782. NullFields []string `json:"-"`
  783. }
  784. func (s *Document) MarshalJSON() ([]byte, error) {
  785. type NoMethod Document
  786. raw := NoMethod(*s)
  787. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  788. }
  789. // Entity: Represents a phrase in the text that is a known entity, such
  790. // as
  791. // a person, an organization, or location. The API associates
  792. // information, such
  793. // as salience and mentions, with entities.
  794. type Entity struct {
  795. // Mentions: The mentions of this entity in the input document. The API
  796. // currently
  797. // supports proper noun mentions.
  798. Mentions []*EntityMention `json:"mentions,omitempty"`
  799. // Metadata: Metadata associated with the entity.
  800. //
  801. // Currently, Wikipedia URLs and Knowledge Graph MIDs are provided,
  802. // if
  803. // available. The associated keys are "wikipedia_url" and "mid",
  804. // respectively.
  805. Metadata map[string]string `json:"metadata,omitempty"`
  806. // Name: The representative name for the entity.
  807. Name string `json:"name,omitempty"`
  808. // Salience: The salience score associated with the entity in the [0,
  809. // 1.0] range.
  810. //
  811. // The salience score for an entity provides information about
  812. // the
  813. // importance or centrality of that entity to the entire document
  814. // text.
  815. // Scores closer to 0 are less salient, while scores closer to 1.0 are
  816. // highly
  817. // salient.
  818. Salience float64 `json:"salience,omitempty"`
  819. // Sentiment: For calls to AnalyzeEntitySentiment or
  820. // if
  821. // AnnotateTextRequest.Features.extract_entity_sentiment is set to
  822. // true, this field will contain the aggregate sentiment expressed for
  823. // this
  824. // entity in the provided document.
  825. Sentiment *Sentiment `json:"sentiment,omitempty"`
  826. // Type: The entity type.
  827. //
  828. // Possible values:
  829. // "UNKNOWN" - Unknown
  830. // "PERSON" - Person
  831. // "LOCATION" - Location
  832. // "ORGANIZATION" - Organization
  833. // "EVENT" - Event
  834. // "WORK_OF_ART" - Work of art
  835. // "CONSUMER_GOOD" - Consumer goods
  836. // "OTHER" - Other types
  837. Type string `json:"type,omitempty"`
  838. // ForceSendFields is a list of field names (e.g. "Mentions") to
  839. // unconditionally include in API requests. By default, fields with
  840. // empty values are omitted from API requests. However, any non-pointer,
  841. // non-interface field appearing in ForceSendFields will be sent to the
  842. // server regardless of whether the field is empty or not. This may be
  843. // used to include empty fields in Patch requests.
  844. ForceSendFields []string `json:"-"`
  845. // NullFields is a list of field names (e.g. "Mentions") to include in
  846. // API requests with the JSON null value. By default, fields with empty
  847. // values are omitted from API requests. However, any field with an
  848. // empty value appearing in NullFields will be sent to the server as
  849. // null. It is an error if a field in this list has a non-empty value.
  850. // This may be used to include null fields in Patch requests.
  851. NullFields []string `json:"-"`
  852. }
  853. func (s *Entity) MarshalJSON() ([]byte, error) {
  854. type NoMethod Entity
  855. raw := NoMethod(*s)
  856. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  857. }
  858. func (s *Entity) UnmarshalJSON(data []byte) error {
  859. type NoMethod Entity
  860. var s1 struct {
  861. Salience gensupport.JSONFloat64 `json:"salience"`
  862. *NoMethod
  863. }
  864. s1.NoMethod = (*NoMethod)(s)
  865. if err := json.Unmarshal(data, &s1); err != nil {
  866. return err
  867. }
  868. s.Salience = float64(s1.Salience)
  869. return nil
  870. }
  871. // EntityMention: Represents a mention for an entity in the text.
  872. // Currently, proper noun
  873. // mentions are supported.
  874. type EntityMention struct {
  875. // Sentiment: For calls to AnalyzeEntitySentiment or
  876. // if
  877. // AnnotateTextRequest.Features.extract_entity_sentiment is set to
  878. // true, this field will contain the sentiment expressed for this
  879. // mention of
  880. // the entity in the provided document.
  881. Sentiment *Sentiment `json:"sentiment,omitempty"`
  882. // Text: The mention text.
  883. Text *TextSpan `json:"text,omitempty"`
  884. // Type: The type of the entity mention.
  885. //
  886. // Possible values:
  887. // "TYPE_UNKNOWN" - Unknown
  888. // "PROPER" - Proper name
  889. // "COMMON" - Common noun (or noun compound)
  890. Type string `json:"type,omitempty"`
  891. // ForceSendFields is a list of field names (e.g. "Sentiment") to
  892. // unconditionally include in API requests. By default, fields with
  893. // empty values are omitted from API requests. However, any non-pointer,
  894. // non-interface field appearing in ForceSendFields will be sent to the
  895. // server regardless of whether the field is empty or not. This may be
  896. // used to include empty fields in Patch requests.
  897. ForceSendFields []string `json:"-"`
  898. // NullFields is a list of field names (e.g. "Sentiment") to include in
  899. // API requests with the JSON null value. By default, fields with empty
  900. // values are omitted from API requests. However, any field with an
  901. // empty value appearing in NullFields will be sent to the server as
  902. // null. It is an error if a field in this list has a non-empty value.
  903. // This may be used to include null fields in Patch requests.
  904. NullFields []string `json:"-"`
  905. }
  906. func (s *EntityMention) MarshalJSON() ([]byte, error) {
  907. type NoMethod EntityMention
  908. raw := NoMethod(*s)
  909. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  910. }
  911. // Features: All available features for sentiment, syntax, and semantic
  912. // analysis.
  913. // Setting each one to true will enable that specific analysis for the
  914. // input.
  915. type Features struct {
  916. // ClassifyText: Classify the full document into categories.
  917. ClassifyText bool `json:"classifyText,omitempty"`
  918. // ExtractDocumentSentiment: Extract document-level sentiment.
  919. ExtractDocumentSentiment bool `json:"extractDocumentSentiment,omitempty"`
  920. // ExtractEntities: Extract entities.
  921. ExtractEntities bool `json:"extractEntities,omitempty"`
  922. // ExtractEntitySentiment: Extract entities and their associated
  923. // sentiment.
  924. ExtractEntitySentiment bool `json:"extractEntitySentiment,omitempty"`
  925. // ExtractSyntax: Extract syntax information.
  926. ExtractSyntax bool `json:"extractSyntax,omitempty"`
  927. // ForceSendFields is a list of field names (e.g. "ClassifyText") to
  928. // unconditionally include in API requests. By default, fields with
  929. // empty values are omitted from API requests. However, any non-pointer,
  930. // non-interface field appearing in ForceSendFields will be sent to the
  931. // server regardless of whether the field is empty or not. This may be
  932. // used to include empty fields in Patch requests.
  933. ForceSendFields []string `json:"-"`
  934. // NullFields is a list of field names (e.g. "ClassifyText") to include
  935. // in API requests with the JSON null value. By default, fields with
  936. // empty values are omitted from API requests. However, any field with
  937. // an empty value appearing in NullFields will be sent to the server as
  938. // null. It is an error if a field in this list has a non-empty value.
  939. // This may be used to include null fields in Patch requests.
  940. NullFields []string `json:"-"`
  941. }
  942. func (s *Features) MarshalJSON() ([]byte, error) {
  943. type NoMethod Features
  944. raw := NoMethod(*s)
  945. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  946. }
  947. // PartOfSpeech: Represents part of speech information for a token.
  948. // Parts of speech
  949. // are as defined
  950. // in
  951. // http://www.lrec-conf.org/proceedings/lrec2012/pdf/274_Paper.pdf
  952. type PartOfSpeech struct {
  953. // Aspect: The grammatical aspect.
  954. //
  955. // Possible values:
  956. // "ASPECT_UNKNOWN" - Aspect is not applicable in the analyzed
  957. // language or is not predicted.
  958. // "PERFECTIVE" - Perfective
  959. // "IMPERFECTIVE" - Imperfective
  960. // "PROGRESSIVE" - Progressive
  961. Aspect string `json:"aspect,omitempty"`
  962. // Case: The grammatical case.
  963. //
  964. // Possible values:
  965. // "CASE_UNKNOWN" - Case is not applicable in the analyzed language or
  966. // is not predicted.
  967. // "ACCUSATIVE" - Accusative
  968. // "ADVERBIAL" - Adverbial
  969. // "COMPLEMENTIVE" - Complementive
  970. // "DATIVE" - Dative
  971. // "GENITIVE" - Genitive
  972. // "INSTRUMENTAL" - Instrumental
  973. // "LOCATIVE" - Locative
  974. // "NOMINATIVE" - Nominative
  975. // "OBLIQUE" - Oblique
  976. // "PARTITIVE" - Partitive
  977. // "PREPOSITIONAL" - Prepositional
  978. // "REFLEXIVE_CASE" - Reflexive
  979. // "RELATIVE_CASE" - Relative
  980. // "VOCATIVE" - Vocative
  981. Case string `json:"case,omitempty"`
  982. // Form: The grammatical form.
  983. //
  984. // Possible values:
  985. // "FORM_UNKNOWN" - Form is not applicable in the analyzed language or
  986. // is not predicted.
  987. // "ADNOMIAL" - Adnomial
  988. // "AUXILIARY" - Auxiliary
  989. // "COMPLEMENTIZER" - Complementizer
  990. // "FINAL_ENDING" - Final ending
  991. // "GERUND" - Gerund
  992. // "REALIS" - Realis
  993. // "IRREALIS" - Irrealis
  994. // "SHORT" - Short form
  995. // "LONG" - Long form
  996. // "ORDER" - Order form
  997. // "SPECIFIC" - Specific form
  998. Form string `json:"form,omitempty"`
  999. // Gender: The grammatical gender.
  1000. //
  1001. // Possible values:
  1002. // "GENDER_UNKNOWN" - Gender is not applicable in the analyzed
  1003. // language or is not predicted.
  1004. // "FEMININE" - Feminine
  1005. // "MASCULINE" - Masculine
  1006. // "NEUTER" - Neuter
  1007. Gender string `json:"gender,omitempty"`
  1008. // Mood: The grammatical mood.
  1009. //
  1010. // Possible values:
  1011. // "MOOD_UNKNOWN" - Mood is not applicable in the analyzed language or
  1012. // is not predicted.
  1013. // "CONDITIONAL_MOOD" - Conditional
  1014. // "IMPERATIVE" - Imperative
  1015. // "INDICATIVE" - Indicative
  1016. // "INTERROGATIVE" - Interrogative
  1017. // "JUSSIVE" - Jussive
  1018. // "SUBJUNCTIVE" - Subjunctive
  1019. Mood string `json:"mood,omitempty"`
  1020. // Number: The grammatical number.
  1021. //
  1022. // Possible values:
  1023. // "NUMBER_UNKNOWN" - Number is not applicable in the analyzed
  1024. // language or is not predicted.
  1025. // "SINGULAR" - Singular
  1026. // "PLURAL" - Plural
  1027. // "DUAL" - Dual
  1028. Number string `json:"number,omitempty"`
  1029. // Person: The grammatical person.
  1030. //
  1031. // Possible values:
  1032. // "PERSON_UNKNOWN" - Person is not applicable in the analyzed
  1033. // language or is not predicted.
  1034. // "FIRST" - First
  1035. // "SECOND" - Second
  1036. // "THIRD" - Third
  1037. // "REFLEXIVE_PERSON" - Reflexive
  1038. Person string `json:"person,omitempty"`
  1039. // Proper: The grammatical properness.
  1040. //
  1041. // Possible values:
  1042. // "PROPER_UNKNOWN" - Proper is not applicable in the analyzed
  1043. // language or is not predicted.
  1044. // "PROPER" - Proper
  1045. // "NOT_PROPER" - Not proper
  1046. Proper string `json:"proper,omitempty"`
  1047. // Reciprocity: The grammatical reciprocity.
  1048. //
  1049. // Possible values:
  1050. // "RECIPROCITY_UNKNOWN" - Reciprocity is not applicable in the
  1051. // analyzed language or is not
  1052. // predicted.
  1053. // "RECIPROCAL" - Reciprocal
  1054. // "NON_RECIPROCAL" - Non-reciprocal
  1055. Reciprocity string `json:"reciprocity,omitempty"`
  1056. // Tag: The part of speech tag.
  1057. //
  1058. // Possible values:
  1059. // "UNKNOWN" - Unknown
  1060. // "ADJ" - Adjective
  1061. // "ADP" - Adposition (preposition and postposition)
  1062. // "ADV" - Adverb
  1063. // "CONJ" - Conjunction
  1064. // "DET" - Determiner
  1065. // "NOUN" - Noun (common and proper)
  1066. // "NUM" - Cardinal number
  1067. // "PRON" - Pronoun
  1068. // "PRT" - Particle or other function word
  1069. // "PUNCT" - Punctuation
  1070. // "VERB" - Verb (all tenses and modes)
  1071. // "X" - Other: foreign words, typos, abbreviations
  1072. // "AFFIX" - Affix
  1073. Tag string `json:"tag,omitempty"`
  1074. // Tense: The grammatical tense.
  1075. //
  1076. // Possible values:
  1077. // "TENSE_UNKNOWN" - Tense is not applicable in the analyzed language
  1078. // or is not predicted.
  1079. // "CONDITIONAL_TENSE" - Conditional
  1080. // "FUTURE" - Future
  1081. // "PAST" - Past
  1082. // "PRESENT" - Present
  1083. // "IMPERFECT" - Imperfect
  1084. // "PLUPERFECT" - Pluperfect
  1085. Tense string `json:"tense,omitempty"`
  1086. // Voice: The grammatical voice.
  1087. //
  1088. // Possible values:
  1089. // "VOICE_UNKNOWN" - Voice is not applicable in the analyzed language
  1090. // or is not predicted.
  1091. // "ACTIVE" - Active
  1092. // "CAUSATIVE" - Causative
  1093. // "PASSIVE" - Passive
  1094. Voice string `json:"voice,omitempty"`
  1095. // ForceSendFields is a list of field names (e.g. "Aspect") to
  1096. // unconditionally include in API requests. By default, fields with
  1097. // empty values are omitted from API requests. However, any non-pointer,
  1098. // non-interface field appearing in ForceSendFields will be sent to the
  1099. // server regardless of whether the field is empty or not. This may be
  1100. // used to include empty fields in Patch requests.
  1101. ForceSendFields []string `json:"-"`
  1102. // NullFields is a list of field names (e.g. "Aspect") to include in API
  1103. // requests with the JSON null value. By default, fields with empty
  1104. // values are omitted from API requests. However, any field with an
  1105. // empty value appearing in NullFields will be sent to the server as
  1106. // null. It is an error if a field in this list has a non-empty value.
  1107. // This may be used to include null fields in Patch requests.
  1108. NullFields []string `json:"-"`
  1109. }
  1110. func (s *PartOfSpeech) MarshalJSON() ([]byte, error) {
  1111. type NoMethod PartOfSpeech
  1112. raw := NoMethod(*s)
  1113. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1114. }
  1115. // Sentence: Represents a sentence in the input document.
  1116. type Sentence struct {
  1117. // Sentiment: For calls to AnalyzeSentiment or
  1118. // if
  1119. // AnnotateTextRequest.Features.extract_document_sentiment is set
  1120. // to
  1121. // true, this field will contain the sentiment for the sentence.
  1122. Sentiment *Sentiment `json:"sentiment,omitempty"`
  1123. // Text: The sentence text.
  1124. Text *TextSpan `json:"text,omitempty"`
  1125. // ForceSendFields is a list of field names (e.g. "Sentiment") to
  1126. // unconditionally include in API requests. By default, fields with
  1127. // empty values are omitted from API requests. However, any non-pointer,
  1128. // non-interface field appearing in ForceSendFields will be sent to the
  1129. // server regardless of whether the field is empty or not. This may be
  1130. // used to include empty fields in Patch requests.
  1131. ForceSendFields []string `json:"-"`
  1132. // NullFields is a list of field names (e.g. "Sentiment") to include in
  1133. // API requests with the JSON null value. By default, fields with empty
  1134. // values are omitted from API requests. However, any field with an
  1135. // empty value appearing in NullFields will be sent to the server as
  1136. // null. It is an error if a field in this list has a non-empty value.
  1137. // This may be used to include null fields in Patch requests.
  1138. NullFields []string `json:"-"`
  1139. }
  1140. func (s *Sentence) MarshalJSON() ([]byte, error) {
  1141. type NoMethod Sentence
  1142. raw := NoMethod(*s)
  1143. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1144. }
  1145. // Sentiment: Represents the feeling associated with the entire text or
  1146. // entities in
  1147. // the text.
  1148. type Sentiment struct {
  1149. // Magnitude: A non-negative number in the [0, +inf) range, which
  1150. // represents
  1151. // the absolute magnitude of sentiment regardless of score (positive
  1152. // or
  1153. // negative).
  1154. Magnitude float64 `json:"magnitude,omitempty"`
  1155. // Score: Sentiment score between -1.0 (negative sentiment) and
  1156. // 1.0
  1157. // (positive sentiment).
  1158. Score float64 `json:"score,omitempty"`
  1159. // ForceSendFields is a list of field names (e.g. "Magnitude") to
  1160. // unconditionally include in API requests. By default, fields with
  1161. // empty values are omitted from API requests. However, any non-pointer,
  1162. // non-interface field appearing in ForceSendFields will be sent to the
  1163. // server regardless of whether the field is empty or not. This may be
  1164. // used to include empty fields in Patch requests.
  1165. ForceSendFields []string `json:"-"`
  1166. // NullFields is a list of field names (e.g. "Magnitude") to include in
  1167. // API requests with the JSON null value. By default, fields with empty
  1168. // values are omitted from API requests. However, any field with an
  1169. // empty value appearing in NullFields will be sent to the server as
  1170. // null. It is an error if a field in this list has a non-empty value.
  1171. // This may be used to include null fields in Patch requests.
  1172. NullFields []string `json:"-"`
  1173. }
  1174. func (s *Sentiment) MarshalJSON() ([]byte, error) {
  1175. type NoMethod Sentiment
  1176. raw := NoMethod(*s)
  1177. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1178. }
  1179. func (s *Sentiment) UnmarshalJSON(data []byte) error {
  1180. type NoMethod Sentiment
  1181. var s1 struct {
  1182. Magnitude gensupport.JSONFloat64 `json:"magnitude"`
  1183. Score gensupport.JSONFloat64 `json:"score"`
  1184. *NoMethod
  1185. }
  1186. s1.NoMethod = (*NoMethod)(s)
  1187. if err := json.Unmarshal(data, &s1); err != nil {
  1188. return err
  1189. }
  1190. s.Magnitude = float64(s1.Magnitude)
  1191. s.Score = float64(s1.Score)
  1192. return nil
  1193. }
  1194. // Status: The `Status` type defines a logical error model that is
  1195. // suitable for different
  1196. // programming environments, including REST APIs and RPC APIs. It is
  1197. // used by
  1198. // [gRPC](https://github.com/grpc). The error model is designed to
  1199. // be:
  1200. //
  1201. // - Simple to use and understand for most users
  1202. // - Flexible enough to meet unexpected needs
  1203. //
  1204. // # Overview
  1205. //
  1206. // The `Status` message contains three pieces of data: error code, error
  1207. // message,
  1208. // and error details. The error code should be an enum value
  1209. // of
  1210. // google.rpc.Code, but it may accept additional error codes if needed.
  1211. // The
  1212. // error message should be a developer-facing English message that
  1213. // helps
  1214. // developers *understand* and *resolve* the error. If a localized
  1215. // user-facing
  1216. // error message is needed, put the localized message in the error
  1217. // details or
  1218. // localize it in the client. The optional error details may contain
  1219. // arbitrary
  1220. // information about the error. There is a predefined set of error
  1221. // detail types
  1222. // in the package `google.rpc` that can be used for common error
  1223. // conditions.
  1224. //
  1225. // # Language mapping
  1226. //
  1227. // The `Status` message is the logical representation of the error
  1228. // model, but it
  1229. // is not necessarily the actual wire format. When the `Status` message
  1230. // is
  1231. // exposed in different client libraries and different wire protocols,
  1232. // it can be
  1233. // mapped differently. For example, it will likely be mapped to some
  1234. // exceptions
  1235. // in Java, but more likely mapped to some error codes in C.
  1236. //
  1237. // # Other uses
  1238. //
  1239. // The error model and the `Status` message can be used in a variety
  1240. // of
  1241. // environments, either with or without APIs, to provide a
  1242. // consistent developer experience across different
  1243. // environments.
  1244. //
  1245. // Example uses of this error model include:
  1246. //
  1247. // - Partial errors. If a service needs to return partial errors to the
  1248. // client,
  1249. // it may embed the `Status` in the normal response to indicate the
  1250. // partial
  1251. // errors.
  1252. //
  1253. // - Workflow errors. A typical workflow has multiple steps. Each step
  1254. // may
  1255. // have a `Status` message for error reporting.
  1256. //
  1257. // - Batch operations. If a client uses batch request and batch
  1258. // response, the
  1259. // `Status` message should be used directly inside batch response,
  1260. // one for
  1261. // each error sub-response.
  1262. //
  1263. // - Asynchronous operations. If an API call embeds asynchronous
  1264. // operation
  1265. // results in its response, the status of those operations should
  1266. // be
  1267. // represented directly using the `Status` message.
  1268. //
  1269. // - Logging. If some API errors are stored in logs, the message
  1270. // `Status` could
  1271. // be used directly after any stripping needed for security/privacy
  1272. // reasons.
  1273. type Status struct {
  1274. // Code: The status code, which should be an enum value of
  1275. // google.rpc.Code.
  1276. Code int64 `json:"code,omitempty"`
  1277. // Details: A list of messages that carry the error details. There is a
  1278. // common set of
  1279. // message types for APIs to use.
  1280. Details []googleapi.RawMessage `json:"details,omitempty"`
  1281. // Message: A developer-facing error message, which should be in
  1282. // English. Any
  1283. // user-facing error message should be localized and sent in
  1284. // the
  1285. // google.rpc.Status.details field, or localized by the client.
  1286. Message string `json:"message,omitempty"`
  1287. // ForceSendFields is a list of field names (e.g. "Code") to
  1288. // unconditionally include in API requests. By default, fields with
  1289. // empty values are omitted from API requests. However, any non-pointer,
  1290. // non-interface field appearing in ForceSendFields will be sent to the
  1291. // server regardless of whether the field is empty or not. This may be
  1292. // used to include empty fields in Patch requests.
  1293. ForceSendFields []string `json:"-"`
  1294. // NullFields is a list of field names (e.g. "Code") to include in API
  1295. // requests with the JSON null value. By default, fields with empty
  1296. // values are omitted from API requests. However, any field with an
  1297. // empty value appearing in NullFields will be sent to the server as
  1298. // null. It is an error if a field in this list has a non-empty value.
  1299. // This may be used to include null fields in Patch requests.
  1300. NullFields []string `json:"-"`
  1301. }
  1302. func (s *Status) MarshalJSON() ([]byte, error) {
  1303. type NoMethod Status
  1304. raw := NoMethod(*s)
  1305. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1306. }
  1307. // TextSpan: Represents an output piece of text.
  1308. type TextSpan struct {
  1309. // BeginOffset: The API calculates the beginning offset of the content
  1310. // in the original
  1311. // document according to the EncodingType specified in the API request.
  1312. BeginOffset int64 `json:"beginOffset,omitempty"`
  1313. // Content: The content of the output text.
  1314. Content string `json:"content,omitempty"`
  1315. // ForceSendFields is a list of field names (e.g. "BeginOffset") to
  1316. // unconditionally include in API requests. By default, fields with
  1317. // empty values are omitted from API requests. However, any non-pointer,
  1318. // non-interface field appearing in ForceSendFields will be sent to the
  1319. // server regardless of whether the field is empty or not. This may be
  1320. // used to include empty fields in Patch requests.
  1321. ForceSendFields []string `json:"-"`
  1322. // NullFields is a list of field names (e.g. "BeginOffset") to include
  1323. // in API requests with the JSON null value. By default, fields with
  1324. // empty values are omitted from API requests. However, any field with
  1325. // an empty value appearing in NullFields will be sent to the server as
  1326. // null. It is an error if a field in this list has a non-empty value.
  1327. // This may be used to include null fields in Patch requests.
  1328. NullFields []string `json:"-"`
  1329. }
  1330. func (s *TextSpan) MarshalJSON() ([]byte, error) {
  1331. type NoMethod TextSpan
  1332. raw := NoMethod(*s)
  1333. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1334. }
  1335. // Token: Represents the smallest syntactic building block of the text.
  1336. type Token struct {
  1337. // DependencyEdge: Dependency tree parse for this token.
  1338. DependencyEdge *DependencyEdge `json:"dependencyEdge,omitempty"`
  1339. // Lemma: [Lemma](https://en.wikipedia.org/wiki/Lemma_%28morphology%29)
  1340. // of the token.
  1341. Lemma string `json:"lemma,omitempty"`
  1342. // PartOfSpeech: Parts of speech tag for this token.
  1343. PartOfSpeech *PartOfSpeech `json:"partOfSpeech,omitempty"`
  1344. // Text: The token text.
  1345. Text *TextSpan `json:"text,omitempty"`
  1346. // ForceSendFields is a list of field names (e.g. "DependencyEdge") to
  1347. // unconditionally include in API requests. By default, fields with
  1348. // empty values are omitted from API requests. However, any non-pointer,
  1349. // non-interface field appearing in ForceSendFields will be sent to the
  1350. // server regardless of whether the field is empty or not. This may be
  1351. // used to include empty fields in Patch requests.
  1352. ForceSendFields []string `json:"-"`
  1353. // NullFields is a list of field names (e.g. "DependencyEdge") to
  1354. // include in API requests with the JSON null value. By default, fields
  1355. // with empty values are omitted from API requests. However, any field
  1356. // with an empty value appearing in NullFields will be sent to the
  1357. // server as null. It is an error if a field in this list has a
  1358. // non-empty value. This may be used to include null fields in Patch
  1359. // requests.
  1360. NullFields []string `json:"-"`
  1361. }
  1362. func (s *Token) MarshalJSON() ([]byte, error) {
  1363. type NoMethod Token
  1364. raw := NoMethod(*s)
  1365. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1366. }
  1367. // method id "language.documents.analyzeEntities":
  1368. type DocumentsAnalyzeEntitiesCall struct {
  1369. s *Service
  1370. analyzeentitiesrequest *AnalyzeEntitiesRequest
  1371. urlParams_ gensupport.URLParams
  1372. ctx_ context.Context
  1373. header_ http.Header
  1374. }
  1375. // AnalyzeEntities: Finds named entities (currently proper names and
  1376. // common nouns) in the text
  1377. // along with entity types, salience, mentions for each entity,
  1378. // and
  1379. // other properties.
  1380. func (r *DocumentsService) AnalyzeEntities(analyzeentitiesrequest *AnalyzeEntitiesRequest) *DocumentsAnalyzeEntitiesCall {
  1381. c := &DocumentsAnalyzeEntitiesCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1382. c.analyzeentitiesrequest = analyzeentitiesrequest
  1383. return c
  1384. }
  1385. // Fields allows partial responses to be retrieved. See
  1386. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1387. // for more information.
  1388. func (c *DocumentsAnalyzeEntitiesCall) Fields(s ...googleapi.Field) *DocumentsAnalyzeEntitiesCall {
  1389. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1390. return c
  1391. }
  1392. // Context sets the context to be used in this call's Do method. Any
  1393. // pending HTTP request will be aborted if the provided context is
  1394. // canceled.
  1395. func (c *DocumentsAnalyzeEntitiesCall) Context(ctx context.Context) *DocumentsAnalyzeEntitiesCall {
  1396. c.ctx_ = ctx
  1397. return c
  1398. }
  1399. // Header returns an http.Header that can be modified by the caller to
  1400. // add HTTP headers to the request.
  1401. func (c *DocumentsAnalyzeEntitiesCall) Header() http.Header {
  1402. if c.header_ == nil {
  1403. c.header_ = make(http.Header)
  1404. }
  1405. return c.header_
  1406. }
  1407. func (c *DocumentsAnalyzeEntitiesCall) doRequest(alt string) (*http.Response, error) {
  1408. reqHeaders := make(http.Header)
  1409. for k, v := range c.header_ {
  1410. reqHeaders[k] = v
  1411. }
  1412. reqHeaders.Set("User-Agent", c.s.userAgent())
  1413. var body io.Reader = nil
  1414. body, err := googleapi.WithoutDataWrapper.JSONReader(c.analyzeentitiesrequest)
  1415. if err != nil {
  1416. return nil, err
  1417. }
  1418. reqHeaders.Set("Content-Type", "application/json")
  1419. c.urlParams_.Set("alt", alt)
  1420. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/documents:analyzeEntities")
  1421. urls += "?" + c.urlParams_.Encode()
  1422. req, _ := http.NewRequest("POST", urls, body)
  1423. req.Header = reqHeaders
  1424. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1425. }
  1426. // Do executes the "language.documents.analyzeEntities" call.
  1427. // Exactly one of *AnalyzeEntitiesResponse or error will be non-nil. Any
  1428. // non-2xx status code is an error. Response headers are in either
  1429. // *AnalyzeEntitiesResponse.ServerResponse.Header or (if a response was
  1430. // returned at all) in error.(*googleapi.Error).Header. Use
  1431. // googleapi.IsNotModified to check whether the returned error was
  1432. // because http.StatusNotModified was returned.
  1433. func (c *DocumentsAnalyzeEntitiesCall) Do(opts ...googleapi.CallOption) (*AnalyzeEntitiesResponse, error) {
  1434. gensupport.SetOptions(c.urlParams_, opts...)
  1435. res, err := c.doRequest("json")
  1436. if res != nil && res.StatusCode == http.StatusNotModified {
  1437. if res.Body != nil {
  1438. res.Body.Close()
  1439. }
  1440. return nil, &googleapi.Error{
  1441. Code: res.StatusCode,
  1442. Header: res.Header,
  1443. }
  1444. }
  1445. if err != nil {
  1446. return nil, err
  1447. }
  1448. defer googleapi.CloseBody(res)
  1449. if err := googleapi.CheckResponse(res); err != nil {
  1450. return nil, err
  1451. }
  1452. ret := &AnalyzeEntitiesResponse{
  1453. ServerResponse: googleapi.ServerResponse{
  1454. Header: res.Header,
  1455. HTTPStatusCode: res.StatusCode,
  1456. },
  1457. }
  1458. target := &ret
  1459. if err := gensupport.DecodeResponse(target, res); err != nil {
  1460. return nil, err
  1461. }
  1462. return ret, nil
  1463. // {
  1464. // "description": "Finds named entities (currently proper names and common nouns) in the text\nalong with entity types, salience, mentions for each entity, and\nother properties.",
  1465. // "flatPath": "v1/documents:analyzeEntities",
  1466. // "httpMethod": "POST",
  1467. // "id": "language.documents.analyzeEntities",
  1468. // "parameterOrder": [],
  1469. // "parameters": {},
  1470. // "path": "v1/documents:analyzeEntities",
  1471. // "request": {
  1472. // "$ref": "AnalyzeEntitiesRequest"
  1473. // },
  1474. // "response": {
  1475. // "$ref": "AnalyzeEntitiesResponse"
  1476. // },
  1477. // "scopes": [
  1478. // "https://www.googleapis.com/auth/cloud-language",
  1479. // "https://www.googleapis.com/auth/cloud-platform"
  1480. // ]
  1481. // }
  1482. }
  1483. // method id "language.documents.analyzeEntitySentiment":
  1484. type DocumentsAnalyzeEntitySentimentCall struct {
  1485. s *Service
  1486. analyzeentitysentimentrequest *AnalyzeEntitySentimentRequest
  1487. urlParams_ gensupport.URLParams
  1488. ctx_ context.Context
  1489. header_ http.Header
  1490. }
  1491. // AnalyzeEntitySentiment: Finds entities, similar to AnalyzeEntities in
  1492. // the text and analyzes
  1493. // sentiment associated with each entity and its mentions.
  1494. func (r *DocumentsService) AnalyzeEntitySentiment(analyzeentitysentimentrequest *AnalyzeEntitySentimentRequest) *DocumentsAnalyzeEntitySentimentCall {
  1495. c := &DocumentsAnalyzeEntitySentimentCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1496. c.analyzeentitysentimentrequest = analyzeentitysentimentrequest
  1497. return c
  1498. }
  1499. // Fields allows partial responses to be retrieved. See
  1500. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1501. // for more information.
  1502. func (c *DocumentsAnalyzeEntitySentimentCall) Fields(s ...googleapi.Field) *DocumentsAnalyzeEntitySentimentCall {
  1503. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1504. return c
  1505. }
  1506. // Context sets the context to be used in this call's Do method. Any
  1507. // pending HTTP request will be aborted if the provided context is
  1508. // canceled.
  1509. func (c *DocumentsAnalyzeEntitySentimentCall) Context(ctx context.Context) *DocumentsAnalyzeEntitySentimentCall {
  1510. c.ctx_ = ctx
  1511. return c
  1512. }
  1513. // Header returns an http.Header that can be modified by the caller to
  1514. // add HTTP headers to the request.
  1515. func (c *DocumentsAnalyzeEntitySentimentCall) Header() http.Header {
  1516. if c.header_ == nil {
  1517. c.header_ = make(http.Header)
  1518. }
  1519. return c.header_
  1520. }
  1521. func (c *DocumentsAnalyzeEntitySentimentCall) doRequest(alt string) (*http.Response, error) {
  1522. reqHeaders := make(http.Header)
  1523. for k, v := range c.header_ {
  1524. reqHeaders[k] = v
  1525. }
  1526. reqHeaders.Set("User-Agent", c.s.userAgent())
  1527. var body io.Reader = nil
  1528. body, err := googleapi.WithoutDataWrapper.JSONReader(c.analyzeentitysentimentrequest)
  1529. if err != nil {
  1530. return nil, err
  1531. }
  1532. reqHeaders.Set("Content-Type", "application/json")
  1533. c.urlParams_.Set("alt", alt)
  1534. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/documents:analyzeEntitySentiment")
  1535. urls += "?" + c.urlParams_.Encode()
  1536. req, _ := http.NewRequest("POST", urls, body)
  1537. req.Header = reqHeaders
  1538. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1539. }
  1540. // Do executes the "language.documents.analyzeEntitySentiment" call.
  1541. // Exactly one of *AnalyzeEntitySentimentResponse or error will be
  1542. // non-nil. Any non-2xx status code is an error. Response headers are in
  1543. // either *AnalyzeEntitySentimentResponse.ServerResponse.Header or (if a
  1544. // response was returned at all) in error.(*googleapi.Error).Header. Use
  1545. // googleapi.IsNotModified to check whether the returned error was
  1546. // because http.StatusNotModified was returned.
  1547. func (c *DocumentsAnalyzeEntitySentimentCall) Do(opts ...googleapi.CallOption) (*AnalyzeEntitySentimentResponse, error) {
  1548. gensupport.SetOptions(c.urlParams_, opts...)
  1549. res, err := c.doRequest("json")
  1550. if res != nil && res.StatusCode == http.StatusNotModified {
  1551. if res.Body != nil {
  1552. res.Body.Close()
  1553. }
  1554. return nil, &googleapi.Error{
  1555. Code: res.StatusCode,
  1556. Header: res.Header,
  1557. }
  1558. }
  1559. if err != nil {
  1560. return nil, err
  1561. }
  1562. defer googleapi.CloseBody(res)
  1563. if err := googleapi.CheckResponse(res); err != nil {
  1564. return nil, err
  1565. }
  1566. ret := &AnalyzeEntitySentimentResponse{
  1567. ServerResponse: googleapi.ServerResponse{
  1568. Header: res.Header,
  1569. HTTPStatusCode: res.StatusCode,
  1570. },
  1571. }
  1572. target := &ret
  1573. if err := gensupport.DecodeResponse(target, res); err != nil {
  1574. return nil, err
  1575. }
  1576. return ret, nil
  1577. // {
  1578. // "description": "Finds entities, similar to AnalyzeEntities in the text and analyzes\nsentiment associated with each entity and its mentions.",
  1579. // "flatPath": "v1/documents:analyzeEntitySentiment",
  1580. // "httpMethod": "POST",
  1581. // "id": "language.documents.analyzeEntitySentiment",
  1582. // "parameterOrder": [],
  1583. // "parameters": {},
  1584. // "path": "v1/documents:analyzeEntitySentiment",
  1585. // "request": {
  1586. // "$ref": "AnalyzeEntitySentimentRequest"
  1587. // },
  1588. // "response": {
  1589. // "$ref": "AnalyzeEntitySentimentResponse"
  1590. // },
  1591. // "scopes": [
  1592. // "https://www.googleapis.com/auth/cloud-language",
  1593. // "https://www.googleapis.com/auth/cloud-platform"
  1594. // ]
  1595. // }
  1596. }
  1597. // method id "language.documents.analyzeSentiment":
  1598. type DocumentsAnalyzeSentimentCall struct {
  1599. s *Service
  1600. analyzesentimentrequest *AnalyzeSentimentRequest
  1601. urlParams_ gensupport.URLParams
  1602. ctx_ context.Context
  1603. header_ http.Header
  1604. }
  1605. // AnalyzeSentiment: Analyzes the sentiment of the provided text.
  1606. func (r *DocumentsService) AnalyzeSentiment(analyzesentimentrequest *AnalyzeSentimentRequest) *DocumentsAnalyzeSentimentCall {
  1607. c := &DocumentsAnalyzeSentimentCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1608. c.analyzesentimentrequest = analyzesentimentrequest
  1609. return c
  1610. }
  1611. // Fields allows partial responses to be retrieved. See
  1612. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1613. // for more information.
  1614. func (c *DocumentsAnalyzeSentimentCall) Fields(s ...googleapi.Field) *DocumentsAnalyzeSentimentCall {
  1615. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1616. return c
  1617. }
  1618. // Context sets the context to be used in this call's Do method. Any
  1619. // pending HTTP request will be aborted if the provided context is
  1620. // canceled.
  1621. func (c *DocumentsAnalyzeSentimentCall) Context(ctx context.Context) *DocumentsAnalyzeSentimentCall {
  1622. c.ctx_ = ctx
  1623. return c
  1624. }
  1625. // Header returns an http.Header that can be modified by the caller to
  1626. // add HTTP headers to the request.
  1627. func (c *DocumentsAnalyzeSentimentCall) Header() http.Header {
  1628. if c.header_ == nil {
  1629. c.header_ = make(http.Header)
  1630. }
  1631. return c.header_
  1632. }
  1633. func (c *DocumentsAnalyzeSentimentCall) doRequest(alt string) (*http.Response, error) {
  1634. reqHeaders := make(http.Header)
  1635. for k, v := range c.header_ {
  1636. reqHeaders[k] = v
  1637. }
  1638. reqHeaders.Set("User-Agent", c.s.userAgent())
  1639. var body io.Reader = nil
  1640. body, err := googleapi.WithoutDataWrapper.JSONReader(c.analyzesentimentrequest)
  1641. if err != nil {
  1642. return nil, err
  1643. }
  1644. reqHeaders.Set("Content-Type", "application/json")
  1645. c.urlParams_.Set("alt", alt)
  1646. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/documents:analyzeSentiment")
  1647. urls += "?" + c.urlParams_.Encode()
  1648. req, _ := http.NewRequest("POST", urls, body)
  1649. req.Header = reqHeaders
  1650. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1651. }
  1652. // Do executes the "language.documents.analyzeSentiment" call.
  1653. // Exactly one of *AnalyzeSentimentResponse or error will be non-nil.
  1654. // Any non-2xx status code is an error. Response headers are in either
  1655. // *AnalyzeSentimentResponse.ServerResponse.Header or (if a response was
  1656. // returned at all) in error.(*googleapi.Error).Header. Use
  1657. // googleapi.IsNotModified to check whether the returned error was
  1658. // because http.StatusNotModified was returned.
  1659. func (c *DocumentsAnalyzeSentimentCall) Do(opts ...googleapi.CallOption) (*AnalyzeSentimentResponse, error) {
  1660. gensupport.SetOptions(c.urlParams_, opts...)
  1661. res, err := c.doRequest("json")
  1662. if res != nil && res.StatusCode == http.StatusNotModified {
  1663. if res.Body != nil {
  1664. res.Body.Close()
  1665. }
  1666. return nil, &googleapi.Error{
  1667. Code: res.StatusCode,
  1668. Header: res.Header,
  1669. }
  1670. }
  1671. if err != nil {
  1672. return nil, err
  1673. }
  1674. defer googleapi.CloseBody(res)
  1675. if err := googleapi.CheckResponse(res); err != nil {
  1676. return nil, err
  1677. }
  1678. ret := &AnalyzeSentimentResponse{
  1679. ServerResponse: googleapi.ServerResponse{
  1680. Header: res.Header,
  1681. HTTPStatusCode: res.StatusCode,
  1682. },
  1683. }
  1684. target := &ret
  1685. if err := gensupport.DecodeResponse(target, res); err != nil {
  1686. return nil, err
  1687. }
  1688. return ret, nil
  1689. // {
  1690. // "description": "Analyzes the sentiment of the provided text.",
  1691. // "flatPath": "v1/documents:analyzeSentiment",
  1692. // "httpMethod": "POST",
  1693. // "id": "language.documents.analyzeSentiment",
  1694. // "parameterOrder": [],
  1695. // "parameters": {},
  1696. // "path": "v1/documents:analyzeSentiment",
  1697. // "request": {
  1698. // "$ref": "AnalyzeSentimentRequest"
  1699. // },
  1700. // "response": {
  1701. // "$ref": "AnalyzeSentimentResponse"
  1702. // },
  1703. // "scopes": [
  1704. // "https://www.googleapis.com/auth/cloud-language",
  1705. // "https://www.googleapis.com/auth/cloud-platform"
  1706. // ]
  1707. // }
  1708. }
  1709. // method id "language.documents.analyzeSyntax":
  1710. type DocumentsAnalyzeSyntaxCall struct {
  1711. s *Service
  1712. analyzesyntaxrequest *AnalyzeSyntaxRequest
  1713. urlParams_ gensupport.URLParams
  1714. ctx_ context.Context
  1715. header_ http.Header
  1716. }
  1717. // AnalyzeSyntax: Analyzes the syntax of the text and provides sentence
  1718. // boundaries and
  1719. // tokenization along with part of speech tags, dependency trees, and
  1720. // other
  1721. // properties.
  1722. func (r *DocumentsService) AnalyzeSyntax(analyzesyntaxrequest *AnalyzeSyntaxRequest) *DocumentsAnalyzeSyntaxCall {
  1723. c := &DocumentsAnalyzeSyntaxCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1724. c.analyzesyntaxrequest = analyzesyntaxrequest
  1725. return c
  1726. }
  1727. // Fields allows partial responses to be retrieved. See
  1728. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1729. // for more information.
  1730. func (c *DocumentsAnalyzeSyntaxCall) Fields(s ...googleapi.Field) *DocumentsAnalyzeSyntaxCall {
  1731. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1732. return c
  1733. }
  1734. // Context sets the context to be used in this call's Do method. Any
  1735. // pending HTTP request will be aborted if the provided context is
  1736. // canceled.
  1737. func (c *DocumentsAnalyzeSyntaxCall) Context(ctx context.Context) *DocumentsAnalyzeSyntaxCall {
  1738. c.ctx_ = ctx
  1739. return c
  1740. }
  1741. // Header returns an http.Header that can be modified by the caller to
  1742. // add HTTP headers to the request.
  1743. func (c *DocumentsAnalyzeSyntaxCall) Header() http.Header {
  1744. if c.header_ == nil {
  1745. c.header_ = make(http.Header)
  1746. }
  1747. return c.header_
  1748. }
  1749. func (c *DocumentsAnalyzeSyntaxCall) doRequest(alt string) (*http.Response, error) {
  1750. reqHeaders := make(http.Header)
  1751. for k, v := range c.header_ {
  1752. reqHeaders[k] = v
  1753. }
  1754. reqHeaders.Set("User-Agent", c.s.userAgent())
  1755. var body io.Reader = nil
  1756. body, err := googleapi.WithoutDataWrapper.JSONReader(c.analyzesyntaxrequest)
  1757. if err != nil {
  1758. return nil, err
  1759. }
  1760. reqHeaders.Set("Content-Type", "application/json")
  1761. c.urlParams_.Set("alt", alt)
  1762. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/documents:analyzeSyntax")
  1763. urls += "?" + c.urlParams_.Encode()
  1764. req, _ := http.NewRequest("POST", urls, body)
  1765. req.Header = reqHeaders
  1766. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1767. }
  1768. // Do executes the "language.documents.analyzeSyntax" call.
  1769. // Exactly one of *AnalyzeSyntaxResponse or error will be non-nil. Any
  1770. // non-2xx status code is an error. Response headers are in either
  1771. // *AnalyzeSyntaxResponse.ServerResponse.Header or (if a response was
  1772. // returned at all) in error.(*googleapi.Error).Header. Use
  1773. // googleapi.IsNotModified to check whether the returned error was
  1774. // because http.StatusNotModified was returned.
  1775. func (c *DocumentsAnalyzeSyntaxCall) Do(opts ...googleapi.CallOption) (*AnalyzeSyntaxResponse, error) {
  1776. gensupport.SetOptions(c.urlParams_, opts...)
  1777. res, err := c.doRequest("json")
  1778. if res != nil && res.StatusCode == http.StatusNotModified {
  1779. if res.Body != nil {
  1780. res.Body.Close()
  1781. }
  1782. return nil, &googleapi.Error{
  1783. Code: res.StatusCode,
  1784. Header: res.Header,
  1785. }
  1786. }
  1787. if err != nil {
  1788. return nil, err
  1789. }
  1790. defer googleapi.CloseBody(res)
  1791. if err := googleapi.CheckResponse(res); err != nil {
  1792. return nil, err
  1793. }
  1794. ret := &AnalyzeSyntaxResponse{
  1795. ServerResponse: googleapi.ServerResponse{
  1796. Header: res.Header,
  1797. HTTPStatusCode: res.StatusCode,
  1798. },
  1799. }
  1800. target := &ret
  1801. if err := gensupport.DecodeResponse(target, res); err != nil {
  1802. return nil, err
  1803. }
  1804. return ret, nil
  1805. // {
  1806. // "description": "Analyzes the syntax of the text and provides sentence boundaries and\ntokenization along with part of speech tags, dependency trees, and other\nproperties.",
  1807. // "flatPath": "v1/documents:analyzeSyntax",
  1808. // "httpMethod": "POST",
  1809. // "id": "language.documents.analyzeSyntax",
  1810. // "parameterOrder": [],
  1811. // "parameters": {},
  1812. // "path": "v1/documents:analyzeSyntax",
  1813. // "request": {
  1814. // "$ref": "AnalyzeSyntaxRequest"
  1815. // },
  1816. // "response": {
  1817. // "$ref": "AnalyzeSyntaxResponse"
  1818. // },
  1819. // "scopes": [
  1820. // "https://www.googleapis.com/auth/cloud-language",
  1821. // "https://www.googleapis.com/auth/cloud-platform"
  1822. // ]
  1823. // }
  1824. }
  1825. // method id "language.documents.annotateText":
  1826. type DocumentsAnnotateTextCall struct {
  1827. s *Service
  1828. annotatetextrequest *AnnotateTextRequest
  1829. urlParams_ gensupport.URLParams
  1830. ctx_ context.Context
  1831. header_ http.Header
  1832. }
  1833. // AnnotateText: A convenience method that provides all the features
  1834. // that analyzeSentiment,
  1835. // analyzeEntities, and analyzeSyntax provide in one call.
  1836. func (r *DocumentsService) AnnotateText(annotatetextrequest *AnnotateTextRequest) *DocumentsAnnotateTextCall {
  1837. c := &DocumentsAnnotateTextCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1838. c.annotatetextrequest = annotatetextrequest
  1839. return c
  1840. }
  1841. // Fields allows partial responses to be retrieved. See
  1842. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1843. // for more information.
  1844. func (c *DocumentsAnnotateTextCall) Fields(s ...googleapi.Field) *DocumentsAnnotateTextCall {
  1845. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1846. return c
  1847. }
  1848. // Context sets the context to be used in this call's Do method. Any
  1849. // pending HTTP request will be aborted if the provided context is
  1850. // canceled.
  1851. func (c *DocumentsAnnotateTextCall) Context(ctx context.Context) *DocumentsAnnotateTextCall {
  1852. c.ctx_ = ctx
  1853. return c
  1854. }
  1855. // Header returns an http.Header that can be modified by the caller to
  1856. // add HTTP headers to the request.
  1857. func (c *DocumentsAnnotateTextCall) Header() http.Header {
  1858. if c.header_ == nil {
  1859. c.header_ = make(http.Header)
  1860. }
  1861. return c.header_
  1862. }
  1863. func (c *DocumentsAnnotateTextCall) doRequest(alt string) (*http.Response, error) {
  1864. reqHeaders := make(http.Header)
  1865. for k, v := range c.header_ {
  1866. reqHeaders[k] = v
  1867. }
  1868. reqHeaders.Set("User-Agent", c.s.userAgent())
  1869. var body io.Reader = nil
  1870. body, err := googleapi.WithoutDataWrapper.JSONReader(c.annotatetextrequest)
  1871. if err != nil {
  1872. return nil, err
  1873. }
  1874. reqHeaders.Set("Content-Type", "application/json")
  1875. c.urlParams_.Set("alt", alt)
  1876. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/documents:annotateText")
  1877. urls += "?" + c.urlParams_.Encode()
  1878. req, _ := http.NewRequest("POST", urls, body)
  1879. req.Header = reqHeaders
  1880. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1881. }
  1882. // Do executes the "language.documents.annotateText" call.
  1883. // Exactly one of *AnnotateTextResponse or error will be non-nil. Any
  1884. // non-2xx status code is an error. Response headers are in either
  1885. // *AnnotateTextResponse.ServerResponse.Header or (if a response was
  1886. // returned at all) in error.(*googleapi.Error).Header. Use
  1887. // googleapi.IsNotModified to check whether the returned error was
  1888. // because http.StatusNotModified was returned.
  1889. func (c *DocumentsAnnotateTextCall) Do(opts ...googleapi.CallOption) (*AnnotateTextResponse, error) {
  1890. gensupport.SetOptions(c.urlParams_, opts...)
  1891. res, err := c.doRequest("json")
  1892. if res != nil && res.StatusCode == http.StatusNotModified {
  1893. if res.Body != nil {
  1894. res.Body.Close()
  1895. }
  1896. return nil, &googleapi.Error{
  1897. Code: res.StatusCode,
  1898. Header: res.Header,
  1899. }
  1900. }
  1901. if err != nil {
  1902. return nil, err
  1903. }
  1904. defer googleapi.CloseBody(res)
  1905. if err := googleapi.CheckResponse(res); err != nil {
  1906. return nil, err
  1907. }
  1908. ret := &AnnotateTextResponse{
  1909. ServerResponse: googleapi.ServerResponse{
  1910. Header: res.Header,
  1911. HTTPStatusCode: res.StatusCode,
  1912. },
  1913. }
  1914. target := &ret
  1915. if err := gensupport.DecodeResponse(target, res); err != nil {
  1916. return nil, err
  1917. }
  1918. return ret, nil
  1919. // {
  1920. // "description": "A convenience method that provides all the features that analyzeSentiment,\nanalyzeEntities, and analyzeSyntax provide in one call.",
  1921. // "flatPath": "v1/documents:annotateText",
  1922. // "httpMethod": "POST",
  1923. // "id": "language.documents.annotateText",
  1924. // "parameterOrder": [],
  1925. // "parameters": {},
  1926. // "path": "v1/documents:annotateText",
  1927. // "request": {
  1928. // "$ref": "AnnotateTextRequest"
  1929. // },
  1930. // "response": {
  1931. // "$ref": "AnnotateTextResponse"
  1932. // },
  1933. // "scopes": [
  1934. // "https://www.googleapis.com/auth/cloud-language",
  1935. // "https://www.googleapis.com/auth/cloud-platform"
  1936. // ]
  1937. // }
  1938. }
  1939. // method id "language.documents.classifyText":
  1940. type DocumentsClassifyTextCall struct {
  1941. s *Service
  1942. classifytextrequest *ClassifyTextRequest
  1943. urlParams_ gensupport.URLParams
  1944. ctx_ context.Context
  1945. header_ http.Header
  1946. }
  1947. // ClassifyText: Classifies a document into categories.
  1948. func (r *DocumentsService) ClassifyText(classifytextrequest *ClassifyTextRequest) *DocumentsClassifyTextCall {
  1949. c := &DocumentsClassifyTextCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1950. c.classifytextrequest = classifytextrequest
  1951. return c
  1952. }
  1953. // Fields allows partial responses to be retrieved. See
  1954. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1955. // for more information.
  1956. func (c *DocumentsClassifyTextCall) Fields(s ...googleapi.Field) *DocumentsClassifyTextCall {
  1957. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1958. return c
  1959. }
  1960. // Context sets the context to be used in this call's Do method. Any
  1961. // pending HTTP request will be aborted if the provided context is
  1962. // canceled.
  1963. func (c *DocumentsClassifyTextCall) Context(ctx context.Context) *DocumentsClassifyTextCall {
  1964. c.ctx_ = ctx
  1965. return c
  1966. }
  1967. // Header returns an http.Header that can be modified by the caller to
  1968. // add HTTP headers to the request.
  1969. func (c *DocumentsClassifyTextCall) Header() http.Header {
  1970. if c.header_ == nil {
  1971. c.header_ = make(http.Header)
  1972. }
  1973. return c.header_
  1974. }
  1975. func (c *DocumentsClassifyTextCall) doRequest(alt string) (*http.Response, error) {
  1976. reqHeaders := make(http.Header)
  1977. for k, v := range c.header_ {
  1978. reqHeaders[k] = v
  1979. }
  1980. reqHeaders.Set("User-Agent", c.s.userAgent())
  1981. var body io.Reader = nil
  1982. body, err := googleapi.WithoutDataWrapper.JSONReader(c.classifytextrequest)
  1983. if err != nil {
  1984. return nil, err
  1985. }
  1986. reqHeaders.Set("Content-Type", "application/json")
  1987. c.urlParams_.Set("alt", alt)
  1988. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/documents:classifyText")
  1989. urls += "?" + c.urlParams_.Encode()
  1990. req, _ := http.NewRequest("POST", urls, body)
  1991. req.Header = reqHeaders
  1992. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1993. }
  1994. // Do executes the "language.documents.classifyText" call.
  1995. // Exactly one of *ClassifyTextResponse or error will be non-nil. Any
  1996. // non-2xx status code is an error. Response headers are in either
  1997. // *ClassifyTextResponse.ServerResponse.Header or (if a response was
  1998. // returned at all) in error.(*googleapi.Error).Header. Use
  1999. // googleapi.IsNotModified to check whether the returned error was
  2000. // because http.StatusNotModified was returned.
  2001. func (c *DocumentsClassifyTextCall) Do(opts ...googleapi.CallOption) (*ClassifyTextResponse, error) {
  2002. gensupport.SetOptions(c.urlParams_, opts...)
  2003. res, err := c.doRequest("json")
  2004. if res != nil && res.StatusCode == http.StatusNotModified {
  2005. if res.Body != nil {
  2006. res.Body.Close()
  2007. }
  2008. return nil, &googleapi.Error{
  2009. Code: res.StatusCode,
  2010. Header: res.Header,
  2011. }
  2012. }
  2013. if err != nil {
  2014. return nil, err
  2015. }
  2016. defer googleapi.CloseBody(res)
  2017. if err := googleapi.CheckResponse(res); err != nil {
  2018. return nil, err
  2019. }
  2020. ret := &ClassifyTextResponse{
  2021. ServerResponse: googleapi.ServerResponse{
  2022. Header: res.Header,
  2023. HTTPStatusCode: res.StatusCode,
  2024. },
  2025. }
  2026. target := &ret
  2027. if err := gensupport.DecodeResponse(target, res); err != nil {
  2028. return nil, err
  2029. }
  2030. return ret, nil
  2031. // {
  2032. // "description": "Classifies a document into categories.",
  2033. // "flatPath": "v1/documents:classifyText",
  2034. // "httpMethod": "POST",
  2035. // "id": "language.documents.classifyText",
  2036. // "parameterOrder": [],
  2037. // "parameters": {},
  2038. // "path": "v1/documents:classifyText",
  2039. // "request": {
  2040. // "$ref": "ClassifyTextRequest"
  2041. // },
  2042. // "response": {
  2043. // "$ref": "ClassifyTextResponse"
  2044. // },
  2045. // "scopes": [
  2046. // "https://www.googleapis.com/auth/cloud-language",
  2047. // "https://www.googleapis.com/auth/cloud-platform"
  2048. // ]
  2049. // }
  2050. }