(_)
| 602 | |
| 603 | |
| 604 | def main(_): |
| 605 | global DEFINITIONS |
| 606 | global RULES |
| 607 | |
| 608 | # definitions of terms used in our domain-specific language. |
| 609 | DEFINITIONS = pr.Definition.from_txt_file(_DEFS_FILE.value, to_dict=True) |
| 610 | # load inference rules used in DD. |
| 611 | RULES = pr.Theorem.from_txt_file(_RULES_FILE.value, to_dict=True) |
| 612 | |
| 613 | # when using the language model, |
| 614 | # point names will be renamed to alphabetical a, b, c, d, e, ... |
| 615 | # instead of staying with their original names, |
| 616 | # in order to match the synthetic training data generation. |
| 617 | need_rename = _MODE.value != 'ddar' |
| 618 | |
| 619 | # load problems from the problems_file, |
| 620 | problems = pr.Problem.from_txt_file( |
| 621 | _PROBLEMS_FILE.value, to_dict=True, translate=need_rename |
| 622 | ) |
| 623 | |
| 624 | if _PROBLEM_NAME.value not in problems: |
| 625 | raise ValueError( |
| 626 | f'Problem name `{_PROBLEM_NAME.value}` ' |
| 627 | + f'not found in `{_PROBLEMS_FILE.value}`' |
| 628 | ) |
| 629 | |
| 630 | this_problem = problems[_PROBLEM_NAME.value] |
| 631 | |
| 632 | if _MODE.value == 'ddar': |
| 633 | g, _ = gh.Graph.build_problem(this_problem, DEFINITIONS) |
| 634 | run_ddar(g, this_problem, _OUT_FILE.value) |
| 635 | |
| 636 | elif _MODE.value == 'alphageometry': |
| 637 | model = get_lm(_CKPT_PATH.value, _VOCAB_PATH.value) |
| 638 | run_alphageometry( |
| 639 | model, |
| 640 | this_problem, |
| 641 | _SEARCH_DEPTH.value, |
| 642 | _BEAM_SIZE.value, |
| 643 | _OUT_FILE.value, |
| 644 | ) |
| 645 | |
| 646 | else: |
| 647 | raise ValueError(f'Unknown FLAGS.mode: {_MODE.value}') |
| 648 | |
| 649 | |
| 650 | if __name__ == '__main__': |
nothing calls this directly
no test coverage detected