This repository was archived by the owner on Sep 5, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +6
-7
lines changed
samples/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 11
11
# See the License for the specific language governing permissions and
12
12
# limitations under the License.
13
13
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."""
15
15
16
16
import argparse
17
+
17
18
from googleapiclient import discovery
18
19
from oauth2client .client import GoogleCredentials
19
20
20
21
21
22
def 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."""
23
24
24
25
credentials = GoogleCredentials .get_application_default ()
25
26
service = discovery .build ('language' , 'v1' , credentials = credentials )
@@ -41,13 +42,10 @@ def main(movie_review_filename):
41
42
for i , sentence in enumerate (response ['sentences' ]):
42
43
sentence_sentiment = sentence ['sentiment' ]['score' ]
43
44
print ('Sentence {} has a sentiment score of {}' .format (
44
- i ,
45
- sentence_sentiment ))
45
+ i , sentence_sentiment ))
46
46
47
47
print ('Overall Sentiment: score of {} with magnitude of {}' .format (
48
- score ,
49
- magnitude )
50
- )
48
+ score , magnitude ))
51
49
return 0
52
50
53
51
print ('Sentiment: score of {} with magnitude of {}' .format (
Original file line number Diff line number Diff line change 12
12
# limitations under the License.
13
13
14
14
import re
15
+
15
16
from sentiment_analysis import main
16
17
17
18
You can’t perform that action at this time.
0 commit comments