@@ -28,6 +28,10 @@ class EntityAnnotation(object):
2828 :type description: str
2929 :param description: Description of entity detected in an image.
3030
31+ :type locale: str
32+ :param locale: The language code for the locale in which the entity textual
33+ description (next field) is expressed.
34+
3135 :type locations: list of
3236 :class:`~google.cloud.vision.geometry.LocationInformation`.
3337 :param locations: List of ``LocationInformation`` instances.
@@ -38,9 +42,10 @@ class EntityAnnotation(object):
3842 :type score: float
3943 :param score: Overall score of the result. Range [0, 1].
4044 """
41- def __init__ (self , bounds , description , locations , mid , score ):
45+ def __init__ (self , bounds , description , locale , locations , mid , score ):
4246 self ._bounds = bounds
4347 self ._description = description
48+ self ._locale = locale
4449 self ._locations = locations
4550 self ._mid = mid
4651 self ._score = score
@@ -52,19 +57,21 @@ def from_api_repr(cls, response):
5257 :type response: dict
5358 :param response: Dictionary response from Vision API with entity data.
5459
55- :rtype: :class:`~google.cloud.vision.entiy .EntityAnnotation`
60+ :rtype: :class:`~google.cloud.vision.entity .EntityAnnotation`
5661 :returns: Instance of ``EntityAnnotation``.
5762 """
5863 bounds = []
5964 if 'boundingPoly' in response :
6065 bounds = Bounds .from_api_repr (response ['boundingPoly' ])
6166 description = response ['description' ]
67+
68+ locale = response .get ('locale' , None )
6269 locations = [LocationInformation .from_api_repr (location )
6370 for location in response .get ('locations' , [])]
64- mid = response [ 'mid' ]
65- score = response [ 'score' ]
71+ mid = response . get ( 'mid' , None )
72+ score = response . get ( 'score' , None )
6673
67- return cls (bounds , description , locations , mid , score )
74+ return cls (bounds , description , locale , locations , mid , score )
6875
6976 @property
7077 def bounds (self ):
@@ -84,6 +91,15 @@ def description(self):
8491 """
8592 return self ._description
8693
94+ @property
95+ def locale (self ):
96+ """The language code for text discovered in an image.
97+
98+ :rtype: str
99+ :returns: String language code of text found in the image.
100+ """
101+ return self ._locale
102+
87103 @property
88104 def locations (self ):
89105 """Location coordinates landmarks detected.
0 commit comments