m00shm00sh/mathgen
Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Repository files navigation
Mathgen ======= Mathgen is a tool to randomly generate fake mathematics papers. Online version: Soon (TM) Source code (Github): https://github.com/m00shm00sh/mathgen Prerequisites ============= Mathgen was developed and tested on Gentoo Linux with Go 1.23. It should work on other systems supported by LaTeX ecosystem and Golang. To run Mathgen, you will need: - Golang - LaTeX - BibTeX You will need the following LaTeX packages: - AMS-LaTeX - fullpage - mathrsfs - natbib - truncate If you want to produce books (-product book), you will need the following additional LaTeX packages: - geometry - txfonts - hyphenat - textcase - hyperref - titlesec - makeidx - url - tocbibind You will also need the `makeindex' program. Building ======== (pushd go && go build) Running ======= The main Mathgen program is `main`. For a summary of options, run: $ ./main -h The current default behavior, is to generate an article with one randomly generated author and view the output with `xdg-open`. A basic http server can run on :8080, for use in browser: $ ./http Use envar RATE_LIMIT to set rate limit so there's not 9000 concurrent pdflatex processes running. Then visit http://127.0.0.1:8080/article.pdf . Use query-params author and seed to specify author(s) and seed. Examples ======== Generate an article with author "J. Doe" and view the output with xpdf: `$ ./main - product article -mode view -author "J. Doe" -viewer xpdf` The same, but write the PDF to `mypaper.pdf': `$ ./main -product article -mode pdf -author "J. Doe" -output mypaper.pdf` Give yourself a famous collaborator, and create a zip file with the source and PDF: `$ ./main -product article -mode zip -output mypaper.zip -author "J. Doe" -author "P. Erd\H{o}s"` Tip: To randomly generate an author's name, you can use `-author FAMOUS_AUTHOR' or `-author GENERIC_AUTHOR'. Generate a book: `$ ./main -product book -mode pdf -output mybook.pdf -author "J. Doe"` Note that this may take a couple of minutes to generate and compile. Source code =========== A quick road map to the files in the source distribution: - debugdriver.go: debug driver - main.go: command-line front-end - http.go: http front-end - mathgen/: the `mathgen` module - mathgen/bibtex.go: bibtex generator - (*GeneratorWorker) GenerateBibtex (string) string - mathgen/driver.go: file production driver - Product - product to generate - Blurb - generate blurb - Article - generate article - Book - generate book (all lowercase for string representation) - OutputMode - output to generate - Raw - raw output (for blurb) - Pdf - pdf file output - Zip - zip file output - ZipAll - zip file containing all working files (for debugging) - `Driver`: driver configuration struct - `Product`: product to generate - `OutputMode`: output mode - `Seed`: seed; leave as zero to use default run-time generated value - `Authors`: list of authors; leave as nil to use default random-generated name - `NewDriver`: create new Driver - `(*Driver) SetVerbosity`: set verbosity level - `(*Driver) GenerateOutput`: produce output, returning Reader and last error - mathgen/engine.go: main engine - `GeneratorBuilder`: builder struct for preparing rule reading - `Input`: main input file `io.Reader` - `AddBibtexPlaceholder`: if `true`, prepare the rules for an auxiliary Bibtex pass - `Generator`: main generator; holds rule patterns and worker setup recipes; multiple expansions can be done from the same Generator provided the GeneratorWorker is not shared - `NewGeneratorBuilder`: create a new builder with default values - `(*GeneratorBuilder) SetLogger`: set logger - `(*GeneratorBuilder) SetVerbosity`: set verbosity level; support for changing level after generator is built is missing - `(*GeneratorBuilder) SetAuthors`: set authors - `(*GeneratorBuilder) Build`: build a `Generator` created from input in Builder - `GeneratorWorker`: per-expansion worker - `(*Generator) NewWorker`: create a new worker ready to start expanding - `(*Generator) Seed`: get the seed value in use - `(*Generator) GenerateString`: generate string given start token - `(*Generator) GenerateText` generate string with start token `START` - mathgen/latexpretty.go: LaTeX pretty printing - Pretty - pretty printing to perform - `PNone` - none - `Platex` - article pretty-printing - `Platexbook` - book pretty-printing - `Pbibtex` - bibtex pretty-printing - `(*Generator) GeneratePrettyString`: generate LaTeX or Bibtex text with fixed formatting - mathgen/loggable.go: Internal logging helpers (no exported functions) - mathgen/re.go: internal regex helpers (no exported functions) - mathgen/util.go: internal utility helpers (no exported functions) - mathgen/verbosity.go: verbosity type and its flag interface - Verbosity - type - None - verbosity level `none` - Info - verbosity level `info` - Verbose - verbosity level `verbose` - Debug - verbosity level `debug` - scirules.in: Common grammar rules, included into the following files. - sci{article,book,blurb}.in: Grammar rules specific for the corresponding products. Credits ======= Mathgen was written by Nate Eldredge <nate at thatsmathematics dot com> and ported to other languages by Andrey V, incorporating code from SCIgen (https://pdos.csail.mit.edu/scigen/), by Jeremy Stribling, Max Krohn, and Dan Aguayo, without whom this project would not exist. Jordan Eldredge wrote most of the web interface. A list of names of famous mathematicians, used in the program, was extracted from the web site The Greatest Mathematicians of All Time (https://fabpedigree.com/james/greatmm.htm) by James Dow Allen, and is used by permission. A list of countries and other place names was taken from Wikipedia (https://en.wikipedia.org/wiki/List_of_adjectival_and_demonymic_forms_of_place_names) License ======= Mathgen is free software. You are welcome to share, copy, and modify it, under the terms of the GNU General Public License, version 2.0. See the file COPYING.