@@ -35,7 +35,7 @@ def sentiment_text(text):
3535
3636 # Detects sentiment in the document. You can also analyze HTML with:
3737 # document.doc_type == language.Document.HTML
38- sentiment = document .analyze_sentiment ()
38+ sentiment = document .analyze_sentiment (). sentiment
3939
4040 print ('Score: {}' .format (sentiment .score ))
4141 print ('Magnitude: {}' .format (sentiment .magnitude ))
@@ -50,7 +50,7 @@ def sentiment_file(gcs_uri):
5050
5151 # Detects sentiment in the document. You can also analyze HTML with:
5252 # document.doc_type == language.Document.HTML
53- sentiment = document .analyze_sentiment ()
53+ sentiment = document .analyze_sentiment (). sentiment
5454
5555 print ('Score: {}' .format (sentiment .score ))
5656 print ('Magnitude: {}' .format (sentiment .magnitude ))
@@ -65,15 +65,16 @@ def entities_text(text):
6565
6666 # Detects entities in the document. You can also analyze HTML with:
6767 # document.doc_type == language.Document.HTML
68- entities = document .analyze_entities ()
68+ entities = document .analyze_entities (). entities
6969
7070 for entity in entities :
7171 print ('=' * 20 )
7272 print ('{:<16}: {}' .format ('name' , entity .name ))
7373 print ('{:<16}: {}' .format ('type' , entity .entity_type ))
74- print ('{:<16}: {}' .format ('wikipedia_url' , entity .wikipedia_url ))
7574 print ('{:<16}: {}' .format ('metadata' , entity .metadata ))
7675 print ('{:<16}: {}' .format ('salience' , entity .salience ))
76+ print ('{:<16}: {}' .format ('wikipedia_url' ,
77+ entity .metadata .get ('wikipedia_url' , '-' )))
7778
7879
7980def entities_file (gcs_uri ):
@@ -85,15 +86,16 @@ def entities_file(gcs_uri):
8586
8687 # Detects sentiment in the document. You can also analyze HTML with:
8788 # document.doc_type == language.Document.HTML
88- entities = document .analyze_entities ()
89+ entities = document .analyze_entities (). entities
8990
9091 for entity in entities :
9192 print ('=' * 20 )
9293 print ('{:<16}: {}' .format ('name' , entity .name ))
9394 print ('{:<16}: {}' .format ('type' , entity .entity_type ))
94- print ('{:<16}: {}' .format ('wikipedia_url' , entity .wikipedia_url ))
9595 print ('{:<16}: {}' .format ('metadata' , entity .metadata ))
9696 print ('{:<16}: {}' .format ('salience' , entity .salience ))
97+ print ('{:<16}: {}' .format ('wikipedia_url' ,
98+ entity .metadata .get ('wikipedia_url' , '-' )))
9799
98100
99101def syntax_text (text ):
@@ -105,7 +107,7 @@ def syntax_text(text):
105107
106108 # Detects syntax in the document. You can also analyze HTML with:
107109 # document.doc_type == language.Document.HTML
108- tokens = document .analyze_syntax ()
110+ tokens = document .analyze_syntax (). tokens
109111
110112 for token in tokens :
111113 print ('{}: {}' .format (token .part_of_speech , token .text_content ))
@@ -120,7 +122,7 @@ def syntax_file(gcs_uri):
120122
121123 # Detects syntax in the document. You can also analyze HTML with:
122124 # document.doc_type == language.Document.HTML
123- tokens = document .analyze_syntax ()
125+ tokens = document .analyze_syntax (). tokens
124126
125127 for token in tokens :
126128 print ('{}: {}' .format (token .part_of_speech , token .text_content ))
0 commit comments