Guest User

Untitled

a guest
Jun 25th, 2018
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.22 KB | None | 0 0
  1. // Dudinator 1999 by Turfster
  2. // pretty much made for @glassbottommeg
  3.  
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8.  
  9. namespace Dudinator
  10. {
  11. public struct Duderism
  12. {
  13. public byte startingVolume; // the lowest 'volume' we want this to start matching
  14. public List<string> duded; // the thing(s) to replace it with, list for random support, just in case
  15.  
  16. public Duderism(byte sV, string s)
  17. {
  18. startingVolume = sV;
  19. duded = new List<string>();
  20. duded.Add(s);
  21. }
  22.  
  23. public Duderism(byte sV, List<string> ls)
  24. {
  25. startingVolume = sV;
  26. duded = new List<string>(ls);
  27. }
  28. }
  29.  
  30. // fuck it, let's go static, since we don't want to do the whole dictionary thing every time
  31. public static class Dudinator1999
  32. {
  33.  
  34. // 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
  35. // yes this is total overkill for most stuff, but eh
  36. // also, please add the tiered list in order
  37. static Dictionary<string, List<Duderism>> myDictionary;
  38.  
  39. public static void Initialize()
  40. {
  41. // fill the dictionary
  42. myDictionary = new Dictionary<string, List<Duderism>>();
  43. myDictionary.Add("he", new List<Duderism> { new Duderism(1, "the dude") });
  44. myDictionary.Add("she", new List<Duderism> { new Duderism(1, "the dude") });
  45. myDictionary.Add("it", new List<Duderism> { new Duderism(5, "the dude") });
  46. myDictionary.Add("his", new List<Duderism> { new Duderism(3, "dude's") });
  47. myDictionary.Add("her", new List<Duderism> { new Duderism(3, "dude's") });
  48. myDictionary.Add("its", new List<Duderism> { new Duderism(3, "the dude's") });
  49. myDictionary.Add("it's", new List<Duderism> { new Duderism(3, "dude's") });
  50.  
  51. myDictionary.Add("guys", new List<Duderism> { new Duderism(8, "dudes") });
  52. myDictionary.Add("girls", new List<Duderism> { new Duderism(8, "dudes") });
  53. myDictionary.Add("people", new List<Duderism> { new Duderism(8, "dudes") });
  54.  
  55. myDictionary.Add("totally", new List<Duderism> { new Duderism(2, "totes") });
  56.  
  57. myDictionary.Add("dog", new List<Duderism> { new Duderism(3, "good dude") });
  58. myDictionary.Add("dogs", new List<Duderism> { new Duderism(3, "good dudes") });
  59. myDictionary.Add("cat", new List<Duderism> { new Duderism(3, "li'l dude") });
  60. myDictionary.Add("cats", new List<Duderism> { new Duderism(3, "li'l dudes") });
  61.  
  62. /*// with random options
  63. myDictionary.Add("cool", new List<Duderism> { new Duderism(4, new List<string>{ "radical", "tubular", "gnarly" }) });
  64. myDictionary.Add("great", new List<Duderism> { new Duderism(6, new List<string> { "radical", "tubular", "gnarly" }) });
  65. myDictionary.Add("amazing", new List<Duderism> { new Duderism(7, new List<string> { "radical", "tubular", "gnarly" }) });
  66. myDictionary.Add("awesome", new List<Duderism> { new Duderism(5, new List<string> { "radical", "tubular", "gnarly" }) });
  67. myDictionary.Add("crazy", new List<Duderism> { new Duderism(6, new List<string> { "radical", "tubular", "gnarly" }) });
  68. */
  69. // without random options, but with a tiered list per word
  70. myDictionary.Add("cool", new List<Duderism> { new Duderism(4, "radical"), new Duderism(6, "tubular"), new Duderism(9, "gnarly") });
  71. myDictionary.Add("great", new List<Duderism> { new Duderism(4, "radical"), new Duderism(6, "tubular"), new Duderism(9, "gnarly") });
  72. myDictionary.Add("amazing", new List<Duderism> { new Duderism(4, "radical"), new Duderism(6, "tubular"), new Duderism(9, "gnarly") });
  73. myDictionary.Add("awesome", new List<Duderism> { new Duderism(4, "radical"), new Duderism(6, "tubular"), new Duderism(9, "gnarly") });
  74. myDictionary.Add("crazy", new List<Duderism> { new Duderism(4, "radical"), new Duderism(6, "tubular"), new Duderism(9, "gnarly") });
  75.  
  76.  
  77. myDictionary.Add(".", new List<Duderism> { new Duderism(5, ", dude.") });
  78. myDictionary.Add("?", new List<Duderism> { new Duderism(5, ", dude?") });
  79. myDictionary.Add("!", new List<Duderism> { new Duderism(11, " *air guitar solo*") });
  80.  
  81. // are these more valley girl than dude? idk, I only speak Californian by way of 90s movies
  82. myDictionary.Add("if", new List<Duderism> { new Duderism(10, "if, like,") });
  83. myDictionary.Add("or", new List<Duderism> { new Duderism(10, "or, like,") });
  84. myDictionary.Add("and", new List<Duderism> { new Duderism(10, "and, like,") });
  85. }
  86.  
  87. public static string ToDude(string inputString)
  88. {
  89. return ToDude(inputString, 2); // the "neutral" default?
  90. }
  91.  
  92. static bool IsPunctuation(char inChar)
  93. {
  94. return ((inChar == '.') || (inChar == ',') || (inChar == '?') || (inChar == '!') || (inChar == ':') || (inChar == ';'));
  95. }
  96.  
  97. public static string ToDude(string inputString, byte wantedVolume)
  98. {
  99. if (myDictionary == null)
  100. Initialize(); // make sure we have a dictionary, or nothing will happen. NOTHING.
  101.  
  102. // first, let's split it
  103. List<string> parsedString = new List<string>();
  104. List<int> isPunctuation = new List<int>(); // better store these for later
  105. List<bool> handled = new List<bool>();
  106.  
  107. parsedString = inputString.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList(); // dammit c#
  108. // okay so we were lazy, and need to split off the punctuation
  109. int counter = 0;
  110. while (counter < parsedString.Count())
  111. {
  112. // we're going to assume the punctuation will be the final character of a string. Makes sense, right?
  113. if (IsPunctuation(parsedString[counter][parsedString[counter].Length - 1]))
  114. {
  115. char punct = parsedString[counter][parsedString[counter].Length - 1];
  116. parsedString[counter] = parsedString[counter].Remove(parsedString[counter].Length - 1, 1);
  117. parsedString.Insert(counter + 1, "" + punct);
  118. isPunctuation.Add(counter + 1);
  119. counter++;
  120. }
  121. counter++;
  122. }
  123.  
  124. // Zhu Li, do the thing!
  125. bool reCaps;
  126. for (int i = 0; i < parsedString.Count(); i++)
  127. {
  128. handled.Add(false);
  129. reCaps = Char.IsUpper(parsedString[i][0]);
  130. parsedString[i] = parsedString[i].ToLower();
  131. if (myDictionary.ContainsKey(parsedString[i]))
  132. {
  133. int found = -1;
  134. for (int j = 0; j < myDictionary[parsedString[i]].Count(); j++)
  135. {
  136. if (wantedVolume >= myDictionary[parsedString[i]][j].startingVolume)
  137. found = j;
  138. else
  139. break;
  140. }
  141. if (found > -1)
  142. {
  143. handled[i] = true;
  144. if (myDictionary[parsedString[i]][found].duded.Count() == 1)
  145. parsedString[i] = myDictionary[parsedString[i]][found].duded[0];
  146. else
  147. {
  148. Random rand = new Random();
  149. parsedString[i] = myDictionary[parsedString[i]][found].duded[rand.Next(myDictionary[parsedString[i]][0].duded.Count())];
  150. }
  151. }
  152. }
  153. if (reCaps)
  154. parsedString[i] = Char.ToUpper(parsedString[i][0]) + parsedString[i].Substring(1);
  155. }
  156.  
  157. // You know what we can do? Put it to eleven.
  158. if (wantedVolume == 11)
  159. {
  160. for (int i = 0; i < parsedString.Count(); i++)
  161. {
  162. if (handled[i]) // can't touch this
  163. continue;
  164.  
  165. // do we have a d? And is it not the last letter?
  166. if (parsedString[i].Contains('d') && (parsedString[i].IndexOf('d') != parsedString[i].Length - 1))
  167. {
  168. int dIndex = parsedString[i].IndexOf('d');
  169. int cutIndex = parsedString[i].IndexOfAny(new char[] { 's', 'c', 'r' }, dIndex + 1); // hard cut letters, fiddle with this
  170. if (cutIndex == -1)
  171. parsedString[i] = parsedString[i].Substring(0, dIndex + 1) + "ude";
  172. else
  173. {
  174. if ((cutIndex < parsedString[i].Length - 2) && (parsedString[i][cutIndex + 1] == 'e')) // sneaksie thiefsie
  175. parsedString[i] = parsedString[i].Substring(0, dIndex + 1) + "ude" + parsedString[i].Substring(cutIndex + 2);
  176. else
  177. parsedString[i] = parsedString[i].Substring(0, dIndex + 1) + "ude" + parsedString[i].Substring(cutIndex);
  178. }
  179. }
  180. }
  181. }
  182.  
  183. // okay, now rebuild it. You have the technology.
  184. string outputString = "";
  185. for (int i = 0; i < parsedString.Count(); i++)
  186. {
  187. if ((i > 0) && (!isPunctuation.Contains(i)))
  188. outputString += " ";
  189. outputString += parsedString[i];
  190. }
  191.  
  192. // Time to die.
  193. return outputString;
  194. }
  195. }
  196. }
Advertisement
Add Comment
Please, Sign In to add comment