Pgn2tex - Scripts to convert pgn files to latex document. Useful to build books or pdf from pgn studies

Related tags

Deep Learningpgn2tex
Overview

Pgn2Latex (WIP)

A simple script to make pdf from pgn files and studies. It's still work in progress and I hope to improve it in the future. Please feel to reach out or to contribute by submitting issues and pull requests!

Examples

Some examples can be found in the examples/ directory. At the moment there is a book on the Stafford Gambit based on this study and a book of puzzles.

Requirements

Python

pip install -r requirements.txt

Latex

It uses xskak and skak to draw the chessboards. The latex files should be compiled using xelatex.

Usage

Studies

> python pgn2tex/study.py --help
usage: study.py [-h] [--mode {single,study}] [--players] [--template TEMPLATE] [--front-page FRONT_PAGE] [-o OUTPUT] file

Convert a PGN file to a latex document. It is supposed to be used to create book from a study or a single game analysis.

positional arguments:
  file                  PGN File to parse

options:
  -h, --help            show this help message and exit
  --mode {single,study}, -m {single,study}
                        Wether to treat each game independently or as one single large study with several chapters.
  --players, -p         Add player names
  --template TEMPLATE, -t TEMPLATE
                        Template file to use, if none only the latex content is generated with headers / document class, it can be input later on in any latex document.
  --front-page FRONT_PAGE, -f FRONT_PAGE
                        Path to a pdf frontpage
  -o OUTPUT, --output OUTPUT
> python pgn2tex/study.py examples/lichess_study_stafford-gambit_by_wyggam_2020.10.04.pgn --mode study -o examples/stafford.tex --template pgn2tex/templates/book.tex --front-page pgn2tex/templates/frontpage_stafford.pdf
> cd examples
> xelatex stafford.tex
> xelatex stafford.tex # for table of content and cross refs

Puzzles

You first need to download the lichess puzzle database and the themes description, assuming you are in the root directory of the repo:

mkdir -p data 
cd data 
wget https://database.lichess.org/lichess_db_puzzle.csv.bz2 && bzip2 -d lichess_db_puzzle.csv.bz2 
wget https://raw.githubusercontent.com/lichess-org/lila/master/translation/source/puzzleTheme.xml
cd ..

Usage:

usage: puzzles.py [-h] [--problems PROBLEMS]
                  [--theme {advancedPawn,advantage,anastasiaMate,arabianMate,attackingF2F7,attraction,backRankMate,bishopEndgame,bodenMate,castling,capturingDefender,crushing,doubleBishopMate,dovetailMate,equality,kingsideAttack,clearance,defensiveMove,deflection,discoveredAttack,doubleCheck,endgame,exposedKing,fork,hangingPiece,hookMate,interference,intermezzo,knightEndgame,long,master,masterVsMaster,mate,mateIn1,mateIn2,mateIn3,mateIn4,mateIn5,middlegame,oneMove,opening,pawnEndgame,pin,promotion,queenEndgame,queenRookEndgame,queensideAttack,quietMove,rookEndgame,sacrifice,short,skewer,smotheredMate,superGM,trappedPiece,underPromotion,veryLong,xRayAttack,zugzwang,healthyMix,playerGames,puzzleDownloadInformation} [{advancedPawn,advantage,anastasiaMate,arabianMate,attackingF2F7,attraction,backRankMate,bishopEndgame,bodenMate,castling,capturingDefender,crushing,doubleBishopMate,dovetailMate,equality,kingsideAttack,clearance,defensiveMove,deflection,discoveredAttack,doubleCheck,endgame,exposedKing,fork,hangingPiece,hookMate,interference,intermezzo,knightEndgame,long,master,masterVsMaster,mate,mateIn1,mateIn2,mateIn3,mateIn4,mateIn5,middlegame,oneMove,opening,pawnEndgame,pin,promotion,queenEndgame,queenRookEndgame,queensideAttack,quietMove,rookEndgame,sacrifice,short,skewer,smotheredMate,superGM,trappedPiece,underPromotion,veryLong,xRayAttack,zugzwang,healthyMix,playerGames,puzzleDownloadInformation} ...]]
                  [-m MIN_RATING] [-s STEP_SIZE] [-M MAX_RATING] [--template TEMPLATE] [--front-page FRONT_PAGE] [--output OUTPUT]

Generate latex with chess puzzles from the lichess database

options:
  -h, --help            show this help message and exit
  --problems PROBLEMS, -p PROBLEMS
                        Max number of problems to sample in each theme/rating range.
  --theme {advancedPawn,advantage,anastasiaMate,arabianMate,attackingF2F7,attraction,backRankMate,bishopEndgame,bodenMate,castling,capturingDefender,crushing,doubleBishopMate,dovetailMate,equality,kingsideAttack,clearance,defensiveMove,deflection,discoveredAttack,doubleCheck,endgame,exposedKing,fork,hangingPiece,hookMate,interference,intermezzo,knightEndgame,long,master,masterVsMaster,mate,mateIn1,mateIn2,mateIn3,mateIn4,mateIn5,middlegame,oneMove,opening,pawnEndgame,pin,promotion,queenEndgame,queenRookEndgame,queensideAttack,quietMove,rookEndgame,sacrifice,short,skewer,smotheredMate,superGM,trappedPiece,underPromotion,veryLong,xRayAttack,zugzwang,healthyMix,playerGames,puzzleDownloadInformation} [{advancedPawn,advantage,anastasiaMate,arabianMate,attackingF2F7,attraction,backRankMate,bishopEndgame,bodenMate,castling,capturingDefender,crushing,doubleBishopMate,dovetailMate,equality,kingsideAttack,clearance,defensiveMove,deflection,discoveredAttack,doubleCheck,endgame,exposedKing,fork,hangingPiece,hookMate,interference,intermezzo,knightEndgame,long,master,masterVsMaster,mate,mateIn1,mateIn2,mateIn3,mateIn4,mateIn5,middlegame,oneMove,opening,pawnEndgame,pin,promotion,queenEndgame,queenRookEndgame,queensideAttack,quietMove,rookEndgame,sacrifice,short,skewer,smotheredMate,superGM,trappedPiece,underPromotion,veryLong,xRayAttack,zugzwang,healthyMix,playerGames,puzzleDownloadInformation} ...]
                        Name of the themes to be used.
  -m MIN_RATING, --min-rating MIN_RATING
                        Minimum rating of the problems.
  -s STEP_SIZE, --step-size STEP_SIZE
                        Step size from problem ratings
  -M MAX_RATING, --max-rating MAX_RATING
                        Maximum rating of the problems.
  --template TEMPLATE, -t TEMPLATE
                        Template file to use, if none only the latex content is generated with headers / document class, it can be input later on in any latex document.
  --front-page FRONT_PAGE, -f FRONT_PAGE
                        Path to a pdf frontpage
  --output OUTPUT, -o OUTPUT
                        Output file

Example:

python pgn2tex/puzzles.py --template pgn2tex/templates/book.tex --front-page pgn2tex/templates/frontpage_puzzles.pdf  --output examples/puzzles.tex
cd examples
xelatex puzzles.tex
xelatex puzzles.tex # for table of contents

Code formatting

The code is formatted using Black

PyTorch reimplementation of Diffusion Models

PyTorch pretrained Diffusion Models A PyTorch reimplementation of Denoising Diffusion Probabilistic Models with checkpoints converted from the author'

Patrick Esser 265 Jan 01, 2023
GPT, but made only out of gMLPs

GPT - gMLP This repository will attempt to crack long context autoregressive language modeling (GPT) using variations of gMLPs. Specifically, it will

Phil Wang 80 Dec 01, 2022
PyTorch implementation of spectral graph ConvNets, NIPS’16

Graph ConvNets in PyTorch October 15, 2017 Xavier Bresson http://www.ntu.edu.sg/home/xbresson https://github.com/xbresson https://twitter.com/xbresson

Xavier Bresson 287 Jan 04, 2023
The AugNet Python module contains functions for the fast computation of image similarity.

AugNet AugNet: End-to-End Unsupervised Visual Representation Learning with Image Augmentation arxiv link In our work, we propose AugNet, a new deep le

Ming 74 Dec 28, 2022
ELECTRA: Pre-training Text Encoders as Discriminators Rather Than Generators

ELECTRA Introduction ELECTRA is a method for self-supervised language representation learning. It can be used to pre-train transformer networks using

Google Research 2.1k Dec 28, 2022
Tools to create pixel-wise object masks, bounding box labels (2D and 3D) and 3D object model (PLY triangle mesh) for object sequences filmed with an RGB-D camera.

Tools to create pixel-wise object masks, bounding box labels (2D and 3D) and 3D object model (PLY triangle mesh) for object sequences filmed with an RGB-D camera. This project prepares training and t

305 Dec 16, 2022
A Python Package for Convex Regression and Frontier Estimation

pyStoNED pyStoNED is a Python package that provides functions for estimating multivariate convex regression, convex quantile regression, convex expect

Sheng Dai 17 Jan 08, 2023
NOMAD - A blackbox optimization software

################################################################################### #

Blackbox Optimization 78 Dec 29, 2022
gtfs2vec - Learning GTFS Embeddings for comparing PublicTransport Offer in Microregions

gtfs2vec This is a companion repository for a gtfs2vec - Learning GTFS Embeddings for comparing PublicTransport Offer in Microregions publication. Vis

Politechnika Wrocławska - repozytorium dla informatyków 5 Oct 10, 2022
Revisiting Weakly Supervised Pre-Training of Visual Perception Models

SWAG: Supervised Weakly from hashtAGs This repository contains SWAG models from the paper Revisiting Weakly Supervised Pre-Training of Visual Percepti

Meta Research 134 Jan 05, 2023
Deep Learning for Natural Language Processing SS 2021 (TU Darmstadt)

Deep Learning for Natural Language Processing SS 2021 (TU Darmstadt) Task Training huge unsupervised deep neural networks yields to strong progress in

Oliver Hahn 1 Jan 26, 2022
Efficient and intelligent interactive segmentation annotation software

Efficient and intelligent interactive segmentation annotation software

294 Dec 30, 2022
Repositório criado para abrigar os notebooks com a listas de exercícios propostos pelo professor Gustavo Guanabara do canal Curso em Vídeo do YouTube durante o Curso de Python 3

Curso em Vídeo - Exercícios de Python 3 Sobre o repositório Este repositório contém os notebooks com a listas de exercícios propostos pelo professor G

João Pedro Pereira 9 Oct 15, 2022
Autonomous Robots Kalman Filters

Autonomous Robots Kalman Filters The Kalman Filter is an easy topic. However, ma

20 Jul 18, 2022
A machine learning project which can detect and predict the skin disease through image recognition.

ML-Project-2021 A machine learning project which can detect and predict the skin disease through image recognition. The dataset used for this is the H

Debshishu Ghosh 1 Jan 13, 2022
🕹️ Official Implementation of Conditional Motion In-betweening (CMIB) 🏃

Conditional Motion In-Betweening (CMIB) Official implementation of paper: Conditional Motion In-betweeening. Paper(arXiv) | Project Page | YouTube in-

Jihoon Kim 81 Dec 22, 2022
SOTA easy to use PyTorch-based DL training library

Easily train or fine-tune SOTA computer vision models from one training repository. SuperGradients Introduction Welcome to SuperGradients, a free open

619 Jan 03, 2023
Repository for the AugmentedPCA Python package.

Overview This Python package provides implementations of Augmented Principal Component Analysis (AugmentedPCA) - a family of linear factor models that

Billy Carson 6 Dec 07, 2022
CHERRY is a python library for predicting the interactions between viral and prokaryotic genomes

CHERRY is a python library for predicting the interactions between viral and prokaryotic genomes. CHERRY is based on a deep learning model, which consists of a graph convolutional encoder and a link

Kenneth Shang 12 Dec 15, 2022
Demystifying How Self-Supervised Features Improve Training from Noisy Labels

Demystifying How Self-Supervised Features Improve Training from Noisy Labels This code is a PyTorch implementation of the paper "[Demystifying How Sel

<a href=[email protected]"> 4 Oct 14, 2022