tslmy / idiomgraph-gv

Graph of Chinese idioms.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

成语接龙图生成器 IdiomGraph-gv

Codacy Badge Total alerts Maintainability HitCount

A program that generates a look-up chart for the game Chinese Idiom Solitaire.

Idiom Solitaire is a classic game among Chinese speakers. In this game, players take turns to come up with an four-character idiom that starts with the last (forth) character of the last player's idiom. This first player that fails to come up with one loses (and have to take a shot of spirit -- at least this was how I learned the game when I was 8 years old).

How is that a game? There are ~50,000 four-character idioms in the Chinese language (at least in the dictionary that I'm using in this repo), each of which start with one of ~3,500 unique characters. Thus, each round of game may end up with an unique path of idioms presented.

Technical details: The chart will be in PDF format, generated by graphviz, and is a direct graph. Notice that the graph might not be connected (in the graph-theory sense).

demo

Usage

  1. Create a conda environment with the required packages:
conda create --name idiom --file conda-requirements.txt
conda activate idiom
  1. Run this command to retrieve a list of idioms:
curl https://raw.githubusercontent.com/fighting41love/funNLP/master/data/%E6%88%90%E8%AF%AD%E8%AF%8D%E5%BA%93/ChengYu_Corpus%EF%BC%885W%EF%BC%89.txt > idioms.txt
  1. Run the main script:
python main.py generate

Related Projects

About

Graph of Chinese idioms.

License:GNU General Public License v3.0


Languages

Language:Python 90.0%Language:Starlark 10.0%