Wolfpack
Junior Member
- Jul 13, 2011
- 166
- 351
Been a while since I posted anything helpful/anything at all. Here's a small little program I wrote last night in C#, it spins articles using the spintax format, and supports multilevel spinning, i.e.
It's not exactly the most extensive program, but it's a quick put-together which I think a lot of people will want. Have fun, and report bugs here 
PS: Don't know if it needs a virus check because it's only 7KB and archived, but if anybody wants to do a virus check and post the stats that'd be really helpful, no idea how to do it or what to use, as I've never uploaded a .exe
Aussi, here's a screenshot of it in action:
On request, here's the source code
Code:
{this|is|{multi|level|spinning}|as|there's|more{than|one}|layer {of|curly}|brackets}
PS: Don't know if it needs a virus check because it's only 7KB and archived, but if anybody wants to do a virus check and post the stats that'd be really helpful, no idea how to do it or what to use, as I've never uploaded a .exe
Aussi, here's a screenshot of it in action:

On request, here's the source code
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Text.RegularExpressions;
using System.IO;
namespace WindowsFormsApplication36
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
lblError.Visible = false;
}
private static readonly Random random = new Random();
private static readonly object syncLock = new object();
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text.Split('{').Length == textBox1.Text.Split('}').Length)
{
string text = textBox1.Text;
string carrier;
MatchCollection md = Regex.Matches(text, "\\{[\\s\\S]*\\}*");
foreach (Match d in md)
{
string dstr = d.Value;
carrier = LongSpinner(dstr);
text = textBox2.Text = Regex.Replace(text, Regex.Escape(d.Value), carrier);
}
lblCharCount.Text = textBox2.Text.Length.ToString();
string unique = Uniqueness(textBox1.Text);
if (unique != "")
{
lblUnique.Text = unique + "%";
}
else
{
lblUnique.Text = "0.00%";
}
if (Combinations(textBox1.Text) > 1000000 | Combinations(textBox1.Text) < 0)
{
lblCombination.Text = "1,000,000+";
}
else
{
lblCombination.Text = Combinations(textBox1.Text).ToString();
}
}
else
{
lblError.Visible = true;
}
}
private void button2_Click(object sender, EventArgs e)
{
if (textBox1.Text.Split('{').Length == textBox1.Text.Split('}').Length)
{
string text = textBox1.Text;
string carrier;
MatchCollection md = Regex.Matches(text, "\\{[\\s\\S]*\\}*");
Random rnd = new Random();
foreach (Match d in md)
{
string dstr = d.Value;
carrier = Spinner(dstr, rnd);
text = textBox2.Text = Regex.Replace(text, Regex.Escape(d.Value), carrier);
}
lblCharCount.Text = textBox2.Text.Length.ToString();
string unique = Uniqueness(textBox1.Text);
if (unique != "")
{
lblUnique.Text = unique + "%";
}
else
{
lblUnique.Text = "0.00%";
}
if (Combinations(textBox1.Text) > 1000000)
{
lblCombination.Text = "1,000,000+";
}
else
{
lblCombination.Text = Combinations(textBox1.Text).ToString();
}
}
else
{
lblError.Visible = true;
}
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
lblError.Visible = false;
}
private void button7_Click(object sender, EventArgs e)
{
if (textBox1.Text.Split('{').Length == textBox1.Text.Split('}').Length)
{
string text = textBox1.Text;
string carrier;
MatchCollection md = Regex.Matches(text, "\\{[\\s\\S]*\\}*");
Random rnd = new Random();
foreach (Match d in md)
{
string dstr = d.Value;
carrier = ShortSpinner(dstr);
text = textBox2.Text = Regex.Replace(text, Regex.Escape(d.Value), carrier);
}
lblCharCount.Text = textBox2.Text.Length.ToString();
string unique = Uniqueness(textBox1.Text);
if (unique != "")
{
lblUnique.Text = unique + "%";
}
else
{
lblUnique.Text = "0.00%";
}
if (Combinations(textBox1.Text) > 1000000)
{
lblCombination.Text = "1,000,000+";
}
else
{
lblCombination.Text = Combinations(textBox1.Text).ToString();
}
}
}
private string Spinner(string mstr, Random rdm)
{
string returnword;
string[] arrSplit;
int cnt = 0;
while (Regex.IsMatch(mstr, "\\{"))
{
string innerspin = mstr.Split('{')[(mstr.Split('{').Length) - 1];
string tospin = Regex.Match(innerspin, "[\\s\\S]*?(?=\\})").Value;
arrSplit = tospin.Split('|');
returnword = arrSplit[rdm.Next(0, arrSplit.Length)];
cnt++;
Console.WriteLine(cnt);
mstr = Regex.Replace(mstr, "\\{" + Regex.Escape(tospin) + "\\}", returnword);
}
return mstr;
}
private string LongSpinner(string mstr)
{
string returnword;
string[] arrSplit;
int cnt = 0;
while (Regex.IsMatch(mstr, "\\{"))
{
string innerspin = mstr.Split('{')[(mstr.Split('{').Length) - 1];
string tospin = Regex.Match(innerspin, "[\\s\\S]*?(?=\\})").Value;
int idx = 0;
int x = 0;
int longcount = 0;
arrSplit = tospin.Split('|');
foreach (string str in arrSplit)
{
int length = str.Length;
if (length > longcount)
{
longcount = length;
idx = x;
}
x++;
}
returnword = arrSplit[idx];
cnt++;
Console.WriteLine(cnt);
mstr = Regex.Replace(mstr, "\\{" + Regex.Escape(tospin) + "\\}", returnword);
}
return mstr;
}
private int Combinations(string text)
{
MatchCollection mc = Regex.Matches(text, "\\{[\\s\\S]*?\\}");
int combno = 1;
foreach (Match m in mc)
{
string[] arrMatch = m.Value.Split('|');
combno *= arrMatch.Length;
if (combno > 1000000)
{
break;
}
}
return combno;
}
private string Uniqueness(string text)
{
int spincount = 0;
int allcount = 0;
MatchCollection notspun = Regex.Matches(text, "\\{[\\s\\S]*?\\}");
foreach (Match m in notspun)
{
spincount += m.Value.Length;
}
MatchCollection all = Regex.Matches(text, "[\\S]*");
foreach (Match m in all)
{
allcount += m.Value.Length;
}
int nonspun = allcount - spincount;
MatchCollection mc = Regex.Matches(text, "(?<=\\{)[\\s\\S]*?(?=\\})");
decimal[] arrDoubles = new decimal[mc.Count];
int x = 0;
foreach (Match m in mc)
{
int averagelengthcnt = 0;
string[] arrMatch = m.Value.Split('|');
foreach (string s in arrMatch)
{
averagelengthcnt += s.Length;
}
arrDoubles[x] = Decimal.Divide(averagelengthcnt, arrMatch.Length);
x++;
}
return text = (Decimal.Divide(arrDoubles.Sum(), (arrDoubles.Sum() + nonspun)) * 100).ToString("#.##");
}
public static int RandomNumber(int min, int max)
{
lock (syncLock)
{
return random.Next(min, max);
}
}
private string ShortSpinner(string mstr)
{
string returnword;
string[] arrSplit;
int cnt = 0;
while (Regex.IsMatch(mstr, "\\{"))
{
string innerspin = mstr.Split('{')[(mstr.Split('{').Length) - 1];
string tospin = Regex.Match(innerspin, "[\\s\\S]*?(?=\\})").Value;
int idx = 0;
int x = 0;
int longcount = 0;
int firstcnt = 0;
arrSplit = tospin.Split('|');
foreach (string str in arrSplit)
{
int length = str.Length;
if (length < longcount | (longcount == 0 && firstcnt == 0))
{
longcount = length;
idx = x;
firstcnt++;
}
x++;
}
returnword = arrSplit[idx];
cnt++;
Console.WriteLine(cnt);
mstr = Regex.Replace(mstr, "\\{" + Regex.Escape(tospin) + "\\}", returnword);
}
return mstr;
}
private void button5_Click(object sender, EventArgs e)
{
dlgSave.Filter = "Text Files|*.txt";
DialogResult drUsr;
drUsr = dlgSave.ShowDialog();
if (drUsr == DialogResult.OK)
{
FileStream fs = new FileStream(dlgSave.FileName, FileMode.OpenOrCreate, FileAccess.Write, FileShare.ReadWrite);
StreamWriter sw = new StreamWriter(fs, Encoding.ASCII);
sw.Write(textBox1.Text);
sw.Flush();
sw.Close();
fs.Close();
}
}
private void button6_Click(object sender, EventArgs e)
{
textBox2.Text = "";
}
static System.Timers.Timer Time = new System.Timers.Timer(8000);
static bool signaler = false;
static void _timer_Elapsed(object sender, ElapsedEventArgs e)
{
signaler = true;
Time.Enabled = false;
}
private void button3_Click(object sender, EventArgs e)
{
dlgOpen.Filter = "Text Files|*.txt";
DialogResult drUsr;
drUsr = dlgOpen.ShowDialog();
if (drUsr == DialogResult.OK)
{
StreamReader sr = new StreamReader(dlgOpen.FileName);
textBox1.Text = sr.ReadToEnd();
}
}
private void button4_Click(object sender, EventArgs e)
{
textBox1.Text = "";
}
}
}
Attachments
Last edited: