Sentiment analysis seeks to determine the general attitude of a writer, given some text they have written. For example, given the movie review “The film was a breath of fresh air” a sentiment analysis

# R epla ce th is c o m ment w it h a n a ppro pria te h eader c o m ment. # R epla ce th is c o m ment w it h y o ur fu nctio n d efin it io ns. # # E va lu atio n # #def e va lu ate (w ord _se ntim ent_ dic t, file n am e): # # f = o pen(file nam e, " r" ) # # c o rre ct = 0 # # in co rre ct = 0 # # fo r lin e in f: # # lin e = lin e.s tr ip () # # s co re = in t( lin e[0 ]) # # w ord s = lin e[2 :] # # p re dic te d_posit iv e = is _ posit iv e (w ord s, w ord _se n tim en t_ dic t) # # if s co re > 2 a nd p re dic te d_posit iv e : # # c o rre ct + = 1 # # e lif s co re < = 2 a nd n ot p re dic te d_p osit iv e : # # c o rre ct + = 1 # # e ls e : # # in co rre ct + = 1 # # f.c lo se () # # p rin t( " p re dic te d c o rre ctly :" , c o rre ct, " (" + str (c o rre ct/( c o rre ct+ in co rre ct) )+ ")" ) # # p rin t( " p re dic te d in co rre ctly :" , in co rre ct, " (" + str (in co rre ct/( c o rre ct+ in co rre ct) )+ ")" ) # ## D O N O T D ELE TE T H IS L IN E: b eg t e stin g w ord _se ntim ent_ dic tio nary = m ake _w ord _se n tim en t_ dic tio nary (" m ovie _re vie w s_ tr a in in g.tx t" ) p rin t( " n ic e ", w ord _se ntim ent_ dic tio nary [" n ic e "]) p rin t( " s to ry ", w ord _se ntim ent_ dic tio nary [" s to ry "]) # p rin t( p re dic t_ se ntim ent_ sco re (" T his m ovie is a w eso m e !" , w ord _se n tim en t_ dic tio nary )) # e va lu ate (w ord _se ntim ent_ dic tio nary , " m ovie _re vie w s_ d ev.tx t" )