Skip to content

Commit 334b1cb

Browse files
committed
fix(discovery): sentence_location renamed to sentence_locations in NluEnrichmentEmotion
* New model NluEnrichmentConcepts
1 parent ab9d5bd commit 334b1cb

File tree

1 file changed

+92
-26
lines changed

1 file changed

+92
-26
lines changed

watson_developer_cloud/discovery_v1.py

Lines changed: 92 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6760,6 +6760,53 @@ def __ne__(self, other):
67606760
return not self == other
67616761

67626762

6763+
class NluEnrichmentConcepts(object):
6764+
"""
6765+
An object specifiying the concepts enrichment and related parameters.
6766+
6767+
:attr int limit: (optional) The maximum number of concepts enrichments to extact from
6768+
each instance of the specified field.
6769+
"""
6770+
6771+
def __init__(self, limit=None):
6772+
"""
6773+
Initialize a NluEnrichmentConcepts object.
6774+
6775+
:param int limit: (optional) The maximum number of concepts enrichments to extact
6776+
from each instance of the specified field.
6777+
"""
6778+
self.limit = limit
6779+
6780+
@classmethod
6781+
def _from_dict(cls, _dict):
6782+
"""Initialize a NluEnrichmentConcepts object from a json dictionary."""
6783+
args = {}
6784+
if 'limit' in _dict:
6785+
args['limit'] = _dict.get('limit')
6786+
return cls(**args)
6787+
6788+
def _to_dict(self):
6789+
"""Return a json dictionary representing this model."""
6790+
_dict = {}
6791+
if hasattr(self, 'limit') and self.limit is not None:
6792+
_dict['limit'] = self.limit
6793+
return _dict
6794+
6795+
def __str__(self):
6796+
"""Return a `str` version of this NluEnrichmentConcepts object."""
6797+
return json.dumps(self._to_dict(), indent=2)
6798+
6799+
def __eq__(self, other):
6800+
"""Return `true` when self and other are equal, false otherwise."""
6801+
if not isinstance(other, self.__class__):
6802+
return False
6803+
return self.__dict__ == other.__dict__
6804+
6805+
def __ne__(self, other):
6806+
"""Return `true` when self and other are not equal, false otherwise."""
6807+
return not self == other
6808+
6809+
67636810
class NluEnrichmentEmotion(object):
67646811
"""
67656812
An object specifying the emotion detection enrichment and related parameters.
@@ -6830,8 +6877,8 @@ class NluEnrichmentEntities(object):
68306877
entity is recorded. The default is `false`.
68316878
:attr bool mention_types: (optional) When `true`, the types of mentions for each
68326879
idetifieid entity is recorded. The default is `false`.
6833-
:attr bool sentence_location: (optional) When `true`, a list of sentence locations for
6834-
each instance of each identified entity is recorded. The default is `false`.
6880+
:attr bool sentence_locations: (optional) When `true`, a list of sentence locations
6881+
for each instance of each identified entity is recorded. The default is `false`.
68356882
:attr str model: (optional) The enrichement model to use with entity extraction. May
68366883
be a custom model provided by Watson Knowledge Studio, the public model for use with
68376884
Knowledge Graph `en-news`, or the default public model `alchemy`.
@@ -6843,7 +6890,7 @@ def __init__(self,
68436890
limit=None,
68446891
mentions=None,
68456892
mention_types=None,
6846-
sentence_location=None,
6893+
sentence_locations=None,
68476894
model=None):
68486895
"""
68496896
Initialize a NluEnrichmentEntities object.
@@ -6858,7 +6905,7 @@ def __init__(self,
68586905
identified entity is recorded. The default is `false`.
68596906
:param bool mention_types: (optional) When `true`, the types of mentions for each
68606907
idetifieid entity is recorded. The default is `false`.
6861-
:param bool sentence_location: (optional) When `true`, a list of sentence
6908+
:param bool sentence_locations: (optional) When `true`, a list of sentence
68626909
locations for each instance of each identified entity is recorded. The default is
68636910
`false`.
68646911
:param str model: (optional) The enrichement model to use with entity extraction.
@@ -6870,7 +6917,7 @@ def __init__(self,
68706917
self.limit = limit
68716918
self.mentions = mentions
68726919
self.mention_types = mention_types
6873-
self.sentence_location = sentence_location
6920+
self.sentence_locations = sentence_locations
68746921
self.model = model
68756922

68766923
@classmethod
@@ -6887,8 +6934,8 @@ def _from_dict(cls, _dict):
68876934
args['mentions'] = _dict.get('mentions')
68886935
if 'mention_types' in _dict:
68896936
args['mention_types'] = _dict.get('mention_types')
6890-
if 'sentence_location' in _dict:
6891-
args['sentence_location'] = _dict.get('sentence_location')
6937+
if 'sentence_locations' in _dict:
6938+
args['sentence_locations'] = _dict.get('sentence_locations')
68926939
if 'model' in _dict:
68936940
args['model'] = _dict.get('model')
68946941
return cls(**args)
@@ -6906,9 +6953,10 @@ def _to_dict(self):
69066953
_dict['mentions'] = self.mentions
69076954
if hasattr(self, 'mention_types') and self.mention_types is not None:
69086955
_dict['mention_types'] = self.mention_types
6909-
if hasattr(self,
6910-
'sentence_location') and self.sentence_location is not None:
6911-
_dict['sentence_location'] = self.sentence_location
6956+
if hasattr(
6957+
self,
6958+
'sentence_locations') and self.sentence_locations is not None:
6959+
_dict['sentence_locations'] = self.sentence_locations
69126960
if hasattr(self, 'model') and self.model is not None:
69136961
_dict['model'] = self.model
69146962
return _dict
@@ -6946,6 +6994,8 @@ class NluEnrichmentFeatures(object):
69466994
semantic roles enrichment and related parameters.
69476995
:attr NluEnrichmentRelations relations: (optional) An object specifying the relations
69486996
enrichment and related parameters.
6997+
:attr NluEnrichmentConcepts concepts: (optional) An object specifiying the concepts
6998+
enrichment and related parameters.
69496999
"""
69507000

69517001
def __init__(self,
@@ -6955,7 +7005,8 @@ def __init__(self,
69557005
emotion=None,
69567006
categories=None,
69577007
semantic_roles=None,
6958-
relations=None):
7008+
relations=None,
7009+
concepts=None):
69597010
"""
69607011
Initialize a NluEnrichmentFeatures object.
69617012
@@ -6973,6 +7024,8 @@ def __init__(self,
69737024
the semantic roles enrichment and related parameters.
69747025
:param NluEnrichmentRelations relations: (optional) An object specifying the
69757026
relations enrichment and related parameters.
7027+
:param NluEnrichmentConcepts concepts: (optional) An object specifiying the
7028+
concepts enrichment and related parameters.
69767029
"""
69777030
self.keywords = keywords
69787031
self.entities = entities
@@ -6981,6 +7034,7 @@ def __init__(self,
69817034
self.categories = categories
69827035
self.semantic_roles = semantic_roles
69837036
self.relations = relations
7037+
self.concepts = concepts
69847038

69857039
@classmethod
69867040
def _from_dict(cls, _dict):
@@ -7007,6 +7061,9 @@ def _from_dict(cls, _dict):
70077061
if 'relations' in _dict:
70087062
args['relations'] = NluEnrichmentRelations._from_dict(
70097063
_dict.get('relations'))
7064+
if 'concepts' in _dict:
7065+
args['concepts'] = NluEnrichmentConcepts._from_dict(
7066+
_dict.get('concepts'))
70107067
return cls(**args)
70117068

70127069
def _to_dict(self):
@@ -7026,6 +7083,8 @@ def _to_dict(self):
70267083
_dict['semantic_roles'] = self.semantic_roles._to_dict()
70277084
if hasattr(self, 'relations') and self.relations is not None:
70287085
_dict['relations'] = self.relations._to_dict()
7086+
if hasattr(self, 'concepts') and self.concepts is not None:
7087+
_dict['concepts'] = self.concepts._to_dict()
70297088
return _dict
70307089

70317090
def __str__(self):
@@ -9773,30 +9832,26 @@ class TokenDictRule(object):
97739832
"""
97749833
An object defining a single tokenizaion rule.
97759834
9776-
:attr str text: (optional) The string to tokenize.
9777-
:attr list[str] tokens: (optional) Array of tokens that the `text` field is split into
9778-
when found.
9835+
:attr str text: The string to tokenize.
9836+
:attr list[str] tokens: Array of tokens that the `text` field is split into when
9837+
found.
97799838
:attr list[str] readings: (optional) Array of tokens that represent the content of the
97809839
`text` field in an alternate character set.
9781-
:attr str part_of_speech: (optional) The part of speech that the `text` string belongs
9782-
to. For example `noun`. Custom parts of speech can be specified.
9840+
:attr str part_of_speech: The part of speech that the `text` string belongs to. For
9841+
example `noun`. Custom parts of speech can be specified.
97839842
"""
97849843

9785-
def __init__(self,
9786-
text=None,
9787-
tokens=None,
9788-
readings=None,
9789-
part_of_speech=None):
9844+
def __init__(self, text, tokens, part_of_speech, readings=None):
97909845
"""
97919846
Initialize a TokenDictRule object.
97929847
9793-
:param str text: (optional) The string to tokenize.
9794-
:param list[str] tokens: (optional) Array of tokens that the `text` field is split
9795-
into when found.
9848+
:param str text: The string to tokenize.
9849+
:param list[str] tokens: Array of tokens that the `text` field is split into when
9850+
found.
9851+
:param str part_of_speech: The part of speech that the `text` string belongs to.
9852+
For example `noun`. Custom parts of speech can be specified.
97969853
:param list[str] readings: (optional) Array of tokens that represent the content
97979854
of the `text` field in an alternate character set.
9798-
:param str part_of_speech: (optional) The part of speech that the `text` string
9799-
belongs to. For example `noun`. Custom parts of speech can be specified.
98009855
"""
98019856
self.text = text
98029857
self.tokens = tokens
@@ -9809,12 +9864,23 @@ def _from_dict(cls, _dict):
98099864
args = {}
98109865
if 'text' in _dict:
98119866
args['text'] = _dict.get('text')
9867+
else:
9868+
raise ValueError(
9869+
'Required property \'text\' not present in TokenDictRule JSON')
98129870
if 'tokens' in _dict:
98139871
args['tokens'] = _dict.get('tokens')
9872+
else:
9873+
raise ValueError(
9874+
'Required property \'tokens\' not present in TokenDictRule JSON'
9875+
)
98149876
if 'readings' in _dict:
98159877
args['readings'] = _dict.get('readings')
98169878
if 'part_of_speech' in _dict:
98179879
args['part_of_speech'] = _dict.get('part_of_speech')
9880+
else:
9881+
raise ValueError(
9882+
'Required property \'part_of_speech\' not present in TokenDictRule JSON'
9883+
)
98189884
return cls(**args)
98199885

98209886
def _to_dict(self):

0 commit comments

Comments
 (0)