Skip to content

Commit 89e0c97

Browse files
dhermeslandrito
authored andcommitted
Using HTTPS wikipedia links in language system tests. (googleapis#3732)
Fixes googleapis#3731. Also relaxing the sentiment score expected range for "Jogging is fun" (the same backend update that changed HTTP to HTTPS changed the score from 0.5 to 0.7). Also updating the language usage doc with the correct (and HTTPS) URLs for the 3 examples.
1 parent 1ca1962 commit 89e0c97

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

docs/language/usage.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,17 +144,17 @@ returns a :class:`~.language_v1.types.AnalyzeEntitiesResponse`.
144144
====================
145145
name: Michelangelo Caravaggio
146146
type: PERSON
147-
metadata: {'wikipedia_url': 'http://en.wikipedia.org/wiki/Caravaggio'}
147+
metadata: {'wikipedia_url': 'https://en.wikipedia.org/wiki/Caravaggio'}
148148
salience: 0.7615959
149149
====================
150150
name: Italian
151151
type: LOCATION
152-
metadata: {'wikipedia_url': 'http://en.wikipedia.org/wiki/Caravaggio'}
152+
metadata: {'wikipedia_url': 'https://en.wikipedia.org/wiki/Italy'}
153153
salience: 0.19960518
154154
====================
155155
name: The Calling of Saint Matthew
156156
type: EVENT
157-
metadata: {'wikipedia_url': 'http://en.wikipedia.org/wiki/Caravaggio'}
157+
metadata: {'wikipedia_url': 'https://en.wikipedia.org/wiki/The_Calling_of_St_Matthew_(Caravaggio)'}
158158
salience: 0.038798928
159159
160160
.. note::

language/tests/system.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,23 +77,23 @@ def _check_analyze_entities_result(self, entities):
7777
# Other mentions may occur, e.g. "painter".
7878
self.assertIn(entity1.name, [str(i) for i in entity1.mentions])
7979
self.assertEqual(entity1.metadata['wikipedia_url'],
80-
'http://en.wikipedia.org/wiki/Caravaggio')
80+
'https://en.wikipedia.org/wiki/Caravaggio')
8181
self.assertIsInstance(entity1.metadata, dict)
8282
# Verify entity 2.
8383
self.assertEqual(entity2.name, self.NAME2)
8484
self.assertEqual(entity2.entity_type, EntityType.LOCATION)
8585
self.assertGreater(entity2.salience, 0.0)
8686
self.assertEqual([str(i) for i in entity2.mentions], [entity2.name])
8787
self.assertEqual(entity2.metadata['wikipedia_url'],
88-
'http://en.wikipedia.org/wiki/Italy')
88+
'https://en.wikipedia.org/wiki/Italy')
8989
self.assertIsInstance(entity2.metadata, dict)
9090
# Verify entity 3.
9191
self.assertEqual(entity3.name, self.NAME3)
9292
choices = (EntityType.EVENT, EntityType.WORK_OF_ART)
9393
self.assertIn(entity3.entity_type, choices)
9494
self.assertGreater(entity3.salience, 0.0)
9595
self.assertEqual([str(i) for i in entity3.mentions], [entity3.name])
96-
wiki_url = ('http://en.wikipedia.org/wiki/'
96+
wiki_url = ('https://en.wikipedia.org/wiki/'
9797
'The_Calling_of_St_Matthew_(Caravaggio)')
9898
self.assertEqual(entity3.metadata['wikipedia_url'], wiki_url)
9999
self.assertIsInstance(entity3.metadata, dict)
@@ -122,7 +122,7 @@ def test_analyze_sentiment(self):
122122
positive_msg = 'Jogging is fun'
123123
document = Config.CLIENT.document_from_text(positive_msg)
124124
sentiment = document.analyze_sentiment().sentiment
125-
self.assertEqual(sentiment.score, 0.5)
125+
self.assertTrue(0.0 < sentiment.score < 1.0)
126126
self.assertTrue(0.0 < sentiment.magnitude < 1.5)
127127

128128
def _verify_token(self, token, text_content, part_of_speech, lemma):

0 commit comments

Comments
 (0)