def add_file(self, name: str, fname: Union[Path, str]) -> None: df = holstep.read_file(fname) grp = self._h5f.create_group(name) grp_conjecture = grp.create_group("conjecture") self._set_graph(grp_conjecture, self._build_graph(df.conjecture.text)) grp.create_dataset("labels", data=np.array(df.labels, dtype=np.bool), compression="gzip") grp_statements = grp.create_group("statements") for (i, s) in enumerate(df.examples): grp_statement = grp_statements.create_group("%05d" % i) self._set_graph(grp_statement, self._build_graph(s.text)) n = len(self._h5f["examples_conjecture"]) self._h5f["examples_conjecture"].resize((n + len(df.examples), )) for i in range(n, n + len(df.examples)): self._h5f["examples_conjecture"][i] = name self._h5f["examples_statement"].resize((n + len(df.examples), )) self._h5f["examples_statement"][n:] = np.arange(len(df.examples), dtype=np.int32) self._len += len(df.examples)
import itertools import sys import parsy import holstep import parser_parsy sys.setrecursionlimit(10000) for fname in itertools.chain(("holstep/train/%05d" % i for i in range(1, 10000)), ("holstep/test/%04d" % i for i in range(1, 1412))): print(fname) file = holstep.read_file(fname) num_error = 0 for formula in itertools.chain([file.conjecture], file.dependencies, file.examples): try: parser_parsy.thm.parse(formula.text) except parsy.ParseError as ex: print(ex) print(formula.text) num_error += 1 if num_error >= 10: break
int]]) -> List[int]: n_args = [] for arg in args: n_arg = process(arg, env) edges.append((n, n_arg)) n_args.append(n_arg) return n_args def build_treelets(n: int, n_children: List[int]) -> None: for i, n_ch1 in enumerate(n_children): for n_ch2 in n_children[i + 1:]: treelets.append((n_ch1, n, n_ch2)) process(t, {}) return nodes, edges, treelets if __name__ == '__main__': import holstep import parser_funcparselib df = holstep.read_file("holstep/train/00001") thm = parser_funcparselib.thm.parse( parser_funcparselib.tokenize(df.conjecture.text)) print(thm) t = thm_to_tree(thm) print(t) print(collect_labels(t)) g = tree_to_graph(t) print(g)