Free spinner tool

Status
Not open for further replies.

Moxxy

New member
Jul 10, 2009
189
6
0
Rating - 0%
0   0   0
may or may not be useful...

basically spins files in the standard spin format but with a few twists... So a basic file would look something like:
the {cat|dog} sat on the mat

twist #1, it supports nesting. So you could use
the {cat|{fat|thin} {lama|weasel}} sat on the mat

fat thin would only apply if the lama|weasel option is chosen. so you'd never have a fat cat, just a cat. The nesting works at any level.

twist #2

you can adjust the probability of any word with the following format
{cat(0.5)|dog}
all words have default weighting of 1. So in this case cat would get chosen about 1/3rd of the time.

weightings might be a bit flaky with nested elements (in some cases they'll apply to the whole nested group) but they work fine with top level elements. Will sort that out one day.

twist #3
supports optional/blank elements. if you have an empty string element and it gets chosen it will remove the previous space if one exists so you don't get double spacing.
e.g.
the {big|small|) {cat|dog} ate itself
or
the {big||small) {cat|dog} ate itself
could produce:
the cat ate itself

an example with output:
the {cat(0.5)|{{very|slightly} fat|thin} {lama|weasel}} {sat|died|shat} on the {mat|chair}
the slightly fat lama shat on the mat
the cat died on the chair
the thin lama shat on the chair
the thin weasel sat on the chair
the cat sat on the mat
the cat shat on the chair
the slightly fat weasel shat on the chair
the cat sat on the chair
the cat died on the mat
the thin lama died on the chair
the cat sat on the chair
the slightly fat lama shat on the chair
the cat sat on the mat
the very fat lama died on the chair
the thin lama shat on the chair
the thin lama sat on the mat
the very fat weasel sat on the mat
the thin lama died on the chair
the thin weasel sat on the chair
the thin lama sat on the mat

find it at: http://gnodes.com/spinner.rar

run spinerator.bat with no args for usage.
 


updated... weighting notation should work on nested elements now...
 
  • Like
Reactions: emp
minor update... added a new 'unique' option. Very basic implementation, it just keeps the hashcode of each string and checks it hasn't been done before. So it's theoretically possible to get a duplicate but probably 1 in a million...

usage:
spinerator -vu infile.txt outfile.txt <num results>

if you do a single run first it will tell you how many possible permutations there are.

same download link...
 
Any chance to get this thing in PHP open source? That would be nice to integrate into server-side scripts...
 
Any chance to get this thing in PHP open source? That would be nice to integrate into server-side scripts...

was wondering how long before someone said the P word... not unless someone wants to rewrite it... It's written in java. I don't much like using PHP so I'm not keen on doing it myself.

having said that though, that's the reason I made it command line accessible. I'm pretty sure you can exec shell commands from php. Most hosts allow you to use java SE runtime. To use it on a *nix host you'd just need an sh wrapper that's basically the same as the batch file (which is only two lines)... or just call java command directly...

just had a look and it's as easy as this:

Code:
 [COLOR=#000000] [COLOR=#0000bb]<?php
$output [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000bb]shell_exec[/COLOR][COLOR=#007700]([/COLOR][COLOR=#dd0000]'spinerator -v test.txt out.txt'[/COLOR][COLOR=#007700]);
echo [/COLOR][COLOR=#dd0000]"<pre>[/COLOR][COLOR=#0000bb]$output[/COLOR][COLOR=#dd0000]</pre>"[/COLOR][COLOR=#007700];
[/COLOR][COLOR=#0000bb]?>[/COLOR] [/COLOR]
PHP: shell_exec - Manual
 
Just updated again to add a clean output option... suppresses everything except the output text (and delimiters if you're using multiple outputs). Useful if you want to parse the results yourself. Still writes the files. I'll sort that out sometime...
 
  • Like
Reactions: mattseh
Status
Not open for further replies.