def make_dictpkl(raw_dict_motherpath,dicts_path):
    import tp_utility as tpu
    for dict_path,dict_name in tpu.getFileName(raw_dict_motherpath):
        dict=[]
        dictfile = open(dict_path,'r')
        for dict_word in dictfile.readlines():
            dict_word = dict_word.decode('utf-8')
            dict_word = dict_word.replace(' \n','')
            #print dict_word
            if dict_word !='' and tpu.ischinese(dict_word):#or  dict_word >= u'\u4e00' and dict_word<=u'\u9fa5':
                #print dict_word
                dict.append(dict_word)
        pickle.dump(dict, open(dicts_path+'/'+dict_name+'.pkl','wb'))
def load_dictpickle(dict_motherpath):
    import tp_utility as tpu
    dicts = []
    for dict_path,dict_name in tpu.getFileName(dict_motherpath):
        dicts.append(pickle.load(open(dict_path, 'r')))
    global insufficientdict,inversedict,ishdict, moredict,mostdict,negdict,posdict,verydict
    insufficientdict = dicts[0]
    inversedict = dicts[1]
    ishdict = dicts[2]
    moredict = dicts[3]
    mostdict = dicts[4]
    negdict = dicts[5]
    posdict = dicts[6]
    verydict = dicts[7]
예제 #3
0
def make_dictpkl(raw_dict_motherpath, dicts_path):
    import tp_utility as tpu
    for dict_path, dict_name in tpu.getFileName(raw_dict_motherpath):
        dict = []
        dictfile = open(dict_path, 'r')
        for dict_word in dictfile.readlines():
            dict_word = dict_word.decode('utf-8')
            dict_word = dict_word.replace(' \n', '')
            #print dict_word
            if dict_word != '' and tpu.ischinese(
                    dict_word
            ):  #or  dict_word >= u'\u4e00' and dict_word<=u'\u9fa5':
                #print dict_word
                dict.append(dict_word)
        pickle.dump(dict, open(dicts_path + '/' + dict_name + '.pkl', 'wb'))