-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNFLplayerSentiments.py
More file actions
42 lines (35 loc) · 1.16 KB
/
NFLplayerSentiments.py
File metadata and controls
42 lines (35 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
'''Main Entry Point.
Usage: python NFLplayerSentiments.py 'QUERY'
(with quotes).
@author Alan Ponte
'''
from __future__ import print_function
import sys
from server.nfl.trends import get_sentiments
from server.nfl.trends import create_sentiment_report
import xml.etree.ElementTree as ET
def createReport(query):
""" Creates a sentiment report based on the QUERY."""
sentiments = get_sentiments(query)
print("Based on the query, %s has an average sentiment value of %d", query, sentiments)
def usage():
""" Sends a usage message to the user. """
print("Usage:\n python NFLplayerSentiments.py 'QUERY' (remember to include the quotes).")
def correct_player_name(name):
"""Returns True iff NAME is a name of a player in the XML database."""
tree = ET.parse('players.xml')
root = tree.getroot()
for rt in root:
if rt.attrib['name'] is name:
return True
return False
def main():
#TO DO: Check in XML DB to see if player exists.
try:
query = sys.argv[1]
except IndexError:
usage()
sys.exit(1)
create_sentiment_report(query)
if __name__ == "__main__":
main()