Skip to content

Commit

Permalink
Using HTTPS wikipedia links in language system tests. (googleapis#3732)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dhermes authored and landrito committed Aug 21, 2017
1 parent 1ca1962 commit 89e0c97
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions docs/language/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -144,17 +144,17 @@ returns a :class:`~.language_v1.types.AnalyzeEntitiesResponse`.
====================
name: Michelangelo Caravaggio
type: PERSON
metadata: {'wikipedia_url': 'http://en.wikipedia.org/wiki/Caravaggio'}
metadata: {'wikipedia_url': 'https://en.wikipedia.org/wiki/Caravaggio'}
salience: 0.7615959
====================
name: Italian
type: LOCATION
metadata: {'wikipedia_url': 'http://en.wikipedia.org/wiki/Caravaggio'}
metadata: {'wikipedia_url': 'https://en.wikipedia.org/wiki/Italy'}
salience: 0.19960518
====================
name: The Calling of Saint Matthew
type: EVENT
metadata: {'wikipedia_url': 'http://en.wikipedia.org/wiki/Caravaggio'}
metadata: {'wikipedia_url': 'https://en.wikipedia.org/wiki/The_Calling_of_St_Matthew_(Caravaggio)'}
salience: 0.038798928
.. note::
Expand Down
8 changes: 4 additions & 4 deletions language/tests/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,23 +77,23 @@ def _check_analyze_entities_result(self, entities):
# Other mentions may occur, e.g. "painter".
self.assertIn(entity1.name, [str(i) for i in entity1.mentions])
self.assertEqual(entity1.metadata['wikipedia_url'],
'http://en.wikipedia.org/wiki/Caravaggio')
'https://en.wikipedia.org/wiki/Caravaggio')
self.assertIsInstance(entity1.metadata, dict)
# Verify entity 2.
self.assertEqual(entity2.name, self.NAME2)
self.assertEqual(entity2.entity_type, EntityType.LOCATION)
self.assertGreater(entity2.salience, 0.0)
self.assertEqual([str(i) for i in entity2.mentions], [entity2.name])
self.assertEqual(entity2.metadata['wikipedia_url'],
'http://en.wikipedia.org/wiki/Italy')
'https://en.wikipedia.org/wiki/Italy')
self.assertIsInstance(entity2.metadata, dict)
# Verify entity 3.
self.assertEqual(entity3.name, self.NAME3)
choices = (EntityType.EVENT, EntityType.WORK_OF_ART)
self.assertIn(entity3.entity_type, choices)
self.assertGreater(entity3.salience, 0.0)
self.assertEqual([str(i) for i in entity3.mentions], [entity3.name])
wiki_url = ('http://en.wikipedia.org/wiki/'
wiki_url = ('https://en.wikipedia.org/wiki/'
'The_Calling_of_St_Matthew_(Caravaggio)')
self.assertEqual(entity3.metadata['wikipedia_url'], wiki_url)
self.assertIsInstance(entity3.metadata, dict)
Expand Down Expand Up @@ -122,7 +122,7 @@ def test_analyze_sentiment(self):
positive_msg = 'Jogging is fun'
document = Config.CLIENT.document_from_text(positive_msg)
sentiment = document.analyze_sentiment().sentiment
self.assertEqual(sentiment.score, 0.5)
self.assertTrue(0.0 < sentiment.score < 1.0)
self.assertTrue(0.0 < sentiment.magnitude < 1.5)

def _verify_token(self, token, text_content, part_of_speech, lemma):
Expand Down

0 comments on commit 89e0c97

Please sign in to comment.