25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

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