I'm writing a script for text prediction using NLTK's Conditional Frequency Distribution.
I want to store the distribution in SQL database for later usage using JSON. Is it even possible? If yes, how to dump the ConditionalFrequencyDistribution format using JSON?
Or maybe there is some other nifty way of storing it?
cfd = ConditionalFreqDist()
prev_words = None
cnt=0
for word in words:
if cnt > 1:
prev_words = words[cnt-2]+' '+words[cnt-1]
cfd[prev_words].inc(word)
cnt+=1