clean_movetext: Remove comments and annotations from movetext

View source: R/clean_movetext.R

clean_movetextR Documentation

Remove comments and annotations from movetext

Description

Removes comments, annotations, and other formatting that would interfere with engine analysis.

Usage

clean_movetext(movetext, cut_gtm = TRUE)

Arguments

movetext

A character vector of PGN movetext data

cut_gtm

(Default = TRUE) A boolean indicating if game termination markers should be deleted

Details

The PGN specification allows comments, annotations, game termination markers, and formatting oddities that may not play well with all software. The clean_movetext() function removes everything but the moves and move numbers, unless the cut_gtm parameter is set to FALSE.

Value

A character vector of clean movetext.

Note

Game termination markers ('1-0', '0-1', '1/2-1/2', '*') are removed by default. This causes the movetext to no longer comply with the PGN specification. PGN files saved without game termination markers will not function properly. If you intend to save the clean movetext to a PGN file, set the cut_gtm parameter to FALSE to preserve the game termination markers.

As a human-readable (and writable) format, pgn files may sometimes contain non-standard characters. Some sources may use zero for castling ('0-0' or '0-0-0') instead of capital letter O. Clean movetext will convert these to the accepted forms. Em (—) or en (–) dashes are replaced with ordinary dashes (-).

See Also

get_pgn() to get the movetext and other data from a PGN file.

Examples

clean_movetext('1. e4! {Best by test.} e5 (d5 leads to the Scandinavian.) *')

dryguy/rbitr documentation built on Oct. 15, 2024, 6:18 a.m.