All Projects → AceLewis → Spintax

AceLewis / Spintax

Licence: other
A Python module for parsing spintax, unlike any other module this works with nested spintax and also allows the user to escape the special characters used in its syntax.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Spintax

Solid
Liquid template engine in Elixir
Stars: ✭ 68 (-12.82%)
Mutual labels:  parser
Ng4 Loading Spinner
Angular 4 custom async loading spinner.
Stars: ✭ 74 (-5.13%)
Mutual labels:  spinner
Gutenberg Parser Rs
An experimental Rust parser for WordPress Gutenberg post format
Stars: ✭ 76 (-2.56%)
Mutual labels:  parser
To.ml
OCaml library for TOML
Stars: ✭ 68 (-12.82%)
Mutual labels:  parser
Gw2 Elite Insights Parser
Binary parser for the .evtc files that arcdps generates after a boss encounter. This will generate a .html file where the results can be easily reviewed.
Stars: ✭ 73 (-6.41%)
Mutual labels:  parser
Parser
Generate a JSON documentation for a SFC Vue component. Contribute: https://gitlab.com/vuedoc/parser#contribute
Stars: ✭ 74 (-5.13%)
Mutual labels:  parser
Php Svg Lib
SVG file parsing / rendering library
Stars: ✭ 1,146 (+1369.23%)
Mutual labels:  parser
Mimekit
A .NET MIME creation and parser library with support for S/MIME, PGP, DKIM, TNEF and Unix mbox spools.
Stars: ✭ 1,214 (+1456.41%)
Mutual labels:  parser
Xmlparser
A low-level, pull-based, zero-allocation XML 1.0 parser.
Stars: ✭ 73 (-6.41%)
Mutual labels:  parser
Jetpack.js
A ECMAScript bundler and minifier implemented in C++ aimed at excellent performance.
Stars: ✭ 75 (-3.85%)
Mutual labels:  parser
Materialspinner
A spinner view for Android
Stars: ✭ 1,173 (+1403.85%)
Mutual labels:  spinner
Parsing With Haskell Parser Combinators
🔍 A step-by-step guide to parsing using Haskell parser combinators.
Stars: ✭ 72 (-7.69%)
Mutual labels:  parser
Sequential
An environment to visualize JavaScript code execution in a browser
Stars: ✭ 74 (-5.13%)
Mutual labels:  parser
Anglesharp.js
👼 Extends AngleSharp with a .NET-based JavaScript engine.
Stars: ✭ 68 (-12.82%)
Mutual labels:  parser
Cat
Plain C library for parsing AT commands for use in host devices.
Stars: ✭ 77 (-1.28%)
Mutual labels:  parser
Oga
Read-only mirror of https://gitlab.com/yorickpeterse/oga
Stars: ✭ 1,147 (+1370.51%)
Mutual labels:  parser
Method log
Trace the history of an individual method in a git repository (experimental)
Stars: ✭ 73 (-6.41%)
Mutual labels:  parser
Marko
A markdown parser with high extensibility.
Stars: ✭ 77 (-1.28%)
Mutual labels:  parser
Lang C
Lightweight C parser for Rust
Stars: ✭ 77 (-1.28%)
Mutual labels:  parser
Any23
Apache Anything To Triples (Any23) is a library, a web service and a command line tool that extracts structured data in RDF format from a variety of Web documents.
Stars: ✭ 74 (-5.13%)
Mutual labels:  parser

spintax

A Python module for parsing spintax, unlike any other module this also allows both nested spintax and the ability to escape special characters.

How to Install

To install using pip run:

pip install spintax

Alternatively this module can be installed by downloading the zipped folder or cloning the repository and running:

python setup.py install

What is spintax

Spintax (also known as spin syntax) is a way to create random strings that have the same or similar meaning.

Spintax is very useful as it can be used in programs such as chat bots or video game character speach, it allows the dialog to not sound so repetitive and robotic. Spintax also has great applications in voice assistants such as in Amazon's Alexa, you can easily make skills (apps for the Alexa) that respond without saying the exact same thing every time.

There are examples of spintax in use in the examples folder

The syntax

Spintax replaces braces (also known as curly brackets, {}) containing text with a random predefined string. The random string is defined withing the braces by using a pipe | as a seperator.

Simple example:
"{Hey|Hello|Hi} this is {spin syntax|spintax}{.|!|}"
Can produce:
  • Hey this is spintax.
  • Hi this is spin syntax
  • Hello this is spintax
  • Hi this is spintax!

Unlike other modules, you can escape the special characters used in spintax by placing an odd number of "\"'s before the character.

Example:
r"""{Hey|Hello|Hi}{,|} this is {spin syntax|spintax}{.|!|}
To use {this module|spintax} enclose \{your|words\} in {those brackets|braces} and use {a \||the \||a pipe (\|)} to separate them
"""
Can produce:
  • Hi this is spintax!

    To use spintax enclose {your|words} in braces and use the | to separate them

  • Hi, this is spin syntax

    To use this module enclose {your|words} in those brackets and use a | to separate them

  • Hello this is spintax.

    To use spintax enclose {your|words} in those brackets and use a pipe (|) to separate them

Example of Nested Spintax:
   "This is nested {{s|S}pintax|spin syntax}"
Can produce:
  • This is nested Spintax
  • This is nested spin syntax
  • This is nested spintax

How to use this module

This module can be used to spin Spintax easily.

import spintax
print(spintax.spin("{Simple|Easy} {example|demonstration}"))

The Spin Function:

Inputs:
  • string: The sting to parse, make sure it is a literal string if you use 's within the string.
  • seed: (Optional) if a seed for the random function is desired a seed can be set (Default no seed).

Regex help

I would like to say that http://regex101.com helped me a lot with the creation of the Regex, if you need to make Regex I recommend using this website as it is a great tool. They also have an IRC channel that is friendly, and the user OnlineCop helped me with the non capturing group I used to match the spintax brackets.

Licence

This software is licensed under the GNU General Public License (version 3) as published by the Free Software Foundation this licence http://www.gnu.org/licenses/ . If you would want a different licence please contact me, on twitter @_AceLewis or Reddit /u/_AceLewis.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].