@@ -0,0 +1,1372 @@
1+{-# LANGUAGE DeriveDataTypeable #-}
2+{-# LANGUAGE DeriveGeneric #-}
3+{-# LANGUAGE NoImplicitPrelude #-}
4+{-# LANGUAGE OverloadedStrings #-}
5+{-# LANGUAGE RecordWildCards #-}
6+
7+{-# OPTIONS_GHC -fno-warn-unused-binds #-}
8+{-# OPTIONS_GHC -fno-warn-unused-imports #-}
9+
10+-- |
11+-- Module : Network.Google.Language.Types.Product
12+-- Copyright : (c) 2015-2016 Brendan Hay
13+-- License : Mozilla Public License, v. 2.0.
14+-- Maintainer : Brendan Hay <brendan.g.hay@gmail.com>
15+-- Stability : auto-generated
16+-- Portability : non-portable (GHC extensions)
17+--
18+module Network.Google.Language.Types.Product where
19+
20+import Network.Google.Language.Types.Sum
21+import Network.Google.Prelude
22+
23+-- | The syntax analysis request message.
24+--
25+-- /See:/ 'analyzeSyntaxRequest' smart constructor.
26+data AnalyzeSyntaxRequest = AnalyzeSyntaxRequest'
27+ { _asrEncodingType :: !(Maybe AnalyzeSyntaxRequestEncodingType)
28+ , _asrDocument :: !(Maybe Document)
29+ } deriving (Eq,Show,Data,Typeable,Generic)
30+
31+-- | Creates a value of 'AnalyzeSyntaxRequest' with the minimum fields required to make a request.
32+--
33+-- Use one of the following lenses to modify other fields as desired:
34+--
35+-- * 'asrEncodingType'
36+--
37+-- * 'asrDocument'
38+analyzeSyntaxRequest
39+ :: AnalyzeSyntaxRequest
40+analyzeSyntaxRequest =
41+ AnalyzeSyntaxRequest'
42+ { _asrEncodingType = Nothing
43+ , _asrDocument = Nothing
44+ }
45+
46+-- | The encoding type used by the API to calculate offsets.
47+asrEncodingType :: Lens' AnalyzeSyntaxRequest (Maybe AnalyzeSyntaxRequestEncodingType)
48+asrEncodingType
49+ = lens _asrEncodingType
50+ (\ s a -> s{_asrEncodingType = a})
51+
52+-- | Input document.
53+asrDocument :: Lens' AnalyzeSyntaxRequest (Maybe Document)
54+asrDocument
55+ = lens _asrDocument (\ s a -> s{_asrDocument = a})
56+
57+instance FromJSON AnalyzeSyntaxRequest where
58+ parseJSON
59+ = withObject "AnalyzeSyntaxRequest"
60+ (\ o ->
61+ AnalyzeSyntaxRequest' <$>
62+ (o .:? "encodingType") <*> (o .:? "document"))
63+
64+instance ToJSON AnalyzeSyntaxRequest where
65+ toJSON AnalyzeSyntaxRequest'{..}
66+ = object
67+ (catMaybes
68+ [("encodingType" .=) <$> _asrEncodingType,
69+ ("document" .=) <$> _asrDocument])
70+
71+-- | Represents dependency parse tree information for a token. (For more
72+-- information on dependency labels, see
73+-- http:\/\/www.aclweb.org\/anthology\/P13-2017
74+--
75+-- /See:/ 'dependencyEdge' smart constructor.
76+data DependencyEdge = DependencyEdge'
77+ { _deHeadTokenIndex :: !(Maybe (Textual Int32))
78+ , _deLabel :: !(Maybe DependencyEdgeLabel)
79+ } deriving (Eq,Show,Data,Typeable,Generic)
80+
81+-- | Creates a value of 'DependencyEdge' with the minimum fields required to make a request.
82+--
83+-- Use one of the following lenses to modify other fields as desired:
84+--
85+-- * 'deHeadTokenIndex'
86+--
87+-- * 'deLabel'
88+dependencyEdge
89+ :: DependencyEdge
90+dependencyEdge =
91+ DependencyEdge'
92+ { _deHeadTokenIndex = Nothing
93+ , _deLabel = Nothing
94+ }
95+
96+-- | Represents the head of this token in the dependency tree. This is the
97+-- index of the token which has an arc going to this token. The index is
98+-- the position of the token in the array of tokens returned by the API
99+-- method. If this token is a root token, then the \`head_token_index\` is
100+-- its own index.
101+deHeadTokenIndex :: Lens' DependencyEdge (Maybe Int32)
102+deHeadTokenIndex
103+ = lens _deHeadTokenIndex
104+ (\ s a -> s{_deHeadTokenIndex = a})
105+ . mapping _Coerce
106+
107+-- | The parse label for the token.
108+deLabel :: Lens' DependencyEdge (Maybe DependencyEdgeLabel)
109+deLabel = lens _deLabel (\ s a -> s{_deLabel = a})
110+
111+instance FromJSON DependencyEdge where
112+ parseJSON
113+ = withObject "DependencyEdge"
114+ (\ o ->
115+ DependencyEdge' <$>
116+ (o .:? "headTokenIndex") <*> (o .:? "label"))
117+
118+instance ToJSON DependencyEdge where
119+ toJSON DependencyEdge'{..}
120+ = object
121+ (catMaybes
122+ [("headTokenIndex" .=) <$> _deHeadTokenIndex,
123+ ("label" .=) <$> _deLabel])
124+
125+-- | The \`Status\` type defines a logical error model that is suitable for
126+-- different programming environments, including REST APIs and RPC APIs. It
127+-- is used by [gRPC](https:\/\/github.com\/grpc). The error model is
128+-- designed to be: - Simple to use and understand for most users - Flexible
129+-- enough to meet unexpected needs # Overview The \`Status\` message
130+-- contains three pieces of data: error code, error message, and error
131+-- details. The error code should be an enum value of google.rpc.Code, but
132+-- it may accept additional error codes if needed. The error message should
133+-- be a developer-facing English message that helps developers *understand*
134+-- and *resolve* the error. If a localized user-facing error message is
135+-- needed, put the localized message in the error details or localize it in
136+-- the client. The optional error details may contain arbitrary information
137+-- about the error. There is a predefined set of error detail types in the
138+-- package \`google.rpc\` which can be used for common error conditions. #
139+-- Language mapping The \`Status\` message is the logical representation of
140+-- the error model, but it is not necessarily the actual wire format. When
141+-- the \`Status\` message is exposed in different client libraries and
142+-- different wire protocols, it can be mapped differently. For example, it
143+-- will likely be mapped to some exceptions in Java, but more likely mapped
144+-- to some error codes in C. # Other uses The error model and the
145+-- \`Status\` message can be used in a variety of environments, either with
146+-- or without APIs, to provide a consistent developer experience across
147+-- different environments. Example uses of this error model include: -
148+-- Partial errors. If a service needs to return partial errors to the
149+-- client, it may embed the \`Status\` in the normal response to indicate
150+-- the partial errors. - Workflow errors. A typical workflow has multiple
151+-- steps. Each step may have a \`Status\` message for error reporting
152+-- purpose. - Batch operations. If a client uses batch request and batch
153+-- response, the \`Status\` message should be used directly inside batch
154+-- response, one for each error sub-response. - Asynchronous operations. If
155+-- an API call embeds asynchronous operation results in its response, the
156+-- status of those operations should be represented directly using the
157+-- \`Status\` message. - Logging. If some API errors are stored in logs,
158+-- the message \`Status\` could be used directly after any stripping needed
159+-- for security\/privacy reasons.
160+--
161+-- /See:/ 'status' smart constructor.
162+data Status = Status'
163+ { _sDetails :: !(Maybe [StatusDetailsItem])
164+ , _sCode :: !(Maybe (Textual Int32))
165+ , _sMessage :: !(Maybe Text)
166+ } deriving (Eq,Show,Data,Typeable,Generic)
167+
168+-- | Creates a value of 'Status' with the minimum fields required to make a request.
169+--
170+-- Use one of the following lenses to modify other fields as desired:
171+--
172+-- * 'sDetails'
173+--
174+-- * 'sCode'
175+--
176+-- * 'sMessage'
177+status
178+ :: Status
179+status =
180+ Status'
181+ { _sDetails = Nothing
182+ , _sCode = Nothing
183+ , _sMessage = Nothing
184+ }
185+
186+-- | A list of messages that carry the error details. There will be a common
187+-- set of message types for APIs to use.
188+sDetails :: Lens' Status [StatusDetailsItem]
189+sDetails
190+ = lens _sDetails (\ s a -> s{_sDetails = a}) .
191+ _Default
192+ . _Coerce
193+
194+-- | The status code, which should be an enum value of google.rpc.Code.
195+sCode :: Lens' Status (Maybe Int32)
196+sCode
197+ = lens _sCode (\ s a -> s{_sCode = a}) .
198+ mapping _Coerce
199+
200+-- | A developer-facing error message, which should be in English. Any
201+-- user-facing error message should be localized and sent in the
202+-- google.rpc.Status.details field, or localized by the client.
203+sMessage :: Lens' Status (Maybe Text)
204+sMessage = lens _sMessage (\ s a -> s{_sMessage = a})
205+
206+instance FromJSON Status where
207+ parseJSON
208+ = withObject "Status"
209+ (\ o ->
210+ Status' <$>
211+ (o .:? "details" .!= mempty) <*> (o .:? "code") <*>
212+ (o .:? "message"))
213+
214+instance ToJSON Status where
215+ toJSON Status'{..}
216+ = object
217+ (catMaybes
218+ [("details" .=) <$> _sDetails,
219+ ("code" .=) <$> _sCode,
220+ ("message" .=) <$> _sMessage])
221+
222+-- | Represents the feeling associated with the entire text or entities in
223+-- the text.
224+--
225+-- /See:/ 'sentiment' smart constructor.
226+data Sentiment = Sentiment'
227+ { _sScore :: !(Maybe (Textual Double))
228+ , _sMagnitude :: !(Maybe (Textual Double))
229+ } deriving (Eq,Show,Data,Typeable,Generic)
230+
231+-- | Creates a value of 'Sentiment' with the minimum fields required to make a request.
232+--
233+-- Use one of the following lenses to modify other fields as desired:
234+--
235+-- * 'sScore'
236+--
237+-- * 'sMagnitude'
238+sentiment
239+ :: Sentiment
240+sentiment =
241+ Sentiment'
242+ { _sScore = Nothing
243+ , _sMagnitude = Nothing
244+ }
245+
246+-- | Sentiment score between -1.0 (negative sentiment) and 1.0 (positive
247+-- sentiment).
248+sScore :: Lens' Sentiment (Maybe Double)
249+sScore
250+ = lens _sScore (\ s a -> s{_sScore = a}) .
251+ mapping _Coerce
252+
253+-- | A non-negative number in the [0, +inf) range, which represents the
254+-- absolute magnitude of sentiment regardless of score (positive or
255+-- negative).
256+sMagnitude :: Lens' Sentiment (Maybe Double)
257+sMagnitude
258+ = lens _sMagnitude (\ s a -> s{_sMagnitude = a}) .
259+ mapping _Coerce
260+
261+instance FromJSON Sentiment where
262+ parseJSON
263+ = withObject "Sentiment"
264+ (\ o ->
265+ Sentiment' <$>
266+ (o .:? "score") <*> (o .:? "magnitude"))
267+
268+instance ToJSON Sentiment where
269+ toJSON Sentiment'{..}
270+ = object
271+ (catMaybes
272+ [("score" .=) <$> _sScore,
273+ ("magnitude" .=) <$> _sMagnitude])
274+
275+-- | Represents the smallest syntactic building block of the text.
276+--
277+-- /See:/ 'token' smart constructor.
278+data Token = Token'
279+ { _tDependencyEdge :: !(Maybe DependencyEdge)
280+ , _tText :: !(Maybe TextSpan)
281+ , _tLemma :: !(Maybe Text)
282+ , _tPartOfSpeech :: !(Maybe PartOfSpeech)
283+ } deriving (Eq,Show,Data,Typeable,Generic)
284+
285+-- | Creates a value of 'Token' with the minimum fields required to make a request.
286+--
287+-- Use one of the following lenses to modify other fields as desired:
288+--
289+-- * 'tDependencyEdge'
290+--
291+-- * 'tText'
292+--
293+-- * 'tLemma'
294+--
295+-- * 'tPartOfSpeech'
296+token
297+ :: Token
298+token =
299+ Token'
300+ { _tDependencyEdge = Nothing
301+ , _tText = Nothing
302+ , _tLemma = Nothing
303+ , _tPartOfSpeech = Nothing
304+ }
305+
306+-- | Dependency tree parse for this token.
307+tDependencyEdge :: Lens' Token (Maybe DependencyEdge)
308+tDependencyEdge
309+ = lens _tDependencyEdge
310+ (\ s a -> s{_tDependencyEdge = a})
311+
312+-- | The token text.
313+tText :: Lens' Token (Maybe TextSpan)
314+tText = lens _tText (\ s a -> s{_tText = a})
315+
316+-- | [Lemma](https:\/\/en.wikipedia.org\/wiki\/Lemma_%28morphology%29) of the
317+-- token.
318+tLemma :: Lens' Token (Maybe Text)
319+tLemma = lens _tLemma (\ s a -> s{_tLemma = a})
320+
321+-- | Parts of speech tag for this token.
322+tPartOfSpeech :: Lens' Token (Maybe PartOfSpeech)
323+tPartOfSpeech
324+ = lens _tPartOfSpeech
325+ (\ s a -> s{_tPartOfSpeech = a})
326+
327+instance FromJSON Token where
328+ parseJSON
329+ = withObject "Token"
330+ (\ o ->
331+ Token' <$>
332+ (o .:? "dependencyEdge") <*> (o .:? "text") <*>
333+ (o .:? "lemma")
334+ <*> (o .:? "partOfSpeech"))
335+
336+instance ToJSON Token where
337+ toJSON Token'{..}
338+ = object
339+ (catMaybes
340+ [("dependencyEdge" .=) <$> _tDependencyEdge,
341+ ("text" .=) <$> _tText, ("lemma" .=) <$> _tLemma,
342+ ("partOfSpeech" .=) <$> _tPartOfSpeech])
343+
344+--
345+-- /See:/ 'statusDetailsItem' smart constructor.
346+newtype StatusDetailsItem = StatusDetailsItem'
347+ { _sdiAddtional :: HashMap Text JSONValue
348+ } deriving (Eq,Show,Data,Typeable,Generic)
349+
350+-- | Creates a value of 'StatusDetailsItem' with the minimum fields required to make a request.
351+--
352+-- Use one of the following lenses to modify other fields as desired:
353+--
354+-- * 'sdiAddtional'
355+statusDetailsItem
356+ :: HashMap Text JSONValue -- ^ 'sdiAddtional'
357+ -> StatusDetailsItem
358+statusDetailsItem pSdiAddtional_ =
359+ StatusDetailsItem'
360+ { _sdiAddtional = _Coerce # pSdiAddtional_
361+ }
362+
363+-- | Properties of the object. Contains field \'type with type URL.
364+sdiAddtional :: Lens' StatusDetailsItem (HashMap Text JSONValue)
365+sdiAddtional
366+ = lens _sdiAddtional (\ s a -> s{_sdiAddtional = a})
367+ . _Coerce
368+
369+instance FromJSON StatusDetailsItem where
370+ parseJSON
371+ = withObject "StatusDetailsItem"
372+ (\ o -> StatusDetailsItem' <$> (parseJSONObject o))
373+
374+instance ToJSON StatusDetailsItem where
375+ toJSON = toJSON . _sdiAddtional
376+
377+-- | The request message for the text annotation API, which can perform
378+-- multiple analysis types (sentiment, entities, and syntax) in one call.
379+--
380+-- /See:/ 'annotateTextRequest' smart constructor.
381+data AnnotateTextRequest = AnnotateTextRequest'
382+ { _atrEncodingType :: !(Maybe AnnotateTextRequestEncodingType)
383+ , _atrFeatures :: !(Maybe Features)
384+ , _atrDocument :: !(Maybe Document)
385+ } deriving (Eq,Show,Data,Typeable,Generic)
386+
387+-- | Creates a value of 'AnnotateTextRequest' with the minimum fields required to make a request.
388+--
389+-- Use one of the following lenses to modify other fields as desired:
390+--
391+-- * 'atrEncodingType'
392+--
393+-- * 'atrFeatures'
394+--
395+-- * 'atrDocument'
396+annotateTextRequest
397+ :: AnnotateTextRequest
398+annotateTextRequest =
399+ AnnotateTextRequest'
400+ { _atrEncodingType = Nothing
401+ , _atrFeatures = Nothing
402+ , _atrDocument = Nothing
403+ }
404+
405+-- | The encoding type used by the API to calculate offsets.
406+atrEncodingType :: Lens' AnnotateTextRequest (Maybe AnnotateTextRequestEncodingType)
407+atrEncodingType
408+ = lens _atrEncodingType
409+ (\ s a -> s{_atrEncodingType = a})
410+
411+-- | The enabled features.
412+atrFeatures :: Lens' AnnotateTextRequest (Maybe Features)
413+atrFeatures
414+ = lens _atrFeatures (\ s a -> s{_atrFeatures = a})
415+
416+-- | Input document.
417+atrDocument :: Lens' AnnotateTextRequest (Maybe Document)
418+atrDocument
419+ = lens _atrDocument (\ s a -> s{_atrDocument = a})
420+
421+instance FromJSON AnnotateTextRequest where
422+ parseJSON
423+ = withObject "AnnotateTextRequest"
424+ (\ o ->
425+ AnnotateTextRequest' <$>
426+ (o .:? "encodingType") <*> (o .:? "features") <*>
427+ (o .:? "document"))
428+
429+instance ToJSON AnnotateTextRequest where
430+ toJSON AnnotateTextRequest'{..}
431+ = object
432+ (catMaybes
433+ [("encodingType" .=) <$> _atrEncodingType,
434+ ("features" .=) <$> _atrFeatures,
435+ ("document" .=) <$> _atrDocument])
436+
437+-- | Represents a mention for an entity in the text. Currently, proper noun
438+-- mentions are supported.
439+--
440+-- /See:/ 'entityMention' smart constructor.
441+data EntityMention = EntityMention'
442+ { _emText :: !(Maybe TextSpan)
443+ , _emType :: !(Maybe EntityMentionType)
444+ } deriving (Eq,Show,Data,Typeable,Generic)
445+
446+-- | Creates a value of 'EntityMention' with the minimum fields required to make a request.
447+--
448+-- Use one of the following lenses to modify other fields as desired:
449+--
450+-- * 'emText'
451+--
452+-- * 'emType'
453+entityMention
454+ :: EntityMention
455+entityMention =
456+ EntityMention'
457+ { _emText = Nothing
458+ , _emType = Nothing
459+ }
460+
461+-- | The mention text.
462+emText :: Lens' EntityMention (Maybe TextSpan)
463+emText = lens _emText (\ s a -> s{_emText = a})
464+
465+-- | The type of the entity mention.
466+emType :: Lens' EntityMention (Maybe EntityMentionType)
467+emType = lens _emType (\ s a -> s{_emType = a})
468+
469+instance FromJSON EntityMention where
470+ parseJSON
471+ = withObject "EntityMention"
472+ (\ o ->
473+ EntityMention' <$> (o .:? "text") <*> (o .:? "type"))
474+
475+instance ToJSON EntityMention where
476+ toJSON EntityMention'{..}
477+ = object
478+ (catMaybes
479+ [("text" .=) <$> _emText, ("type" .=) <$> _emType])
480+
481+-- | Represents an output piece of text.
482+--
483+-- /See:/ 'textSpan' smart constructor.
484+data TextSpan = TextSpan'
485+ { _tsBeginOffSet :: !(Maybe (Textual Int32))
486+ , _tsContent :: !(Maybe Text)
487+ } deriving (Eq,Show,Data,Typeable,Generic)
488+
489+-- | Creates a value of 'TextSpan' with the minimum fields required to make a request.
490+--
491+-- Use one of the following lenses to modify other fields as desired:
492+--
493+-- * 'tsBeginOffSet'
494+--
495+-- * 'tsContent'
496+textSpan
497+ :: TextSpan
498+textSpan =
499+ TextSpan'
500+ { _tsBeginOffSet = Nothing
501+ , _tsContent = Nothing
502+ }
503+
504+-- | The API calculates the beginning offset of the content in the original
505+-- document according to the EncodingType specified in the API request.
506+tsBeginOffSet :: Lens' TextSpan (Maybe Int32)
507+tsBeginOffSet
508+ = lens _tsBeginOffSet
509+ (\ s a -> s{_tsBeginOffSet = a})
510+ . mapping _Coerce
511+
512+-- | The content of the output text.
513+tsContent :: Lens' TextSpan (Maybe Text)
514+tsContent
515+ = lens _tsContent (\ s a -> s{_tsContent = a})
516+
517+instance FromJSON TextSpan where
518+ parseJSON
519+ = withObject "TextSpan"
520+ (\ o ->
521+ TextSpan' <$>
522+ (o .:? "beginOffset") <*> (o .:? "content"))
523+
524+instance ToJSON TextSpan where
525+ toJSON TextSpan'{..}
526+ = object
527+ (catMaybes
528+ [("beginOffset" .=) <$> _tsBeginOffSet,
529+ ("content" .=) <$> _tsContent])
530+
531+-- | The text annotations response message.
532+--
533+-- /See:/ 'annotateTextResponse' smart constructor.
534+data AnnotateTextResponse = AnnotateTextResponse'
535+ { _atrEntities :: !(Maybe [Entity])
536+ , _atrTokens :: !(Maybe [Token])
537+ , _atrDocumentSentiment :: !(Maybe Sentiment)
538+ , _atrSentences :: !(Maybe [Sentence])
539+ , _atrLanguage :: !(Maybe Text)
540+ } deriving (Eq,Show,Data,Typeable,Generic)
541+
542+-- | Creates a value of 'AnnotateTextResponse' with the minimum fields required to make a request.
543+--
544+-- Use one of the following lenses to modify other fields as desired:
545+--
546+-- * 'atrEntities'
547+--
548+-- * 'atrTokens'
549+--
550+-- * 'atrDocumentSentiment'
551+--
552+-- * 'atrSentences'
553+--
554+-- * 'atrLanguage'
555+annotateTextResponse
556+ :: AnnotateTextResponse
557+annotateTextResponse =
558+ AnnotateTextResponse'
559+ { _atrEntities = Nothing
560+ , _atrTokens = Nothing
561+ , _atrDocumentSentiment = Nothing
562+ , _atrSentences = Nothing
563+ , _atrLanguage = Nothing
564+ }
565+
566+-- | Entities, along with their semantic information, in the input document.
567+-- Populated if the user enables
568+-- AnnotateTextRequest.Features.extract_entities.
569+atrEntities :: Lens' AnnotateTextResponse [Entity]
570+atrEntities
571+ = lens _atrEntities (\ s a -> s{_atrEntities = a}) .
572+ _Default
573+ . _Coerce
574+
575+-- | Tokens, along with their syntactic information, in the input document.
576+-- Populated if the user enables
577+-- AnnotateTextRequest.Features.extract_syntax.
578+atrTokens :: Lens' AnnotateTextResponse [Token]
579+atrTokens
580+ = lens _atrTokens (\ s a -> s{_atrTokens = a}) .
581+ _Default
582+ . _Coerce
583+
584+-- | The overall sentiment for the document. Populated if the user enables
585+-- AnnotateTextRequest.Features.extract_document_sentiment.
586+atrDocumentSentiment :: Lens' AnnotateTextResponse (Maybe Sentiment)
587+atrDocumentSentiment
588+ = lens _atrDocumentSentiment
589+ (\ s a -> s{_atrDocumentSentiment = a})
590+
591+-- | Sentences in the input document. Populated if the user enables
592+-- AnnotateTextRequest.Features.extract_syntax.
593+atrSentences :: Lens' AnnotateTextResponse [Sentence]
594+atrSentences
595+ = lens _atrSentences (\ s a -> s{_atrSentences = a})
596+ . _Default
597+ . _Coerce
598+
599+-- | The language of the text, which will be the same as the language
600+-- specified in the request or, if not specified, the
601+-- automatically-detected language. See \`Document.language\` field for
602+-- more details.
603+atrLanguage :: Lens' AnnotateTextResponse (Maybe Text)
604+atrLanguage
605+ = lens _atrLanguage (\ s a -> s{_atrLanguage = a})
606+
607+instance FromJSON AnnotateTextResponse where
608+ parseJSON
609+ = withObject "AnnotateTextResponse"
610+ (\ o ->
611+ AnnotateTextResponse' <$>
612+ (o .:? "entities" .!= mempty) <*>
613+ (o .:? "tokens" .!= mempty)
614+ <*> (o .:? "documentSentiment")
615+ <*> (o .:? "sentences" .!= mempty)
616+ <*> (o .:? "language"))
617+
618+instance ToJSON AnnotateTextResponse where
619+ toJSON AnnotateTextResponse'{..}
620+ = object
621+ (catMaybes
622+ [("entities" .=) <$> _atrEntities,
623+ ("tokens" .=) <$> _atrTokens,
624+ ("documentSentiment" .=) <$> _atrDocumentSentiment,
625+ ("sentences" .=) <$> _atrSentences,
626+ ("language" .=) <$> _atrLanguage])
627+
628+-- | All available features for sentiment, syntax, and semantic analysis.
629+-- Setting each one to true will enable that specific analysis for the
630+-- input.
631+--
632+-- /See:/ 'features' smart constructor.
633+data Features = Features'
634+ { _fExtractSyntax :: !(Maybe Bool)
635+ , _fExtractDocumentSentiment :: !(Maybe Bool)
636+ , _fExtractEntities :: !(Maybe Bool)
637+ } deriving (Eq,Show,Data,Typeable,Generic)
638+
639+-- | Creates a value of 'Features' with the minimum fields required to make a request.
640+--
641+-- Use one of the following lenses to modify other fields as desired:
642+--
643+-- * 'fExtractSyntax'
644+--
645+-- * 'fExtractDocumentSentiment'
646+--
647+-- * 'fExtractEntities'
648+features
649+ :: Features
650+features =
651+ Features'
652+ { _fExtractSyntax = Nothing
653+ , _fExtractDocumentSentiment = Nothing
654+ , _fExtractEntities = Nothing
655+ }
656+
657+-- | Extract syntax information.
658+fExtractSyntax :: Lens' Features (Maybe Bool)
659+fExtractSyntax
660+ = lens _fExtractSyntax
661+ (\ s a -> s{_fExtractSyntax = a})
662+
663+-- | Extract document-level sentiment.
664+fExtractDocumentSentiment :: Lens' Features (Maybe Bool)
665+fExtractDocumentSentiment
666+ = lens _fExtractDocumentSentiment
667+ (\ s a -> s{_fExtractDocumentSentiment = a})
668+
669+-- | Extract entities.
670+fExtractEntities :: Lens' Features (Maybe Bool)
671+fExtractEntities
672+ = lens _fExtractEntities
673+ (\ s a -> s{_fExtractEntities = a})
674+
675+instance FromJSON Features where
676+ parseJSON
677+ = withObject "Features"
678+ (\ o ->
679+ Features' <$>
680+ (o .:? "extractSyntax") <*>
681+ (o .:? "extractDocumentSentiment")
682+ <*> (o .:? "extractEntities"))
683+
684+instance ToJSON Features where
685+ toJSON Features'{..}
686+ = object
687+ (catMaybes
688+ [("extractSyntax" .=) <$> _fExtractSyntax,
689+ ("extractDocumentSentiment" .=) <$>
690+ _fExtractDocumentSentiment,
691+ ("extractEntities" .=) <$> _fExtractEntities])
692+
693+-- | ################################################################ #
694+-- Represents the input to API methods.
695+--
696+-- /See:/ 'document' smart constructor.
697+data Document = Document'
698+ { _dContent :: !(Maybe Text)
699+ , _dLanguage :: !(Maybe Text)
700+ , _dGcsContentURI :: !(Maybe Text)
701+ , _dType :: !(Maybe DocumentType)
702+ } deriving (Eq,Show,Data,Typeable,Generic)
703+
704+-- | Creates a value of 'Document' with the minimum fields required to make a request.
705+--
706+-- Use one of the following lenses to modify other fields as desired:
707+--
708+-- * 'dContent'
709+--
710+-- * 'dLanguage'
711+--
712+-- * 'dGcsContentURI'
713+--
714+-- * 'dType'
715+document
716+ :: Document
717+document =
718+ Document'
719+ { _dContent = Nothing
720+ , _dLanguage = Nothing
721+ , _dGcsContentURI = Nothing
722+ , _dType = Nothing
723+ }
724+
725+-- | The content of the input in string format.
726+dContent :: Lens' Document (Maybe Text)
727+dContent = lens _dContent (\ s a -> s{_dContent = a})
728+
729+-- | The language of the document (if not specified, the language is
730+-- automatically detected). Both ISO and BCP-47 language codes are
731+-- accepted.
732+-- **Current Language Restrictions:** * Only English, Spanish, and Japanese
733+-- textual content are supported. If the language (either specified by the
734+-- caller or automatically detected) is not supported by the called API
735+-- method, an \`INVALID_ARGUMENT\` error is returned.
736+dLanguage :: Lens' Document (Maybe Text)
737+dLanguage
738+ = lens _dLanguage (\ s a -> s{_dLanguage = a})
739+
740+-- | The Google Cloud Storage URI where the file content is located. This URI
741+-- must be of the form: gs:\/\/bucket_name\/object_name. For more details,
742+-- see https:\/\/cloud.google.com\/storage\/docs\/reference-uris. NOTE:
743+-- Cloud Storage object versioning is not supported.
744+dGcsContentURI :: Lens' Document (Maybe Text)
745+dGcsContentURI
746+ = lens _dGcsContentURI
747+ (\ s a -> s{_dGcsContentURI = a})
748+
749+-- | Required. If the type is not set or is \`TYPE_UNSPECIFIED\`, returns an
750+-- \`INVALID_ARGUMENT\` error.
751+dType :: Lens' Document (Maybe DocumentType)
752+dType = lens _dType (\ s a -> s{_dType = a})
753+
754+instance FromJSON Document where
755+ parseJSON
756+ = withObject "Document"
757+ (\ o ->
758+ Document' <$>
759+ (o .:? "content") <*> (o .:? "language") <*>
760+ (o .:? "gcsContentUri")
761+ <*> (o .:? "type"))
762+
763+instance ToJSON Document where
764+ toJSON Document'{..}
765+ = object
766+ (catMaybes
767+ [("content" .=) <$> _dContent,
768+ ("language" .=) <$> _dLanguage,
769+ ("gcsContentUri" .=) <$> _dGcsContentURI,
770+ ("type" .=) <$> _dType])
771+
772+-- | The sentiment analysis request message.
773+--
774+-- /See:/ 'analyzeSentimentRequest' smart constructor.
775+data AnalyzeSentimentRequest = AnalyzeSentimentRequest'
776+ { _aEncodingType :: !(Maybe AnalyzeSentimentRequestEncodingType)
777+ , _aDocument :: !(Maybe Document)
778+ } deriving (Eq,Show,Data,Typeable,Generic)
779+
780+-- | Creates a value of 'AnalyzeSentimentRequest' with the minimum fields required to make a request.
781+--
782+-- Use one of the following lenses to modify other fields as desired:
783+--
784+-- * 'aEncodingType'
785+--
786+-- * 'aDocument'
787+analyzeSentimentRequest
788+ :: AnalyzeSentimentRequest
789+analyzeSentimentRequest =
790+ AnalyzeSentimentRequest'
791+ { _aEncodingType = Nothing
792+ , _aDocument = Nothing
793+ }
794+
795+-- | The encoding type used by the API to calculate sentence offsets.
796+aEncodingType :: Lens' AnalyzeSentimentRequest (Maybe AnalyzeSentimentRequestEncodingType)
797+aEncodingType
798+ = lens _aEncodingType
799+ (\ s a -> s{_aEncodingType = a})
800+
801+-- | Input document. Currently, \`analyzeSentiment\` only supports English
802+-- text (Document.language=\"EN\").
803+aDocument :: Lens' AnalyzeSentimentRequest (Maybe Document)
804+aDocument
805+ = lens _aDocument (\ s a -> s{_aDocument = a})
806+
807+instance FromJSON AnalyzeSentimentRequest where
808+ parseJSON
809+ = withObject "AnalyzeSentimentRequest"
810+ (\ o ->
811+ AnalyzeSentimentRequest' <$>
812+ (o .:? "encodingType") <*> (o .:? "document"))
813+
814+instance ToJSON AnalyzeSentimentRequest where
815+ toJSON AnalyzeSentimentRequest'{..}
816+ = object
817+ (catMaybes
818+ [("encodingType" .=) <$> _aEncodingType,
819+ ("document" .=) <$> _aDocument])
820+
821+-- | The entity analysis response message.
822+--
823+-- /See:/ 'analyzeEntitiesResponse' smart constructor.
824+data AnalyzeEntitiesResponse = AnalyzeEntitiesResponse'
825+ { _aerEntities :: !(Maybe [Entity])
826+ , _aerLanguage :: !(Maybe Text)
827+ } deriving (Eq,Show,Data,Typeable,Generic)
828+
829+-- | Creates a value of 'AnalyzeEntitiesResponse' with the minimum fields required to make a request.
830+--
831+-- Use one of the following lenses to modify other fields as desired:
832+--
833+-- * 'aerEntities'
834+--
835+-- * 'aerLanguage'
836+analyzeEntitiesResponse
837+ :: AnalyzeEntitiesResponse
838+analyzeEntitiesResponse =
839+ AnalyzeEntitiesResponse'
840+ { _aerEntities = Nothing
841+ , _aerLanguage = Nothing
842+ }
843+
844+-- | The recognized entities in the input document.
845+aerEntities :: Lens' AnalyzeEntitiesResponse [Entity]
846+aerEntities
847+ = lens _aerEntities (\ s a -> s{_aerEntities = a}) .
848+ _Default
849+ . _Coerce
850+
851+-- | The language of the text, which will be the same as the language
852+-- specified in the request or, if not specified, the
853+-- automatically-detected language. See \`Document.language\` field for
854+-- more details.
855+aerLanguage :: Lens' AnalyzeEntitiesResponse (Maybe Text)
856+aerLanguage
857+ = lens _aerLanguage (\ s a -> s{_aerLanguage = a})
858+
859+instance FromJSON AnalyzeEntitiesResponse where
860+ parseJSON
861+ = withObject "AnalyzeEntitiesResponse"
862+ (\ o ->
863+ AnalyzeEntitiesResponse' <$>
864+ (o .:? "entities" .!= mempty) <*> (o .:? "language"))
865+
866+instance ToJSON AnalyzeEntitiesResponse where
867+ toJSON AnalyzeEntitiesResponse'{..}
868+ = object
869+ (catMaybes
870+ [("entities" .=) <$> _aerEntities,
871+ ("language" .=) <$> _aerLanguage])
872+
873+-- | The sentiment analysis response message.
874+--
875+-- /See:/ 'analyzeSentimentResponse' smart constructor.
876+data AnalyzeSentimentResponse = AnalyzeSentimentResponse'
877+ { _asrDocumentSentiment :: !(Maybe Sentiment)
878+ , _asrSentences :: !(Maybe [Sentence])
879+ , _asrLanguage :: !(Maybe Text)
880+ } deriving (Eq,Show,Data,Typeable,Generic)
881+
882+-- | Creates a value of 'AnalyzeSentimentResponse' with the minimum fields required to make a request.
883+--
884+-- Use one of the following lenses to modify other fields as desired:
885+--
886+-- * 'asrDocumentSentiment'
887+--
888+-- * 'asrSentences'
889+--
890+-- * 'asrLanguage'
891+analyzeSentimentResponse
892+ :: AnalyzeSentimentResponse
893+analyzeSentimentResponse =
894+ AnalyzeSentimentResponse'
895+ { _asrDocumentSentiment = Nothing
896+ , _asrSentences = Nothing
897+ , _asrLanguage = Nothing
898+ }
899+
900+-- | The overall sentiment of the input document.
901+asrDocumentSentiment :: Lens' AnalyzeSentimentResponse (Maybe Sentiment)
902+asrDocumentSentiment
903+ = lens _asrDocumentSentiment
904+ (\ s a -> s{_asrDocumentSentiment = a})
905+
906+-- | The sentiment for all the sentences in the document.
907+asrSentences :: Lens' AnalyzeSentimentResponse [Sentence]
908+asrSentences
909+ = lens _asrSentences (\ s a -> s{_asrSentences = a})
910+ . _Default
911+ . _Coerce
912+
913+-- | The language of the text, which will be the same as the language
914+-- specified in the request or, if not specified, the
915+-- automatically-detected language. See \`Document.language\` field for
916+-- more details.
917+asrLanguage :: Lens' AnalyzeSentimentResponse (Maybe Text)
918+asrLanguage
919+ = lens _asrLanguage (\ s a -> s{_asrLanguage = a})
920+
921+instance FromJSON AnalyzeSentimentResponse where
922+ parseJSON
923+ = withObject "AnalyzeSentimentResponse"
924+ (\ o ->
925+ AnalyzeSentimentResponse' <$>
926+ (o .:? "documentSentiment") <*>
927+ (o .:? "sentences" .!= mempty)
928+ <*> (o .:? "language"))
929+
930+instance ToJSON AnalyzeSentimentResponse where
931+ toJSON AnalyzeSentimentResponse'{..}
932+ = object
933+ (catMaybes
934+ [("documentSentiment" .=) <$> _asrDocumentSentiment,
935+ ("sentences" .=) <$> _asrSentences,
936+ ("language" .=) <$> _asrLanguage])
937+
938+-- | The entity analysis request message.
939+--
940+-- /See:/ 'analyzeEntitiesRequest' smart constructor.
941+data AnalyzeEntitiesRequest = AnalyzeEntitiesRequest'
942+ { _aerEncodingType :: !(Maybe AnalyzeEntitiesRequestEncodingType)
943+ , _aerDocument :: !(Maybe Document)
944+ } deriving (Eq,Show,Data,Typeable,Generic)
945+
946+-- | Creates a value of 'AnalyzeEntitiesRequest' with the minimum fields required to make a request.
947+--
948+-- Use one of the following lenses to modify other fields as desired:
949+--
950+-- * 'aerEncodingType'
951+--
952+-- * 'aerDocument'
953+analyzeEntitiesRequest
954+ :: AnalyzeEntitiesRequest
955+analyzeEntitiesRequest =
956+ AnalyzeEntitiesRequest'
957+ { _aerEncodingType = Nothing
958+ , _aerDocument = Nothing
959+ }
960+
961+-- | The encoding type used by the API to calculate offsets.
962+aerEncodingType :: Lens' AnalyzeEntitiesRequest (Maybe AnalyzeEntitiesRequestEncodingType)
963+aerEncodingType
964+ = lens _aerEncodingType
965+ (\ s a -> s{_aerEncodingType = a})
966+
967+-- | Input document.
968+aerDocument :: Lens' AnalyzeEntitiesRequest (Maybe Document)
969+aerDocument
970+ = lens _aerDocument (\ s a -> s{_aerDocument = a})
971+
972+instance FromJSON AnalyzeEntitiesRequest where
973+ parseJSON
974+ = withObject "AnalyzeEntitiesRequest"
975+ (\ o ->
976+ AnalyzeEntitiesRequest' <$>
977+ (o .:? "encodingType") <*> (o .:? "document"))
978+
979+instance ToJSON AnalyzeEntitiesRequest where
980+ toJSON AnalyzeEntitiesRequest'{..}
981+ = object
982+ (catMaybes
983+ [("encodingType" .=) <$> _aerEncodingType,
984+ ("document" .=) <$> _aerDocument])
985+
986+-- | Represents a phrase in the text that is a known entity, such as a
987+-- person, an organization, or location. The API associates information,
988+-- such as salience and mentions, with entities.
989+--
990+-- /See:/ 'entity' smart constructor.
991+data Entity = Entity'
992+ { _eName :: !(Maybe Text)
993+ , _eSalience :: !(Maybe (Textual Double))
994+ , _eMetadata :: !(Maybe EntityMetadata)
995+ , _eType :: !(Maybe EntityType)
996+ , _eMentions :: !(Maybe [EntityMention])
997+ } deriving (Eq,Show,Data,Typeable,Generic)
998+
999+-- | Creates a value of 'Entity' with the minimum fields required to make a request.
1000+--
1001+-- Use one of the following lenses to modify other fields as desired:
1002+--
1003+-- * 'eName'
1004+--
1005+-- * 'eSalience'
1006+--
1007+-- * 'eMetadata'
1008+--
1009+-- * 'eType'
1010+--
1011+-- * 'eMentions'
1012+entity
1013+ :: Entity
1014+entity =
1015+ Entity'
1016+ { _eName = Nothing
1017+ , _eSalience = Nothing
1018+ , _eMetadata = Nothing
1019+ , _eType = Nothing
1020+ , _eMentions = Nothing
1021+ }
1022+
1023+-- | The representative name for the entity.
1024+eName :: Lens' Entity (Maybe Text)
1025+eName = lens _eName (\ s a -> s{_eName = a})
1026+
1027+-- | The salience score associated with the entity in the [0, 1.0] range. The
1028+-- salience score for an entity provides information about the importance
1029+-- or centrality of that entity to the entire document text. Scores closer
1030+-- to 0 are less salient, while scores closer to 1.0 are highly salient.
1031+eSalience :: Lens' Entity (Maybe Double)
1032+eSalience
1033+ = lens _eSalience (\ s a -> s{_eSalience = a}) .
1034+ mapping _Coerce
1035+
1036+-- | Metadata associated with the entity. Currently, Wikipedia URLs and
1037+-- Knowledge Graph MIDs are provided, if available. The associated keys are
1038+-- \"wikipedia_url\" and \"mid\", respectively.
1039+eMetadata :: Lens' Entity (Maybe EntityMetadata)
1040+eMetadata
1041+ = lens _eMetadata (\ s a -> s{_eMetadata = a})
1042+
1043+-- | The entity type.
1044+eType :: Lens' Entity (Maybe EntityType)
1045+eType = lens _eType (\ s a -> s{_eType = a})
1046+
1047+-- | The mentions of this entity in the input document. The API currently
1048+-- supports proper noun mentions.
1049+eMentions :: Lens' Entity [EntityMention]
1050+eMentions
1051+ = lens _eMentions (\ s a -> s{_eMentions = a}) .
1052+ _Default
1053+ . _Coerce
1054+
1055+instance FromJSON Entity where
1056+ parseJSON
1057+ = withObject "Entity"
1058+ (\ o ->
1059+ Entity' <$>
1060+ (o .:? "name") <*> (o .:? "salience") <*>
1061+ (o .:? "metadata")
1062+ <*> (o .:? "type")
1063+ <*> (o .:? "mentions" .!= mempty))
1064+
1065+instance ToJSON Entity where
1066+ toJSON Entity'{..}
1067+ = object
1068+ (catMaybes
1069+ [("name" .=) <$> _eName,
1070+ ("salience" .=) <$> _eSalience,
1071+ ("metadata" .=) <$> _eMetadata,
1072+ ("type" .=) <$> _eType,
1073+ ("mentions" .=) <$> _eMentions])
1074+
1075+-- | The syntax analysis response message.
1076+--
1077+-- /See:/ 'analyzeSyntaxResponse' smart constructor.
1078+data AnalyzeSyntaxResponse = AnalyzeSyntaxResponse'
1079+ { _aTokens :: !(Maybe [Token])
1080+ , _aSentences :: !(Maybe [Sentence])
1081+ , _aLanguage :: !(Maybe Text)
1082+ } deriving (Eq,Show,Data,Typeable,Generic)
1083+
1084+-- | Creates a value of 'AnalyzeSyntaxResponse' with the minimum fields required to make a request.
1085+--
1086+-- Use one of the following lenses to modify other fields as desired:
1087+--
1088+-- * 'aTokens'
1089+--
1090+-- * 'aSentences'
1091+--
1092+-- * 'aLanguage'
1093+analyzeSyntaxResponse
1094+ :: AnalyzeSyntaxResponse
1095+analyzeSyntaxResponse =
1096+ AnalyzeSyntaxResponse'
1097+ { _aTokens = Nothing
1098+ , _aSentences = Nothing
1099+ , _aLanguage = Nothing
1100+ }
1101+
1102+-- | Tokens, along with their syntactic information, in the input document.
1103+aTokens :: Lens' AnalyzeSyntaxResponse [Token]
1104+aTokens
1105+ = lens _aTokens (\ s a -> s{_aTokens = a}) . _Default
1106+ . _Coerce
1107+
1108+-- | Sentences in the input document.
1109+aSentences :: Lens' AnalyzeSyntaxResponse [Sentence]
1110+aSentences
1111+ = lens _aSentences (\ s a -> s{_aSentences = a}) .
1112+ _Default
1113+ . _Coerce
1114+
1115+-- | The language of the text, which will be the same as the language
1116+-- specified in the request or, if not specified, the
1117+-- automatically-detected language. See \`Document.language\` field for
1118+-- more details.
1119+aLanguage :: Lens' AnalyzeSyntaxResponse (Maybe Text)
1120+aLanguage
1121+ = lens _aLanguage (\ s a -> s{_aLanguage = a})
1122+
1123+instance FromJSON AnalyzeSyntaxResponse where
1124+ parseJSON
1125+ = withObject "AnalyzeSyntaxResponse"
1126+ (\ o ->
1127+ AnalyzeSyntaxResponse' <$>
1128+ (o .:? "tokens" .!= mempty) <*>
1129+ (o .:? "sentences" .!= mempty)
1130+ <*> (o .:? "language"))
1131+
1132+instance ToJSON AnalyzeSyntaxResponse where
1133+ toJSON AnalyzeSyntaxResponse'{..}
1134+ = object
1135+ (catMaybes
1136+ [("tokens" .=) <$> _aTokens,
1137+ ("sentences" .=) <$> _aSentences,
1138+ ("language" .=) <$> _aLanguage])
1139+
1140+-- | Metadata associated with the entity. Currently, Wikipedia URLs and
1141+-- Knowledge Graph MIDs are provided, if available. The associated keys are
1142+-- \"wikipedia_url\" and \"mid\", respectively.
1143+--
1144+-- /See:/ 'entityMetadata' smart constructor.
1145+newtype EntityMetadata = EntityMetadata'
1146+ { _emAddtional :: HashMap Text Text
1147+ } deriving (Eq,Show,Data,Typeable,Generic)
1148+
1149+-- | Creates a value of 'EntityMetadata' with the minimum fields required to make a request.
1150+--
1151+-- Use one of the following lenses to modify other fields as desired:
1152+--
1153+-- * 'emAddtional'
1154+entityMetadata
1155+ :: HashMap Text Text -- ^ 'emAddtional'
1156+ -> EntityMetadata
1157+entityMetadata pEmAddtional_ =
1158+ EntityMetadata'
1159+ { _emAddtional = _Coerce # pEmAddtional_
1160+ }
1161+
1162+emAddtional :: Lens' EntityMetadata (HashMap Text Text)
1163+emAddtional
1164+ = lens _emAddtional (\ s a -> s{_emAddtional = a}) .
1165+ _Coerce
1166+
1167+instance FromJSON EntityMetadata where
1168+ parseJSON
1169+ = withObject "EntityMetadata"
1170+ (\ o -> EntityMetadata' <$> (parseJSONObject o))
1171+
1172+instance ToJSON EntityMetadata where
1173+ toJSON = toJSON . _emAddtional
1174+
1175+-- | Represents part of speech information for a token. Parts of speech are
1176+-- as defined in
1177+-- http:\/\/www.lrec-conf.org\/proceedings\/lrec2012\/pdf\/274_Paper.pdf
1178+--
1179+-- /See:/ 'partOfSpeech' smart constructor.
1180+data PartOfSpeech = PartOfSpeech'
1181+ { _posProper :: !(Maybe PartOfSpeechProper)
1182+ , _posTag :: !(Maybe PartOfSpeechTag)
1183+ , _posPerson :: !(Maybe PartOfSpeechPerson)
1184+ , _posAspect :: !(Maybe PartOfSpeechAspect)
1185+ , _posCase :: !(Maybe PartOfSpeechCase)
1186+ , _posGender :: !(Maybe PartOfSpeechGender)
1187+ , _posReciprocity :: !(Maybe PartOfSpeechReciprocity)
1188+ , _posNumber :: !(Maybe PartOfSpeechNumber)
1189+ , _posVoice :: !(Maybe PartOfSpeechVoice)
1190+ , _posForm :: !(Maybe PartOfSpeechForm)
1191+ , _posTense :: !(Maybe PartOfSpeechTense)
1192+ , _posMood :: !(Maybe PartOfSpeechMood)
1193+ } deriving (Eq,Show,Data,Typeable,Generic)
1194+
1195+-- | Creates a value of 'PartOfSpeech' with the minimum fields required to make a request.
1196+--
1197+-- Use one of the following lenses to modify other fields as desired:
1198+--
1199+-- * 'posProper'
1200+--
1201+-- * 'posTag'
1202+--
1203+-- * 'posPerson'
1204+--
1205+-- * 'posAspect'
1206+--
1207+-- * 'posCase'
1208+--
1209+-- * 'posGender'
1210+--
1211+-- * 'posReciprocity'
1212+--
1213+-- * 'posNumber'
1214+--
1215+-- * 'posVoice'
1216+--
1217+-- * 'posForm'
1218+--
1219+-- * 'posTense'
1220+--
1221+-- * 'posMood'
1222+partOfSpeech
1223+ :: PartOfSpeech
1224+partOfSpeech =
1225+ PartOfSpeech'
1226+ { _posProper = Nothing
1227+ , _posTag = Nothing
1228+ , _posPerson = Nothing
1229+ , _posAspect = Nothing
1230+ , _posCase = Nothing
1231+ , _posGender = Nothing
1232+ , _posReciprocity = Nothing
1233+ , _posNumber = Nothing
1234+ , _posVoice = Nothing
1235+ , _posForm = Nothing
1236+ , _posTense = Nothing
1237+ , _posMood = Nothing
1238+ }
1239+
1240+-- | The grammatical properness.
1241+posProper :: Lens' PartOfSpeech (Maybe PartOfSpeechProper)
1242+posProper
1243+ = lens _posProper (\ s a -> s{_posProper = a})
1244+
1245+-- | The part of speech tag.
1246+posTag :: Lens' PartOfSpeech (Maybe PartOfSpeechTag)
1247+posTag = lens _posTag (\ s a -> s{_posTag = a})
1248+
1249+-- | The grammatical person.
1250+posPerson :: Lens' PartOfSpeech (Maybe PartOfSpeechPerson)
1251+posPerson
1252+ = lens _posPerson (\ s a -> s{_posPerson = a})
1253+
1254+-- | The grammatical aspect.
1255+posAspect :: Lens' PartOfSpeech (Maybe PartOfSpeechAspect)
1256+posAspect
1257+ = lens _posAspect (\ s a -> s{_posAspect = a})
1258+
1259+-- | The grammatical case.
1260+posCase :: Lens' PartOfSpeech (Maybe PartOfSpeechCase)
1261+posCase = lens _posCase (\ s a -> s{_posCase = a})
1262+
1263+-- | The grammatical gender.
1264+posGender :: Lens' PartOfSpeech (Maybe PartOfSpeechGender)
1265+posGender
1266+ = lens _posGender (\ s a -> s{_posGender = a})
1267+
1268+-- | The grammatical reciprocity.
1269+posReciprocity :: Lens' PartOfSpeech (Maybe PartOfSpeechReciprocity)
1270+posReciprocity
1271+ = lens _posReciprocity
1272+ (\ s a -> s{_posReciprocity = a})
1273+
1274+-- | The grammatical number.
1275+posNumber :: Lens' PartOfSpeech (Maybe PartOfSpeechNumber)
1276+posNumber
1277+ = lens _posNumber (\ s a -> s{_posNumber = a})
1278+
1279+-- | The grammatical voice.
1280+posVoice :: Lens' PartOfSpeech (Maybe PartOfSpeechVoice)
1281+posVoice = lens _posVoice (\ s a -> s{_posVoice = a})
1282+
1283+-- | The grammatical form.
1284+posForm :: Lens' PartOfSpeech (Maybe PartOfSpeechForm)
1285+posForm = lens _posForm (\ s a -> s{_posForm = a})
1286+
1287+-- | The grammatical tense.
1288+posTense :: Lens' PartOfSpeech (Maybe PartOfSpeechTense)
1289+posTense = lens _posTense (\ s a -> s{_posTense = a})
1290+
1291+-- | The grammatical mood.
1292+posMood :: Lens' PartOfSpeech (Maybe PartOfSpeechMood)
1293+posMood = lens _posMood (\ s a -> s{_posMood = a})
1294+
1295+instance FromJSON PartOfSpeech where
1296+ parseJSON
1297+ = withObject "PartOfSpeech"
1298+ (\ o ->
1299+ PartOfSpeech' <$>
1300+ (o .:? "proper") <*> (o .:? "tag") <*>
1301+ (o .:? "person")
1302+ <*> (o .:? "aspect")
1303+ <*> (o .:? "case")
1304+ <*> (o .:? "gender")
1305+ <*> (o .:? "reciprocity")
1306+ <*> (o .:? "number")
1307+ <*> (o .:? "voice")
1308+ <*> (o .:? "form")
1309+ <*> (o .:? "tense")
1310+ <*> (o .:? "mood"))
1311+
1312+instance ToJSON PartOfSpeech where
1313+ toJSON PartOfSpeech'{..}
1314+ = object
1315+ (catMaybes
1316+ [("proper" .=) <$> _posProper,
1317+ ("tag" .=) <$> _posTag, ("person" .=) <$> _posPerson,
1318+ ("aspect" .=) <$> _posAspect,
1319+ ("case" .=) <$> _posCase,
1320+ ("gender" .=) <$> _posGender,
1321+ ("reciprocity" .=) <$> _posReciprocity,
1322+ ("number" .=) <$> _posNumber,
1323+ ("voice" .=) <$> _posVoice, ("form" .=) <$> _posForm,
1324+ ("tense" .=) <$> _posTense,
1325+ ("mood" .=) <$> _posMood])
1326+
1327+-- | Represents a sentence in the input document.
1328+--
1329+-- /See:/ 'sentence' smart constructor.
1330+data Sentence = Sentence'
1331+ { _sSentiment :: !(Maybe Sentiment)
1332+ , _sText :: !(Maybe TextSpan)
1333+ } deriving (Eq,Show,Data,Typeable,Generic)
1334+
1335+-- | Creates a value of 'Sentence' with the minimum fields required to make a request.
1336+--
1337+-- Use one of the following lenses to modify other fields as desired:
1338+--
1339+-- * 'sSentiment'
1340+--
1341+-- * 'sText'
1342+sentence
1343+ :: Sentence
1344+sentence =
1345+ Sentence'
1346+ { _sSentiment = Nothing
1347+ , _sText = Nothing
1348+ }
1349+
1350+-- | For calls to AnalyzeSentiment or if
1351+-- AnnotateTextRequest.Features.extract_document_sentiment is set to true,
1352+-- this field will contain the sentiment for the sentence.
1353+sSentiment :: Lens' Sentence (Maybe Sentiment)
1354+sSentiment
1355+ = lens _sSentiment (\ s a -> s{_sSentiment = a})
1356+
1357+-- | The sentence text.
1358+sText :: Lens' Sentence (Maybe TextSpan)
1359+sText = lens _sText (\ s a -> s{_sText = a})
1360+
1361+instance FromJSON Sentence where
1362+ parseJSON
1363+ = withObject "Sentence"
1364+ (\ o ->
1365+ Sentence' <$> (o .:? "sentiment") <*> (o .:? "text"))
1366+
1367+instance ToJSON Sentence where
1368+ toJSON Sentence'{..}
1369+ = object
1370+ (catMaybes
1371+ [("sentiment" .=) <$> _sSentiment,
1372+ ("text" .=) <$> _sText])