Skip to content

Commit f34e0a8

Browse files
committed
Address comments.
1 parent 4219e3e commit f34e0a8

File tree

3 files changed

+1
-49
lines changed

3 files changed

+1
-49
lines changed

language/google/cloud/language/document.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def analyze_syntax(self):
207207
api_response = self.client._connection.api_request(
208208
method='POST', path='analyzeSyntax', data=data)
209209
return [Token.from_api_repr(token)
210-
for token in api_response['tokens']]
210+
for token in api_response.get('tokens', ())]
211211

212212
def annotate_text(self, include_syntax=True, include_entities=True,
213213
include_sentiment=True):

language/unit_tests/test_document.py

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,6 @@ def test_analyze_sentiment(self):
317317

318318
def _verify_token(self, token, text_content, part_of_speech, lemma):
319319
from google.cloud.language.syntax import Token
320-
from google.cloud.language.syntax import PartOfSpeech
321320

322321
self.assertIsInstance(token, Token)
323322
self.assertEqual(token.text_content, text_content)
@@ -326,7 +325,6 @@ def _verify_token(self, token, text_content, part_of_speech, lemma):
326325

327326
def test_analyze_syntax(self):
328327
from google.cloud.language.document import Encoding
329-
from google.cloud.language.syntax import Token
330328
from google.cloud.language.syntax import PartOfSpeech
331329

332330
name1 = 'R-O-C-K'
@@ -350,17 +348,6 @@ def test_analyze_syntax(self):
350348
},
351349
'partOfSpeech': {
352350
'tag': 'NOUN',
353-
'aspect': 'ASPECT_UNKNOWN',
354-
'case': 'CASE_UNKNOWN',
355-
'form': 'FORM_UNKNOWN',
356-
'gender': 'GENDER_UNKNOWN',
357-
'mood': 'MOOD_UNKNOWN',
358-
'number': 'SINGULAR',
359-
'person': 'PERSON_UNKNOWN',
360-
'proper': 'PROPER',
361-
'reciprocity': 'RECIPROCITY_UNKNOWN',
362-
'tense': 'TENSE_UNKNOWN',
363-
'voice': 'VOICE_UNKNOWN',
364351
},
365352
'dependencyEdge': {
366353
'headTokenIndex': 0,
@@ -375,17 +362,6 @@ def test_analyze_syntax(self):
375362
},
376363
'partOfSpeech': {
377364
'tag': 'ADP',
378-
'aspect': 'ASPECT_UNKNOWN',
379-
'case': 'CASE_UNKNOWN',
380-
'form': 'FORM_UNKNOWN',
381-
'gender': 'GENDER_UNKNOWN',
382-
'mood': 'MOOD_UNKNOWN',
383-
'number': 'NUMBER_UNKNOWN',
384-
'person': 'PERSON_UNKNOWN',
385-
'proper': 'PROPER_UNKNOWN',
386-
'reciprocity': 'RECIPROCITY_UNKNOWN',
387-
'tense': 'TENSE_UNKNOWN',
388-
'voice': 'VOICE_UNKNOWN',
389365
},
390366
'dependencyEdge': {
391367
'headTokenIndex': 0,
@@ -400,17 +376,6 @@ def test_analyze_syntax(self):
400376
},
401377
'partOfSpeech': {
402378
'tag': 'DET',
403-
'aspect': 'ASPECT_UNKNOWN',
404-
'case': 'CASE_UNKNOWN',
405-
'form': 'FORM_UNKNOWN',
406-
'gender': 'GENDER_UNKNOWN',
407-
'mood': 'MOOD_UNKNOWN',
408-
'number': 'NUMBER_UNKNOWN',
409-
'person': 'PERSON_UNKNOWN',
410-
'proper': 'PROPER_UNKNOWN',
411-
'reciprocity': 'RECIPROCITY_UNKNOWN',
412-
'tense': 'TENSE_UNKNOWN',
413-
'voice': 'VOICE_UNKNOWN',
414379
},
415380
'dependencyEdge': {
416381
'headTokenIndex': 3,
@@ -425,17 +390,6 @@ def test_analyze_syntax(self):
425390
},
426391
'partOfSpeech': {
427392
'tag': 'NOUN',
428-
'aspect': 'ASPECT_UNKNOWN',
429-
'case': 'CASE_UNKNOWN',
430-
'form': 'FORM_UNKNOWN',
431-
'gender': 'GENDER_UNKNOWN',
432-
'mood': 'MOOD_UNKNOWN',
433-
'number': 'SINGULAR',
434-
'person': 'PERSON_UNKNOWN',
435-
'proper': 'PROPER',
436-
'reciprocity': 'RECIPROCITY_UNKNOWN',
437-
'tense': 'TENSE_UNKNOWN',
438-
'voice': 'VOICE_UNKNOWN',
439393
},
440394
'dependencyEdge': {
441395
'headTokenIndex': 1,

system_tests/language.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,15 +126,13 @@ def test_analyze_sentiment(self):
126126

127127
def _verify_token(self, token, text_content, part_of_speech, lemma):
128128
from google.cloud.language.syntax import Token
129-
from google.cloud.language.syntax import PartOfSpeech
130129

131130
self.assertIsInstance(token, Token)
132131
self.assertEqual(token.text_content, text_content)
133132
self.assertEqual(token.part_of_speech, part_of_speech)
134133
self.assertEqual(token.lemma, lemma)
135134

136135
def _check_analyze_syntax_result(self, tokens):
137-
from google.cloud.language.syntax import Token
138136
from google.cloud.language.syntax import PartOfSpeech
139137

140138
self.assertEqual(len(tokens), 3)

0 commit comments

Comments
 (0)