박은주

Clearance

......@@ -27,14 +27,16 @@ def GetResult(annotations):
def analyze(movie_review_filename):
client = language_v1.LanguageServiceClient()
with open(movie_review_filename, "r", encoding='utf-8-sig') as review_file:
# Instantiates a plain text document.
content = review_file.read()
document = language_v1.Document(content=content, type_=language_v1.Document.Type.PLAIN_TEXT)
annotations = client.analyze_sentiment(request={'document': document})
return GetResult(annotations)
try:
with open(movie_review_filename, "r", encoding='utf-8-sig') as review_file:
# Instantiates a plain text document.
content = review_file.read()
document = language_v1.Document(content=content, type_=language_v1.Document.Type.PLAIN_TEXT)
annotations = client.analyze_sentiment(request={'document': document})
return GetResult(annotations)
except:
return 0, 0, 0, 0
def StartSentimentAnalysis():
return analyze("data.txt")
\ No newline at end of file
......