-
Notifications
You must be signed in to change notification settings - Fork 0
/
profile.py
117 lines (78 loc) · 3.53 KB
/
profile.py
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
###########################################################################################################################################################
# Hamlet Character Profiles
# DESCRIPTION: Creates a general profile of the characters in Hamlet
# Created June 2, 2017
###########################################################################################################################################################
# Stuff to do:
# Finish incorporating characters
# Parse the text instead of hard-coding the answer (more a test of concept right now)
###########################################################################################################################################################
import argparse
import numpy as np
import matplotlib.pyplot as plt
def info(name):
# input: name
# output: name, status, family, entrance, exit, cause of death,
# word count, average sentiment, most negative moment,
# most positive moment, killed by, first word, last word, longest speech
# Hamlet
if name == 'hamlet':
status = 'Prince Of Denmark'
father = 'King of Denmark'
mother = 'Gertrude'
family = [father,mother]
ent_act = 1
ent_scene = 2
entrance = [ent_act,ent_scene]
ex_act = 5
ex_scene = 2
play_exit = [ex_act,ex_scene]
cod = 'Poisoned by a sword in a duel with Laeretes'
kills = 'quite a few people'
killed_by = 'Claudius (poisoner) and Laeretes (dueler)'
wrdcnt = 10
first_wrd = 'A little more than kin, and less than kind!'
last_wrd = 'The rest is silence'
longest_speech = 'find this from fafsta file in future'
avg_sent = 10
most_neg = 10
most_pos = 10
# make this a dictionary instead? cleaner I think
profile = [name,status,family,entrance,play_exit,cod,wrdcnt,avg_sent,most_neg,most_pos,kills,killed_by,first_wrd,last_wrd,longest_speech]
return profile
def Main():
# fetches information from the command line for character to analyze
parser = argparse.ArgumentParser()
parser.add_argument("char_name",help='the name of the character (no caps) in hamlet you wish to profile',type=str)
args = parser.parse_args()
char_name = args.char_name
hamlet_character_list = ['claudius',
'hamlet', 'polonius',
'horatio', 'laertes',
'rosencrantz', 'guildenstern',
'osric', 'priest', 'marcellus',
'bernardo', 'francisco',
'reynaldo', 'players',
'clownone', 'clowntwo',
'gertrude', 'ophelia',
'fortinbras', 'ghost', 'other']
if char_name not in hamlet_character_list:
print("This character is not in Hamlet")
# making this case insensitive?
else:
# create a routine here for reading t
# collect the information (from the text)
profile = info(args.char_name)
# for printing the information
status = profile[1]
parents = profile[2]
father = parents[0]
mother = parents[1]
ent = profile[3]
ex = profile[4]
cod = profile[5]
print('The character ' + char_name + ', ' + status + ' is the son of ' + father + ' and ' + mother)
print('He enters the play in Act '+ str(ent[0]) + ', Scene ' + str(ent[1]))
print('He exits the play in Act ' + str(ex[0]) + ', Scene ' + str(ent[1]))
if __name__ == '__main__':
Main()