def problog(self, line, cell=None): """problog line/cell magic""" args = parse_argstring(self.problog, line) if args.knowledge == 'nnf': knowledge = DDNNF elif args.knowledge == 'sdd': knowledge = SDD elif args.knowledge is None: if SDD.is_available(): knowledge = SDD else: knowledge = DDNNF else: error("Unknown option for --knowledge: '%s'" % args.knowledge) if args.logspace: semiring = SemiringLogProbability() else: semiring = None s = cell data = runproblog(s, knowledge=knowledge, semiring=semiring, output='html') if data: display_html(data, raw=True)
import sys import os sys.path.append(os.path.join(os.path.dirname(__file__), '..')) sys.path.append(os.path.join(os.path.dirname(__file__), '../examples')) from problog.logic import Term from problog.program import PrologString, ExtendedPrologFactory, LogicProgram from problog.evaluator import SemiringLogProbability from problog.parser import DefaultPrologParser from problog.ddnnf_formula import DDNNF from problog.sdd_formula import SDD import problog.tasks.sample as plsample if SDD.is_available(): knowledge_default = SDD else: knowledge_default = DDNNF from IPython.core.display import display_html from IPython.core.magic import (Magics, magics_class, line_magic, line_cell_magic) from IPython.core.magic_arguments import (argument, magic_arguments, parse_argstring) import IPython if IPython.version_info[0] >= 6: import warnings def info(message): warnings.warn('WARNING: ' + message)