I would like to construct a mechanism that constructs different facts depending from txt file, imported in prolog. I already have found some examples where they directly assert
You can do any 'normal' prolog in a DCG by enclosing it in {}
some_nonterminal --> "fridge", blanks, [X], { % you can put any normal Prolog code in here assert(fridge_named(X)) }.
This looks for a sequence like
fridge G
and asserts fridge_named(0x47) in the database (Ascii G is 0x47)