Skip to content

Commit e84a0cb

Browse files
committed
feat: regenrate services using current api def and generator
1 parent 8b14dda commit e84a0cb

File tree

4 files changed

+175
-38
lines changed

4 files changed

+175
-38
lines changed

ibm_watson/discovery_v2.py

Lines changed: 163 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ class DiscoveryV2(BaseService):
4848
DEFAULT_SERVICE_NAME = 'discovery'
4949

5050
def __init__(
51-
self,
52-
version: str,
53-
authenticator: Authenticator = None,
54-
service_name: str = DEFAULT_SERVICE_NAME,
51+
self,
52+
version: str,
53+
authenticator: Authenticator = None,
54+
service_name: str = DEFAULT_SERVICE_NAME,
5555
) -> None:
5656
"""
5757
Construct a new client for the Discovery service.
@@ -1763,7 +1763,7 @@ class FileContentType(Enum):
17631763

17641764
class AnalyzedDocument():
17651765
"""
1766-
An object containing the converted document and any identifed enrichments.
1766+
An object containing the converted document and any identified enrichments.
17671767
17681768
:attr List[Notice] notices: (optional) Array of document results that match the
17691769
query.
@@ -2170,15 +2170,15 @@ class Completions():
21702170
"""
21712171
An object containing an array of autocompletion suggestions.
21722172
2173-
:attr List[str] completions: (optional) Array of autcomplete suggestion based on
2174-
the provided prefix.
2173+
:attr List[str] completions: (optional) Array of autocomplete suggestion based
2174+
on the provided prefix.
21752175
"""
21762176

21772177
def __init__(self, *, completions: List[str] = None) -> None:
21782178
"""
21792179
Initialize a Completions object.
21802180
2181-
:param List[str] completions: (optional) Array of autcomplete suggestion
2181+
:param List[str] completions: (optional) Array of autocomplete suggestion
21822182
based on the provided prefix.
21832183
"""
21842184
self.completions = completions
@@ -2759,9 +2759,9 @@ class DefaultQueryParams():
27592759
:attr DefaultQueryParamsSuggestedRefinements suggested_refinements: (optional)
27602760
Object containing suggested refinement settings.
27612761
:attr bool spelling_suggestions: (optional) When `true`, a spelling suggestions
2762-
for the query are retuned by default.
2762+
for the query are returned by default.
27632763
:attr bool highlight: (optional) When `true`, a highlights for the query are
2764-
retuned by default.
2764+
returned by default.
27652765
:attr int count: (optional) The number of document results returned by default.
27662766
:attr str sort: (optional) A comma separated list of document fields to sort
27672767
results by default.
@@ -2797,9 +2797,9 @@ def __init__(self,
27972797
:param DefaultQueryParamsSuggestedRefinements suggested_refinements:
27982798
(optional) Object containing suggested refinement settings.
27992799
:param bool spelling_suggestions: (optional) When `true`, a spelling
2800-
suggestions for the query are retuned by default.
2800+
suggestions for the query are returned by default.
28012801
:param bool highlight: (optional) When `true`, a highlights for the query
2802-
are retuned by default.
2802+
are returned by default.
28032803
:param int count: (optional) The number of document results returned by
28042804
default.
28052805
:param str sort: (optional) A comma separated list of document fields to
@@ -2918,8 +2918,8 @@ class DefaultQueryParamsPassages():
29182918
:attr bool enabled: (optional) When `true`, a passage search is performed by
29192919
default.
29202920
:attr int count: (optional) The number of passages to return.
2921-
:attr List[str] fields: (optional) An array of field names to perfom the passage
2922-
search on.
2921+
:attr List[str] fields: (optional) An array of field names to perform the
2922+
passage search on.
29232923
:attr int characters: (optional) The approximate number of characters that each
29242924
returned passage will contain.
29252925
:attr bool per_document: (optional) When `true` the number of passages that can
@@ -2943,7 +2943,7 @@ def __init__(self,
29432943
:param bool enabled: (optional) When `true`, a passage search is performed
29442944
by default.
29452945
:param int count: (optional) The number of passages to return.
2946-
:param List[str] fields: (optional) An array of field names to perfom the
2946+
:param List[str] fields: (optional) An array of field names to perform the
29472947
passage search on.
29482948
:param int characters: (optional) The approximate number of characters that
29492949
each returned passage will contain.
@@ -3035,7 +3035,7 @@ class DefaultQueryParamsSuggestedRefinements():
30353035
Object containing suggested refinement settings.
30363036
30373037
:attr bool enabled: (optional) When `true`, a suggested refinements for the
3038-
query are retuned by default.
3038+
query are returned by default.
30393039
:attr int count: (optional) The number of suggested refinements to return by
30403040
default.
30413041
"""
@@ -3045,7 +3045,7 @@ def __init__(self, *, enabled: bool = None, count: int = None) -> None:
30453045
Initialize a DefaultQueryParamsSuggestedRefinements object.
30463046
30473047
:param bool enabled: (optional) When `true`, a suggested refinements for
3048-
the query are retuned by default.
3048+
the query are returned by default.
30493049
:param int count: (optional) The number of suggested refinements to return
30503050
by default.
30513051
"""
@@ -3106,7 +3106,7 @@ class DefaultQueryParamsTableResults():
31063106
Default project query settings for table results.
31073107
31083108
:attr bool enabled: (optional) When `true`, a table results for the query are
3109-
retuned by default.
3109+
returned by default.
31103110
:attr int count: (optional) The number of table results to return by default.
31113111
:attr int per_document: (optional) The number of table results to include in
31123112
each result document.
@@ -3121,7 +3121,7 @@ def __init__(self,
31213121
Initialize a DefaultQueryParamsTableResults object.
31223122
31233123
:param bool enabled: (optional) When `true`, a table results for the query
3124-
are retuned by default.
3124+
are returned by default.
31253125
:param int count: (optional) The number of table results to return by
31263126
default.
31273127
:param int per_document: (optional) The number of table results to include
@@ -4413,14 +4413,14 @@ class ProjectListDetailsRelevancyTrainingStatus():
44134413
44144414
:attr str data_updated: (optional) When the training data was updated.
44154415
:attr int total_examples: (optional) The total number of examples.
4416-
:attr bool sufficient_label_diversity: (optional) When `true`, sufficent label
4416+
:attr bool sufficient_label_diversity: (optional) When `true`, sufficient label
44174417
diversity is present to allow training for this project.
44184418
:attr bool processing: (optional) When `true`, the relevancy training is in
44194419
processing.
44204420
:attr bool minimum_examples_added: (optional) When `true`, the minimum number of
44214421
examples required to train has been met.
44224422
:attr str successfully_trained: (optional) The time that the most recent
4423-
successful training occured.
4423+
successful training occurred.
44244424
:attr bool available: (optional) When `true`, relevancy training is available
44254425
when querying collections in the project.
44264426
:attr int notices: (optional) The number of notices generated during the
@@ -4445,14 +4445,14 @@ def __init__(self,
44454445
44464446
:param str data_updated: (optional) When the training data was updated.
44474447
:param int total_examples: (optional) The total number of examples.
4448-
:param bool sufficient_label_diversity: (optional) When `true`, sufficent
4448+
:param bool sufficient_label_diversity: (optional) When `true`, sufficient
44494449
label diversity is present to allow training for this project.
44504450
:param bool processing: (optional) When `true`, the relevancy training is
44514451
in processing.
44524452
:param bool minimum_examples_added: (optional) When `true`, the minimum
44534453
number of examples required to train has been met.
44544454
:param str successfully_trained: (optional) The time that the most recent
4455-
successful training occured.
4455+
successful training occurred.
44564456
:param bool available: (optional) When `true`, relevancy training is
44574457
available when querying collections in the project.
44584458
:param int notices: (optional) The number of notices generated during the
@@ -5237,6 +5237,8 @@ class QueryResponse():
52375237
:attr List[QuerySuggestedRefinement] suggested_refinements: (optional) Array of
52385238
suggested refinements.
52395239
:attr List[QueryTableResult] table_results: (optional) Array of table results.
5240+
:attr List[QueryResponsePassage] passages: (optional) Passages returned by
5241+
Discovery.
52405242
"""
52415243

52425244
def __init__(self,
@@ -5247,7 +5249,8 @@ def __init__(self,
52475249
retrieval_details: 'RetrievalDetails' = None,
52485250
suggested_query: str = None,
52495251
suggested_refinements: List['QuerySuggestedRefinement'] = None,
5250-
table_results: List['QueryTableResult'] = None) -> None:
5252+
table_results: List['QueryTableResult'] = None,
5253+
passages: List['QueryResponsePassage'] = None) -> None:
52515254
"""
52525255
Initialize a QueryResponse object.
52535256
@@ -5265,6 +5268,8 @@ def __init__(self,
52655268
Array of suggested refinements.
52665269
:param List[QueryTableResult] table_results: (optional) Array of table
52675270
results.
5271+
:param List[QueryResponsePassage] passages: (optional) Passages returned by
5272+
Discovery.
52685273
"""
52695274
self.matching_results = matching_results
52705275
self.results = results
@@ -5273,14 +5278,16 @@ def __init__(self,
52735278
self.suggested_query = suggested_query
52745279
self.suggested_refinements = suggested_refinements
52755280
self.table_results = table_results
5281+
self.passages = passages
52765282

52775283
@classmethod
52785284
def from_dict(cls, _dict: Dict) -> 'QueryResponse':
52795285
"""Initialize a QueryResponse object from a json dictionary."""
52805286
args = {}
52815287
valid_keys = [
52825288
'matching_results', 'results', 'aggregations', 'retrieval_details',
5283-
'suggested_query', 'suggested_refinements', 'table_results'
5289+
'suggested_query', 'suggested_refinements', 'table_results',
5290+
'passages'
52845291
]
52855292
bad_keys = set(_dict.keys()) - set(valid_keys)
52865293
if bad_keys:
@@ -5313,6 +5320,11 @@ def from_dict(cls, _dict: Dict) -> 'QueryResponse':
53135320
QueryTableResult._from_dict(x)
53145321
for x in (_dict.get('table_results'))
53155322
]
5323+
if 'passages' in _dict:
5324+
args['passages'] = [
5325+
QueryResponsePassage._from_dict(x)
5326+
for x in (_dict.get('passages'))
5327+
]
53165328
return cls(**args)
53175329

53185330
@classmethod
@@ -5343,6 +5355,8 @@ def to_dict(self) -> Dict:
53435355
]
53445356
if hasattr(self, 'table_results') and self.table_results is not None:
53455357
_dict['table_results'] = [x._to_dict() for x in self.table_results]
5358+
if hasattr(self, 'passages') and self.passages is not None:
5359+
_dict['passages'] = [x._to_dict() for x in self.passages]
53465360
return _dict
53475361

53485362
def _to_dict(self):
@@ -5364,6 +5378,130 @@ def __ne__(self, other: 'QueryResponse') -> bool:
53645378
return not self == other
53655379

53665380

5381+
class QueryResponsePassage():
5382+
"""
5383+
A passage query response.
5384+
5385+
:attr str passage_text: (optional) The content of the extracted passage.
5386+
:attr float passage_score: (optional) The confidence score of the passage's
5387+
analysis. A higher score indicates greater confidence.
5388+
:attr str document_id: (optional) The unique identifier of the ingested
5389+
document.
5390+
:attr str collection_id: (optional) The unique identifier of the collection.
5391+
:attr int start_offset: (optional) The position of the first character of the
5392+
extracted passage in the originating field.
5393+
:attr int end_offset: (optional) The position of the last character of the
5394+
extracted passage in the originating field.
5395+
:attr str field: (optional) The label of the field from which the passage has
5396+
been extracted.
5397+
"""
5398+
5399+
def __init__(self,
5400+
*,
5401+
passage_text: str = None,
5402+
passage_score: float = None,
5403+
document_id: str = None,
5404+
collection_id: str = None,
5405+
start_offset: int = None,
5406+
end_offset: int = None,
5407+
field: str = None) -> None:
5408+
"""
5409+
Initialize a QueryResponsePassage object.
5410+
5411+
:param str passage_text: (optional) The content of the extracted passage.
5412+
:param float passage_score: (optional) The confidence score of the
5413+
passage's analysis. A higher score indicates greater confidence.
5414+
:param str document_id: (optional) The unique identifier of the ingested
5415+
document.
5416+
:param str collection_id: (optional) The unique identifier of the
5417+
collection.
5418+
:param int start_offset: (optional) The position of the first character of
5419+
the extracted passage in the originating field.
5420+
:param int end_offset: (optional) The position of the last character of the
5421+
extracted passage in the originating field.
5422+
:param str field: (optional) The label of the field from which the passage
5423+
has been extracted.
5424+
"""
5425+
self.passage_text = passage_text
5426+
self.passage_score = passage_score
5427+
self.document_id = document_id
5428+
self.collection_id = collection_id
5429+
self.start_offset = start_offset
5430+
self.end_offset = end_offset
5431+
self.field = field
5432+
5433+
@classmethod
5434+
def from_dict(cls, _dict: Dict) -> 'QueryResponsePassage':
5435+
"""Initialize a QueryResponsePassage object from a json dictionary."""
5436+
args = {}
5437+
valid_keys = [
5438+
'passage_text', 'passage_score', 'document_id', 'collection_id',
5439+
'start_offset', 'end_offset', 'field'
5440+
]
5441+
bad_keys = set(_dict.keys()) - set(valid_keys)
5442+
if bad_keys:
5443+
raise ValueError(
5444+
'Unrecognized keys detected in dictionary for class QueryResponsePassage: '
5445+
+ ', '.join(bad_keys))
5446+
if 'passage_text' in _dict:
5447+
args['passage_text'] = _dict.get('passage_text')
5448+
if 'passage_score' in _dict:
5449+
args['passage_score'] = _dict.get('passage_score')
5450+
if 'document_id' in _dict:
5451+
args['document_id'] = _dict.get('document_id')
5452+
if 'collection_id' in _dict:
5453+
args['collection_id'] = _dict.get('collection_id')
5454+
if 'start_offset' in _dict:
5455+
args['start_offset'] = _dict.get('start_offset')
5456+
if 'end_offset' in _dict:
5457+
args['end_offset'] = _dict.get('end_offset')
5458+
if 'field' in _dict:
5459+
args['field'] = _dict.get('field')
5460+
return cls(**args)
5461+
5462+
@classmethod
5463+
def _from_dict(cls, _dict):
5464+
"""Initialize a QueryResponsePassage object from a json dictionary."""
5465+
return cls.from_dict(_dict)
5466+
5467+
def to_dict(self) -> Dict:
5468+
"""Return a json dictionary representing this model."""
5469+
_dict = {}
5470+
if hasattr(self, 'passage_text') and self.passage_text is not None:
5471+
_dict['passage_text'] = self.passage_text
5472+
if hasattr(self, 'passage_score') and self.passage_score is not None:
5473+
_dict['passage_score'] = self.passage_score
5474+
if hasattr(self, 'document_id') and self.document_id is not None:
5475+
_dict['document_id'] = self.document_id
5476+
if hasattr(self, 'collection_id') and self.collection_id is not None:
5477+
_dict['collection_id'] = self.collection_id
5478+
if hasattr(self, 'start_offset') and self.start_offset is not None:
5479+
_dict['start_offset'] = self.start_offset
5480+
if hasattr(self, 'end_offset') and self.end_offset is not None:
5481+
_dict['end_offset'] = self.end_offset
5482+
if hasattr(self, 'field') and self.field is not None:
5483+
_dict['field'] = self.field
5484+
return _dict
5485+
5486+
def _to_dict(self):
5487+
"""Return a json dictionary representing this model."""
5488+
return self.to_dict()
5489+
5490+
def __str__(self) -> str:
5491+
"""Return a `str` version of this QueryResponsePassage object."""
5492+
return json.dumps(self._to_dict(), indent=2)
5493+
5494+
def __eq__(self, other: 'QueryResponsePassage') -> bool:
5495+
"""Return `true` when self and other are equal, false otherwise."""
5496+
if not isinstance(other, self.__class__):
5497+
return False
5498+
return self.__dict__ == other.__dict__
5499+
5500+
def __ne__(self, other: 'QueryResponsePassage') -> bool:
5501+
"""Return `true` when self and other are not equal, false otherwise."""
5502+
return not self == other
5503+
5504+
53675505
class QueryResult():
53685506
"""
53695507
Result document for the specified query.

ibm_watson/natural_language_understanding_v1.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ class NaturalLanguageUnderstandingV1(BaseService):
4848
DEFAULT_SERVICE_NAME = 'natural-language-understanding'
4949

5050
def __init__(
51-
self,
52-
version: str,
53-
authenticator: Authenticator = None,
54-
service_name: str = DEFAULT_SERVICE_NAME,
51+
self,
52+
version: str,
53+
authenticator: Authenticator = None,
54+
service_name: str = DEFAULT_SERVICE_NAME,
5555
) -> None:
5656
"""
5757
Construct a new client for the Natural Language Understanding service.
@@ -110,7 +110,8 @@ def analyze(self,
110110
- Relations
111111
- Semantic roles
112112
- Sentiment
113-
- Syntax.
113+
- Syntax
114+
- Summarization (Experimental)
114115
If a language for the input text is not specified with the `language` parameter,
115116
the service [automatically detects the
116117
language](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-detectable-languages).
@@ -2701,8 +2702,7 @@ class Model():
27012702
that deployed this model to Natural Language Understanding.
27022703
:attr str model_version: (optional) The model version, if it was manually
27032704
provided in Watson Knowledge Studio.
2704-
:attr str version: (optional) (Deprecated — use `model_version`) The model
2705-
version, if it was manually provided in Watson Knowledge Studio.
2705+
:attr str version: (optional) Deprecated — use `model_version`.
27062706
:attr str version_description: (optional) The description of the version, if it
27072707
was manually provided in Watson Knowledge Studio.
27082708
:attr datetime created: (optional) A dateTime indicating when the model was
@@ -2733,8 +2733,7 @@ def __init__(self,
27332733
workspace that deployed this model to Natural Language Understanding.
27342734
:param str model_version: (optional) The model version, if it was manually
27352735
provided in Watson Knowledge Studio.
2736-
:param str version: (optional) (Deprecated — use `model_version`) The model
2737-
version, if it was manually provided in Watson Knowledge Studio.
2736+
:param str version: (optional) Deprecated — use `model_version`.
27382737
:param str version_description: (optional) The description of the version,
27392738
if it was manually provided in Watson Knowledge Studio.
27402739
:param datetime created: (optional) A dateTime indicating when the model

0 commit comments

Comments
 (0)