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

Method from_txt

problem.py:161–179  ·  view source on GitHub ↗

Load a problem from a str object.

(cls, data: str, translate: bool = True)

Source from the content-addressed store, hash-verified

159
160 @classmethod
161 def from_txt(cls, data: str, translate: bool = True) -> Problem:
162 """Load a problem from a str object."""
163 url = ''
164 if '\n' in data:
165 url, data = data.split('\n')
166
167 if ' ? ' in data:
168 clauses, goal = data.split(' ? ')
169 goal = Construction.from_txt(goal)
170 else:
171 clauses, goal = data, None
172
173 clauses = clauses.split('; ')
174 problem = Problem(
175 url=url, clauses=[Clause.from_txt(c) for c in clauses], goal=goal
176 )
177 if translate:
178 return problem.translate()
179 return problem
180
181 @classmethod
182 def to_dict(cls, data: list[Problem]) -> dict[str, Problem]:

Callers

nothing calls this directly

Calls 3

translateMethod · 0.95
ProblemClass · 0.85
from_txtMethod · 0.45

Tested by

no test coverage detected