MCPcopy Create free account
hub / github.com/google-deepmind/alphageometry / from_string

Method from_string

problem.py:384–402  ·  view source on GitHub ↗

Load deduction rule from a str object.

(cls, string: str, to_dict: bool = False)

Source from the content-addressed store, hash-verified

382
383 @classmethod
384 def from_string(cls, string: str, to_dict: bool = False) -> Theorem:
385 """Load deduction rule from a str object."""
386 theorems = string.split('\n')
387 theorems = [l for l in theorems if l and not l.startswith('#')]
388 theorems = [cls.from_txt(l) for l in theorems]
389
390 for i, th in enumerate(theorems):
391 th.rule_name = 'r{:02}'.format(i)
392
393 if to_dict:
394 result = {}
395 for t in theorems:
396 if t.name in result:
397 t.name += '_'
398 result[t.rule_name] = t
399
400 return result
401
402 return theorems
403
404 @classmethod
405 def from_txt(cls, data: str) -> Theorem:

Callers 2

from_txt_fileMethod · 0.45
from_txt_fileMethod · 0.45

Calls 1

from_txtMethod · 0.45

Tested by

no test coverage detected