def mk_exp_wordfreq(): #convs= pu.convs_list_train() fl = open(pth.ExpConvs,'r') exps= pickle.load(fl) ExpFreq = nltk.FreqDist() for conv in exps: msgs= pu.get_msgs_in(conv) tally=[] for msg in msgs: #print msg if msg is not None: words = msg.split() for word in words: lw= word.lower() if lw not in tally: tally.append(lw) ExpFreq.inc(lw) fl = open(pth.ExpDict,'w') pickle.dump(ExpFreq,fl)
def mk_nonexp_wordfreq(): #convs= pu.convs_list_train() fl = open(pth.NonexpConvs,'r') nexps= pu.convs_list_nonexp() NonexpFreq = nltk.FreqDist() #count = 0 for conv in nexps: msgs= pu.get_msgs_in(conv) tally=[] for msg in msgs: #print msg #count +=1 #if count >3: # break if msg is not None: words = msg.split() for word in words: lw= word.lower() if lw not in tally: tally.append(lw) NonexpFreq.inc(lw) fl = open(pth.NonexpDict,'w') pickle.dump(NonexpFreq,fl)