Giter Site home page Giter Site logo

spintax's Introduction

spintax

Spintax is a text generation library on go. And also command line tool is included.

Spintax is an template with alternative parts that can be evaluated into one of many texts. Depth is not limited

Command

There is ready to use command line tool that can generate text from spintax template. Usage:

$ spintax -h
usage: spintax [-c] [-f] [-a] <spintax> // generates one random text out of given spintax template
  -a	print all the possible texts instead of one random
  -c	print count of distinct possible texts instead of generating one
  -f	interpret argument as a file name with spintax not as spintax itself
  -h	print help and exit

Install

You need to have go installed, or install it now.

go get -u github.com/nikandfor/spintax/...

Example

Spintax                 -> results
"string"                -> "string"
"{opt_a|opt_b}"         -> "opt_a" or "opt_b"
"this is {|so} awesome" -> "this is so awesome" or
                           "this is  awesome" (two spaces here)
"this is{| so} awesome" -> "this is so awesome" or
                           "this is awesome" (one space here)
"{{a|b}|{c|d}}"
the same as "{a|b|c|d}" -> "a" or "b" or "c" or "d"
"a{b{c|d}e|f{g|h}i}j"   -> "abcej" or "abdej" or "afgij" or "afhij"

command line tool usage examples

$ spintax "a{b{c|d}e|f{g|h}i}j"
abdej
$ spintax "a{b{c|d}e|f{g|h}i}j"
afhij
$ echo "a{b{c|d}e|f{g|h}i}j" >spintax.txt
$ spintax -a -f spintax.txt
abcej
abdej
afgij
afhij

Specification

Using Extended Backus-Naur Form Spintax is an Expression where

Expression  ::= { String | Alternative }
Alternative ::= "{" [ AltList ] "}"
AltList     ::= Expression { "|" Expression }
String is an empty or non-empty string

spintax's People

Contributors

nikandfor avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.