Exemplo n.º 1
0
    def model_config(predicate, formula, database, mln_path,
                     db_path):  # mln_path,db_path 為string
        base_path = os.getcwd()
        mln = MLN(grammar='StandardGrammar', logic='FirstOrderLogic')
        for i in predicate:
            mln << i
            print('input predicate successful:' + i)
        for i in formula:
            mln << i
            print('input formula successful :' + i)
        mln.write()
        mln.tofile(base_path + '\\' + mln_path)  #把谓语数据储存成 mln_path.mln 档案
        db = Database(mln)
        try:
            for i in enumerate(database):
                db << i[1][1]
                print('input database successful : ' + i[1][0] + ' : ' +
                      i[1][1])
        except:
            for j in database[i[0]::]:
                db << j[1]

        db.write()
        db.tofile(base_path + '\\' + db_path)  #把证据数据储存成 db_path.db 档案
        return (db, mln)
Exemplo n.º 2
0
def test_db():
    mln = test_mln()
    db = Database(mln)
    db << 'foo(X)'
    db['bar(Y)'] = .0
    print('db write:')
    db.write()
    del db['bar(Y)']
    print('db write:')
    db.write()
    return (mln, db)