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 implementation of paper "Efficient Nearest Neighbor Language Models" (EMNLP 2021)

Pytorch implementation of paper "Efficient Nearest Neighbor Language Models" (EMNLP 2021)

Junxian He 57 Jan 01, 2023
P-Tuning v2: Prompt Tuning Can Be Comparable to Finetuning Universally Across Scales and Tasks

P-tuning v2 P-Tuning v2: Prompt Tuning Can Be Comparable to Finetuning Universally Across Scales and Tasks An optimized prompt tuning strategy achievi

THUDM 540 Dec 30, 2022
Source code for the paper "PLOME: Pre-training with Misspelled Knowledge for Chinese Spelling Correction" in ACL2021

PLOME:Pre-training with Misspelled Knowledge for Chinese Spelling Correction (ACL2021) This repository provides the code and data of the work in ACL20

197 Nov 26, 2022
PyTorch implementation of image classification models for CIFAR-10/CIFAR-100/MNIST/FashionMNIST/Kuzushiji-MNIST/ImageNet

PyTorch Image Classification Following papers are implemented using PyTorch. ResNet (1512.03385) ResNet-preact (1603.05027) WRN (1605.07146) DenseNet

1.2k Jan 04, 2023
Cowsay - A rewrite of cowsay in python

Python Cowsay A rewrite of cowsay in python. Allows for parsing of existing .cow

James Ansley 3 Jun 27, 2022
Code for KDD'20 "Generative Pre-Training of Graph Neural Networks"

GPT-GNN: Generative Pre-Training of Graph Neural Networks GPT-GNN is a pre-training framework to initialize GNNs by generative pre-training. It can be

Ziniu Hu 346 Dec 19, 2022
571 Dec 25, 2022
SymmetryNet: Learning to Predict Reflectional and Rotational Symmetries of 3D Shapes from Single-View RGB-D Images

SymmetryNet SymmetryNet: Learning to Predict Reflectional and Rotational Symmetries of 3D Shapes from Single-View RGB-D Images ACM Transactions on Gra

26 Dec 05, 2022
A PyTorch-based Semi-Supervised Learning (SSL) Codebase for Pixel-wise (Pixel) Vision Tasks

PixelSSL is a PyTorch-based semi-supervised learning (SSL) codebase for pixel-wise (Pixel) vision tasks. The purpose of this project is to promote the

Zhanghan Ke 255 Dec 11, 2022
A Keras implementation of YOLOv3 (Tensorflow backend)

keras-yolo3 Introduction A Keras implementation of YOLOv3 (Tensorflow backend) inspired by allanzelener/YAD2K. Quick Start Download YOLOv3 weights fro

7.1k Jan 03, 2023
Code for our ICCV 2021 Paper "OadTR: Online Action Detection with Transformers".

Code for our ICCV 2021 Paper "OadTR: Online Action Detection with Transformers".

66 Dec 15, 2022
An experiment on the performance of homemade Q-learning AIs in Agar.io depending on their state representation and available actions

Agar.io_Q-Learning_AI An experiment on the performance of homemade Q-learning AIs in Agar.io depending on their state representation and available act

1 Jun 09, 2022
A Fast Sequence Transducer Implementation with PyTorch Bindings

transducer A Fast Sequence Transducer Implementation with PyTorch Bindings. The corresponding publication is Sequence Transduction with Recurrent Neur

Awni Hannun 184 Dec 18, 2022
OpenCVのGrabCut()を利用したセマンティックセグメンテーション向けアノテーションツール(Annotation tool using GrabCut() of OpenCV. It can be used to create datasets for semantic segmentation.)

[Japanese/English] GrabCut-Annotation-Tool GrabCut-Annotation-Tool.mp4 OpenCVのGrabCut()を利用したアノテーションツールです。 セマンティックセグメンテーション向けのデータセット作成にご使用いただけます。 ※Grab

KazuhitoTakahashi 30 Nov 18, 2022
Generating synthetic mobility data for a realistic population with RNNs to improve utility and privacy

lbs-data Motivation Location data is collected from the public by private firms via mobile devices. Can this data also be used to serve the public goo

Alex 11 Sep 22, 2022
From this paper "SESNet: A Semantically Enhanced Siamese Network for Remote Sensing Change Detection"

SESNet for remote sensing image change detection It is the implementation of the paper: "SESNet: A Semantically Enhanced Siamese Network for Remote Se

1 May 24, 2022
Official implementation for paper: Feature-Style Encoder for Style-Based GAN Inversion

Feature-Style Encoder for Style-Based GAN Inversion Official implementation for paper: Feature-Style Encoder for Style-Based GAN Inversion. Code will

InterDigital 63 Jan 03, 2023
Efficient face emotion recognition in photos and videos

This repository contains code of face emotion recognition that was developed in the RSF (Russian Science Foundation) project no. 20-71-10010 (Efficien

Andrey Savchenko 239 Jan 04, 2023
ReGAN: Sequence GAN using RE[INFORCE|LAX|BAR] based PG estimators

Sequence Generation with GANs trained by Gradient Estimation Requirements: PyTorch v0.3 Python 3.6 CUDA 9.1 (For GPU) Origin The idea is from paper Se

40 Nov 03, 2022
Neural Turing Machines (NTM) - PyTorch Implementation

PyTorch Neural Turing Machine (NTM) PyTorch implementation of Neural Turing Machines (NTM). An NTM is a memory augumented neural network (attached to

Guy Zana 519 Dec 21, 2022