def test_expression(): #start clean Expression.drop_collection() Assertion.drop_collection() a1 = Assertion.make('/data/test', '/rel/IsA', ['/concept/test/assertion', '/concept/test/test']) expr = Expression.make(a1, '{0} is a {1}', ['this assertion', 'test'], 'en') #check for consistency, ensure all attributes are readable expr.check_consistency() expr.assertion expr.text expr.confidence expr.arguments expr.language expr.frame expr.id assert expr.name == '/expression/%s' % expr.id # load the same assertion from the DB a2 = Assertion.make('/data/test', '/rel/IsA', ['/concept/test/assertion', '/concept/test/test']) assert expr.assertion == a2 #test static methods replace = Expression.replace_args(expr.frame, expr.arguments) assert replace == "this assertion is a test" #clean up Assertion.drop_collection() Expression.drop_collection()
def test_expression(): #start clean Expression.drop_collection() Assertion.drop_collection() a1 = Assertion.make('/data/test','/rel/IsA', ['/concept/test/assertion', '/concept/test/test']) expr = Expression.make(a1, '{0} is a {1}', ['this assertion', 'test'], 'en') #check for consistency, ensure all attributes are readable expr.check_consistency() expr.assertion expr.text expr.confidence expr.arguments expr.language expr.frame expr.id assert expr.name == '/expression/%s' % expr.id # load the same assertion from the DB a2 = Assertion.make('/data/test','/rel/IsA', ['/concept/test/assertion', '/concept/test/test']) assert expr.assertion == a2 #test static methods replace = Expression.replace_args(expr.frame, expr.arguments) assert replace == "this assertion is a test" #clean up Assertion.drop_collection() Expression.drop_collection()
import conceptdb from conceptdb.assertion import Assertion, Expression, Sentence from conceptdb.metadata import Dataset from conceptdb.justify import ReasonConjunction conceptdb.connect_to_mongodb('test') #clean out whatever was in test before Assertion.drop_collection() Dataset.drop_collection() Expression.drop_collection() ReasonConjunction.drop_collection() Sentence.drop_collection() #make a new dataset d = Dataset.make('/data/test', 'en') #make a couple of assertions a1 = Assertion.make(d, '/rel/IsA', ['/concept/assertion', '/concept/test']) a2 = Assertion.make(d, '/rel/IsA', ['/concept/database', '/concept/test']) #add expressions to them e1 = a1.make_expression('{0} is a {1}', a1.arguments, d.language) e2 = a2.make_expression('{0} is a {1}', a2.arguments, d.language) #connect them to sentences a1.connect_to_sentence(d, 'This assertion is a test.') a2.connect_to_sentence(d, 'This database is a test.') #make a reason for myself r = ReasonConjunction.make('/data/test/contributor/elhawk', ['user_factor'], 0.75, True)
import conceptdb from conceptdb.assertion import Assertion, Expression, Sentence from conceptdb.metadata import Dataset from conceptdb.justify import ReasonConjunction conceptdb.connect_to_mongodb('test') #clean out whatever was in test before Assertion.drop_collection() Dataset.drop_collection() Expression.drop_collection() ReasonConjunction.drop_collection() Sentence.drop_collection() #make a new dataset d = Dataset.make('/data/test', 'en') #make a couple of assertions a1 = Assertion.make(d, '/rel/IsA', ['/concept/assertion', '/concept/test']) a2 = Assertion.make(d, '/rel/IsA', ['/concept/database', '/concept/test']) #add expressions to them e1 = a1.make_expression('{0} is a {1}', a1.arguments, d.language) e2 = a2.make_expression('{0} is a {1}', a2.arguments, d.language) #connect them to sentences a1.connect_to_sentence(d, 'This assertion is a test.') a2.connect_to_sentence(d, 'This database is a test.') #make a reason for myself r = ReasonConjunction.make('/data/test/contributor/elhawk', ['user_factor'],