Spintax


Spintax

This is a Python module that parses Spintax. Spintax also known as spinning syntax is often used then text is “spun”, all this means is that the code can create many sentences or paragraphs that are all worded differently however all mean the same thing.

Simple example:
"{Hey|Hello|Hi} {this|here} is {an example of|how to use} Spintax{.|!|}"
Can produce:
  • Hey this is an example of Spintax.
  • Hi here is how to use Spintax
  • Hello this how to use Spintax
  • Hi here is an example of Spintax!

The above example Spintax can return 36 possibilities however this number grows exponentially as more spintax is used.

This code was originally made so the bots I code can respond with automated responses that are unique, I found that by doing this people tended to interact with the bot more. I also noticed that by displaying the same information different ways to people who had trouble understanding English (as it was not their native language) were more likely to understand the meaning of the sentence.

There are many applications of Spintax from generating memorable passwords and usernames to making automated responses seem less robotic. Spintax is useful for chat bots or for video game dialog so that responses seem more natural, this module can be extremely useful with Amazon Alexa skills (apps for Alexa) or other voice automation so that communication with the device seems less robotic.

This module is simple to use;

import spintax
string = r"{Hey|Hello|Hi} {this|here} is {an example of|how to use} Spintax{.|!|}"
print(spintax.spin(string))

Just input the string into the parse function and it will return the spun text, unlike other Spintax parsers this parser is allows for both nested spintax (spintax within spintax) and the abilerty to escape the syntax characters for example;

spintax.spin(r"\{example|shown|here}")
>> '{example|shown|here}'

To download this module either download a copy from Github and install manually or use pip,

pip install spintax

Project Details

Language: Python

Tagged: Spintax, Spintax parser, Text Spinning

URL: http://github.com/AceLewis/Spintax

Other Projects.

  • Killed by Police - A project scraping and processing data obtained from killedbypolice.net
  • This website - This website is made using Jekyll a open source static website builder.
  • Spintax - A Python module to parse spintax, this was created so one of my bots can send people messages that are not the same every time.
  • Steam Trading Bot - A Steam trading bot used to automatically trade items.

About me

I am interested in Physics, Maths, Programming and also play a few games in my spare time. I have an interest in data and have made webscrapers to gather and process information, I am currently looking into nice ways to display information easily in infographics using Python. I can code in Matlab, Python and have also made a Steam trading bot in Node.JS.

Social Links