| |
- add_to_task(...)
- ilasp.add_to_task(string)
Parses the string and adds any examples, rules in the hypothesis space,
background knowledge and other parts to the ILASP task. Note that adding rules
to the hypothesis space will not update any coverage formulas that have already
been computed.
- all_examples(...)
- [list of example ids] = ilasp.all_examples()
This function returns the list of all example ids in the task.
- find_all_counterexamples(...)
- [list of example ids] = ilasp.find_all_counterexamples(solve_result)
Given a solve_result (which must contain a hypothesis and a list of example ids
which are known not to be covered), this function returns the list of all
example ids such that the example is not covered by the hypothesis and not in
the set of examples that are known not to be covered.
- find_counterexample(...)
- example_id = ilasp.find_counterexample(solve_result)
Given a solve_result (which must contain a hypothesis and a list of example ids
which are known not to be covered), this function returns a single example id
such that the example is not covered by the hypothesis and not in the set of
examples that are known not to be covered.
- get_example(...)
- ilasp.get_example(example_id)
This is easiest to explain with an example. Consider the following ILASP input file:
#pos(a, {p}, {q}, {r.}).
#pos(e, {p}, {q}, {r.}).
#neg(b@1, {p}, {q}, {r.}).
#brave_ordering(c@1, a, e).
#cautious_ordering(d@1, a, e, >).
#ilasp_script
print ilasp.get_example('a')
print ilasp.get_example('b')
print ilasp.get_example('c')
print ilasp.get_example('d')
#end.
If this is run in ILASP, it outputs the following:
{'exclusions': ['q'], 'penalty': 0L, 'inclusions': ['p'], 'context': ['r.\n'], 'type': 'positive', 'id': 'a'}
{'exclusions': ['q'], 'penalty': 1L, 'inclusions': ['p'], 'context': ['r.\n'], 'type': 'negative', 'id': 'b'}
{'eg1': 'a', 'eg2': 'e', 'penalty': 1L, 'type': 'brave-order', 'id': 'c', 'op': '<'}
{'eg1': 'a', 'eg2': 'e', 'penalty': 1L, 'type': 'cautious-order', 'id': 'd', 'op': '>'}
- hypothesis_to_string(...)
- string = ilasp.hypothesis_to_string([list of rule ids])
Given a list of rule ids, this function returns a string containing each of the
corresponding rules.
- ilasp2(...)
- solve_result = ilasp.ilasp2([list of examples])
This function uses ILASP2 to find the optimal hypothesis w.r.t. the list of
examples. The structure of the solve result is:
{
'uncovered': [ list of example ids],
'expected_score': [ an integer (the sum of 'hypothesis_length' and
'example penalty')],
'example_penalty': [ an integer ]
'hypothesis': [ a list of (integer) rule ids ]
'hypothesis_length': [ an integer ]
}
|