MCPcopy Create free account
hub / github.com/CodeClash-ai/CodeClash / _movetext

Function _movetext

codeclash/arenas/chess/replay.py:189–202  ·  view source on GitHub ↗

Extract the SAN token list from PGN movetext (strip headers/comments/numbers/result).

(pgn: str)

Source from the content-addressed store, hash-verified

187
188
189def _movetext(pgn: str) -> list[str]:
190 """Extract the SAN token list from PGN movetext (strip headers/comments/numbers/result)."""
191 lines = [ln for ln in pgn.splitlines() if not ln.startswith("[")]
192 text = " ".join(lines)
193 text = re.sub(r"\{[^}]*\}", " ", text) # comments
194 text = re.sub(r"\([^)]*\)", " ", text) # variations
195 text = re.sub(r"\$\d+", " ", text) # NAGs
196 text = re.sub(r"\d+\.(\.\.)?", " ", text) # move numbers
197 out = []
198 for tok in text.split():
199 if tok in ("1-0", "0-1", "1/2-1/2", "*"):
200 break
201 out.append(tok)
202 return out
203
204
205def _header(pgn: str, key: str) -> str | None:

Callers 1

parseMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected