File tree Expand file tree Collapse file tree 2 files changed +6
-7
lines changed
language/snippets/sentiment Expand file tree Collapse file tree 2 files changed +6
-7
lines changed Original file line number Diff line number Diff line change 1111# See the License for the specific language governing permissions and
1212# limitations under the License.
1313
14- ''' Demonstrates how to make a simple call to the Natural Language API'''
14+ """ Demonstrates how to make a simple call to the Natural Language API."""
1515
1616import argparse
17+
1718from googleapiclient import discovery
1819from oauth2client .client import GoogleCredentials
1920
2021
2122def main (movie_review_filename ):
22- ''' Run a sentiment analysis request on text within a passed filename.'''
23+ """ Run a sentiment analysis request on text within a passed filename."""
2324
2425 credentials = GoogleCredentials .get_application_default ()
2526 service = discovery .build ('language' , 'v1' , credentials = credentials )
@@ -41,13 +42,10 @@ def main(movie_review_filename):
4142 for i , sentence in enumerate (response ['sentences' ]):
4243 sentence_sentiment = sentence ['sentiment' ]['score' ]
4344 print ('Sentence {} has a sentiment score of {}' .format (
44- i ,
45- sentence_sentiment ))
45+ i , sentence_sentiment ))
4646
4747 print ('Overall Sentiment: score of {} with magnitude of {}' .format (
48- score ,
49- magnitude )
50- )
48+ score , magnitude ))
5149 return 0
5250
5351 print ('Sentiment: score of {} with magnitude of {}' .format (
Original file line number Diff line number Diff line change 1212# limitations under the License.
1313
1414import re
15+
1516from sentiment_analysis import main
1617
1718
You can’t perform that action at this time.
0 commit comments