Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Dudinator 1999 by Turfster
- // pretty much made for @glassbottommeg
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace Dudinator
- {
- public struct Duderism
- {
- public byte startingVolume; // the lowest 'volume' we want this to start matching
- public List<string> duded; // the thing(s) to replace it with, list for random support, just in case
- public Duderism(byte sV, string s)
- {
- startingVolume = sV;
- duded = new List<string>();
- duded.Add(s);
- }
- public Duderism(byte sV, List<string> ls)
- {
- startingVolume = sV;
- duded = new List<string>(ls);
- }
- }
- // fuck it, let's go static, since we don't want to do the whole dictionary thing every time
- public static class Dudinator1999
- {
- // okay, this is getting slightly overengineered, but you can have a tiered list of options per word, and each option can have multiple options for randomisation purposes
- // yes this is total overkill for most stuff, but eh
- // also, please add the tiered list in order
- static Dictionary<string, List<Duderism>> myDictionary;
- public static void Initialize()
- {
- // fill the dictionary
- myDictionary = new Dictionary<string, List<Duderism>>();
- myDictionary.Add("he", new List<Duderism> { new Duderism(1, "the dude") });
- myDictionary.Add("she", new List<Duderism> { new Duderism(1, "the dude") });
- myDictionary.Add("it", new List<Duderism> { new Duderism(5, "the dude") });
- myDictionary.Add("his", new List<Duderism> { new Duderism(3, "dude's") });
- myDictionary.Add("her", new List<Duderism> { new Duderism(3, "dude's") });
- myDictionary.Add("its", new List<Duderism> { new Duderism(3, "the dude's") });
- myDictionary.Add("it's", new List<Duderism> { new Duderism(3, "dude's") });
- myDictionary.Add("guys", new List<Duderism> { new Duderism(8, "dudes") });
- myDictionary.Add("girls", new List<Duderism> { new Duderism(8, "dudes") });
- myDictionary.Add("people", new List<Duderism> { new Duderism(8, "dudes") });
- myDictionary.Add("totally", new List<Duderism> { new Duderism(2, "totes") });
- myDictionary.Add("dog", new List<Duderism> { new Duderism(3, "good dude") });
- myDictionary.Add("dogs", new List<Duderism> { new Duderism(3, "good dudes") });
- myDictionary.Add("cat", new List<Duderism> { new Duderism(3, "li'l dude") });
- myDictionary.Add("cats", new List<Duderism> { new Duderism(3, "li'l dudes") });
- /*// with random options
- myDictionary.Add("cool", new List<Duderism> { new Duderism(4, new List<string>{ "radical", "tubular", "gnarly" }) });
- myDictionary.Add("great", new List<Duderism> { new Duderism(6, new List<string> { "radical", "tubular", "gnarly" }) });
- myDictionary.Add("amazing", new List<Duderism> { new Duderism(7, new List<string> { "radical", "tubular", "gnarly" }) });
- myDictionary.Add("awesome", new List<Duderism> { new Duderism(5, new List<string> { "radical", "tubular", "gnarly" }) });
- myDictionary.Add("crazy", new List<Duderism> { new Duderism(6, new List<string> { "radical", "tubular", "gnarly" }) });
- */
- // without random options, but with a tiered list per word
- myDictionary.Add("cool", new List<Duderism> { new Duderism(4, "radical"), new Duderism(6, "tubular"), new Duderism(9, "gnarly") });
- myDictionary.Add("great", new List<Duderism> { new Duderism(4, "radical"), new Duderism(6, "tubular"), new Duderism(9, "gnarly") });
- myDictionary.Add("amazing", new List<Duderism> { new Duderism(4, "radical"), new Duderism(6, "tubular"), new Duderism(9, "gnarly") });
- myDictionary.Add("awesome", new List<Duderism> { new Duderism(4, "radical"), new Duderism(6, "tubular"), new Duderism(9, "gnarly") });
- myDictionary.Add("crazy", new List<Duderism> { new Duderism(4, "radical"), new Duderism(6, "tubular"), new Duderism(9, "gnarly") });
- myDictionary.Add(".", new List<Duderism> { new Duderism(5, ", dude.") });
- myDictionary.Add("?", new List<Duderism> { new Duderism(5, ", dude?") });
- myDictionary.Add("!", new List<Duderism> { new Duderism(11, " *air guitar solo*") });
- // are these more valley girl than dude? idk, I only speak Californian by way of 90s movies
- myDictionary.Add("if", new List<Duderism> { new Duderism(10, "if, like,") });
- myDictionary.Add("or", new List<Duderism> { new Duderism(10, "or, like,") });
- myDictionary.Add("and", new List<Duderism> { new Duderism(10, "and, like,") });
- }
- public static string ToDude(string inputString)
- {
- return ToDude(inputString, 2); // the "neutral" default?
- }
- static bool IsPunctuation(char inChar)
- {
- return ((inChar == '.') || (inChar == ',') || (inChar == '?') || (inChar == '!') || (inChar == ':') || (inChar == ';'));
- }
- public static string ToDude(string inputString, byte wantedVolume)
- {
- if (myDictionary == null)
- Initialize(); // make sure we have a dictionary, or nothing will happen. NOTHING.
- // first, let's split it
- List<string> parsedString = new List<string>();
- List<int> isPunctuation = new List<int>(); // better store these for later
- List<bool> handled = new List<bool>();
- parsedString = inputString.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList(); // dammit c#
- // okay so we were lazy, and need to split off the punctuation
- int counter = 0;
- while (counter < parsedString.Count())
- {
- // we're going to assume the punctuation will be the final character of a string. Makes sense, right?
- if (IsPunctuation(parsedString[counter][parsedString[counter].Length - 1]))
- {
- char punct = parsedString[counter][parsedString[counter].Length - 1];
- parsedString[counter] = parsedString[counter].Remove(parsedString[counter].Length - 1, 1);
- parsedString.Insert(counter + 1, "" + punct);
- isPunctuation.Add(counter + 1);
- counter++;
- }
- counter++;
- }
- // Zhu Li, do the thing!
- bool reCaps;
- for (int i = 0; i < parsedString.Count(); i++)
- {
- handled.Add(false);
- reCaps = Char.IsUpper(parsedString[i][0]);
- parsedString[i] = parsedString[i].ToLower();
- if (myDictionary.ContainsKey(parsedString[i]))
- {
- int found = -1;
- for (int j = 0; j < myDictionary[parsedString[i]].Count(); j++)
- {
- if (wantedVolume >= myDictionary[parsedString[i]][j].startingVolume)
- found = j;
- else
- break;
- }
- if (found > -1)
- {
- handled[i] = true;
- if (myDictionary[parsedString[i]][found].duded.Count() == 1)
- parsedString[i] = myDictionary[parsedString[i]][found].duded[0];
- else
- {
- Random rand = new Random();
- parsedString[i] = myDictionary[parsedString[i]][found].duded[rand.Next(myDictionary[parsedString[i]][0].duded.Count())];
- }
- }
- }
- if (reCaps)
- parsedString[i] = Char.ToUpper(parsedString[i][0]) + parsedString[i].Substring(1);
- }
- // You know what we can do? Put it to eleven.
- if (wantedVolume == 11)
- {
- for (int i = 0; i < parsedString.Count(); i++)
- {
- if (handled[i]) // can't touch this
- continue;
- // do we have a d? And is it not the last letter?
- if (parsedString[i].Contains('d') && (parsedString[i].IndexOf('d') != parsedString[i].Length - 1))
- {
- int dIndex = parsedString[i].IndexOf('d');
- int cutIndex = parsedString[i].IndexOfAny(new char[] { 's', 'c', 'r' }, dIndex + 1); // hard cut letters, fiddle with this
- if (cutIndex == -1)
- parsedString[i] = parsedString[i].Substring(0, dIndex + 1) + "ude";
- else
- {
- if ((cutIndex < parsedString[i].Length - 2) && (parsedString[i][cutIndex + 1] == 'e')) // sneaksie thiefsie
- parsedString[i] = parsedString[i].Substring(0, dIndex + 1) + "ude" + parsedString[i].Substring(cutIndex + 2);
- else
- parsedString[i] = parsedString[i].Substring(0, dIndex + 1) + "ude" + parsedString[i].Substring(cutIndex);
- }
- }
- }
- }
- // okay, now rebuild it. You have the technology.
- string outputString = "";
- for (int i = 0; i < parsedString.Count(); i++)
- {
- if ((i > 0) && (!isPunctuation.Contains(i)))
- outputString += " ";
- outputString += parsedString[i];
- }
- // Time to die.
- return outputString;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment