markly

Markov chain for text generation
git clone git://git.yotsev.xyz/markly.git
Log | Files | Refs | README | LICENSE

commit 3e0ac7b8866db826adb0040b3890cd247847eb5c
parent a1bf341477f469faaa1f5311f549b4f2c1df0188
Author: Petar Yotsev <petar@yotsev.xyz>
Date:   Fri, 17 Jul 2020 09:16:28 +0100

Adding option descriptions in README and replacing continuous argument "-c" with "-C" because of overlap with chain "-c"

Diffstat:
MREADME.md | 46++++++++++++++++++++++++++++++++++++++++++----
Mmain.cpp | 2+-
2 files changed, 43 insertions(+), 5 deletions(-)

diff --git a/README.md b/README.md @@ -27,21 +27,21 @@ names.txt: Continuously generating usernames at order 3 and length 10: - ./markly -s -f names.txt -o 3 -l 10 -c + ./markly -s -f names.txt -o 3 -l 10 -C Continuously generating usernames at order 3 and maximum length: - ./markly -s -f names.txt -o 3 -m -c + ./markly -s -f names.txt -o 3 -m -C Generating a continuous username by resetting the gram when nothing follows: - ./markly -s -f names.txt -o 3 -m -c > username.tmp + ./markly -s -f names.txt -o 3 -m -C > username.tmp cat username.tmp | tr -d '\n' > username rm username.tmp Generating continuous text resembling that of book.txt: - ./markly -f book.txt -o 5 -m -c + ./markly -f book.txt -o 5 -m -C Saving a compiled chain for later use: @@ -57,6 +57,44 @@ Using a compiled chain: ## Options +`-s` Short form. Useful for text comprising of short strings on separate lines. +It takes the beginnings of such strings and stores them in a separate array +from the rest of the grams. When generating a new string, a random beginning +from the array is taken and expanded on using the chain. Use this if all the +output strings start with "a" or something similarly predictable. + +`-f [text.txt]` File. Select a file from which the to compiling a Markov chain +and output text. For saving the chain see `-g`. + +`-g text.txt [nameOfChain]` Generate. In addition to compiling the chain, it +saves it to nameOfChain.o3 where "o3" is added automatically depending on the +specified order (see `-o`). When `nameOfChain` is omitted and there are +supplied arguments afterwards, the chain is saved in chain.o3 with the same +handling of the extension. By default there is no output but there is no +restriction on it, you can still make the program generate text by passing +`-n`/`-C` and `-l`/`-m`. + +`-c nameOfChain.o3` Chain. Selects a compiled chain file for the text +generation. When loading a chain, specifying the order doesn't work because the +chain is already compiled with a set order. The order is also automatically read +from the chain so the whole argument can be omitted. The ".o3" extension +doesn't play a role in the reading of the order, it's just there to help the +user. The "3" in ".o3" is the order of the chain. The file extension should be +read as "order 3". + +`-o order` Order. Specifies the order of the compiled chain. + +`-n iterations` Iterations. Specifies number of iterations. + +`-C` Continuous. Infinite iterations. + +`-l length` Length. Specifies the length of the generated strings in characters. + +`-m` Maximum length. Generates text untill it reaches a gram with no following +characters. + +`-v` Verbose. It prints some status messages to standard error. + ## License GPLv2 diff --git a/main.cpp b/main.cpp @@ -105,7 +105,7 @@ int main(int argc, char** argv) length = std::stoi(argv[i + 1]); } else if (arg == "-m") { infinite = true; - } else if (arg == "-c") { + } else if (arg == "-C") { continuous = true; } else if (arg == "-n") { itterations = std::stoi(argv[i + 1]);