Skip to content

Running Popper from Python in a loop on different scenarios #96

@mgualti

Description

@mgualti

I'm trying to run Popper from Python in a loop like this:

for i in range(len(examples_file_names)):

    popper_settings = popper.util.Settings(
        bias_file = bias_file_name,
        bk_file = background_file_name,
        ex_file = examples_file_names[i])
    prog, score, stats = popper.loop.learn_solution(popper_settings)
    
    prog = list(prog)
    for rule in prog:
        rule_string = popper.util.format_rule(rule)[:-1]
        janus.query_once(f'assert(({rule_string})), fail')

    # Use janus.query to see which examples match the rule...

It appears that some information is not reset between loop iterations. For instance, the examples appear to be accumulating. Is there a way to reset the examples that are stored in the Prolog session, or, better yet, reset everything?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions