def generate_unigram_model(favs):
    try:
        freqfav = cpickler.frompickle(filename='favs_model_unigram.dump')
    except:
        freqfav = {}

    esc = [u'…', u'・', u'.', u',', u'、', u'。', u'!', u'?', u'!', u'?']
    for favlist in favs:
        for fav in favlist:
            itemlist = mecabCaller.parse(fav.text)
            for itemraw in itemlist:
                item = [x for x in itemraw if x in esc]
                if item in freqfav:
                    freqfav[item] += 1
                else:
                    freqfav[item] = 1
    cpickler.topickle(freqfav, filename='favs_model_unigram.dump')

    return freqfav
Beispiel #2
0
 def __init__(self):
     self.freq = cpickler.frompickle('favs_model_unigram.dump')
Beispiel #3
0
def callSentenceGen_pickle(reply,modelpath):
	freq1=cpickler.frompickle(modelpath)
	keyword1=keywordext.extraction(reply.text,freq1)
	sentenceGen=sentenceGenerator.sentenceGenerator(freq1)
	sentence=sentenceGen.generateSentence(keyword1)
	return sentence
	def __init__(self,modelpath):
		self.freq1=cpickler.frompickle(modelpath)