Ejemplo n.º 1
0
def main():
    db = DB()
    if not db.open("bayes.kch", DB.OWRITER | DB.OCREATE):
        return

    with open("word_tf.txt") as word_tf:
        for line in word_tf:
            line = line.strip()
            word, bayes_list = loads(line)
            print word
            if bayes_list:
                ar = array('I')
                ar.fromlist(lineiter(bayes_list))
                db[word] = ar.tostring()
Ejemplo n.º 2
0
def main():
    db = DB()
    if not db.open("bayes.kch", DB.OWRITER | DB.OCREATE):
        return

    with open("word_tf.txt") as word_tf:
        for line in word_tf:
            line = line.strip()
            word, bayes_list = loads(line)
            print word
            if bayes_list:
                ar = array('I')
                ar.fromlist(lineiter(bayes_list))
                db[word] = ar.tostring()
Ejemplo n.º 3
0
def dumps_id_score(id_score):
    r = array('I')
    r.fromlist(map(int, lineiter(id_score)))
    return r.tostring()