public List<customMatchObject> getPermutations(string questionLeft)
{
//Trimming the string
questionLeft = questionLeft.Trim();
//Removing Extra spaces
while (questionLeft.Contains(" "))
questionLeft = questionLeft.Replace(" ", " ");
//Creating the new list of objects that would be returned
List<customMatchObject> listObject = new List<customMatchObject>();
//The list of string that holds all permutations of the input string
List<string> toReturn = new List<string>();
//parsing the input string
List<string> input = new List<string>();
input = questionLeft.Split(' ').ToList<string>();
//holds the temporary constructed string
string temp = "";
string temponeWord = "";
string tempUScore = "";
//list holds the words used to generate a certain permutation
List<string> wordsUsed = new List<string>();
//The core algorithm to generate permutations
for (int j = 1; j <= input.Count; j++)//Size of word
{
for (int k = 0; k < (input.Count - (j - 1)); k++) //offset
{
for (int l = k; l < (j + k); l++)
{
temp += input[l] + " ";
temponeWord += input[l];
tempUScore += input[l] + "_";
wordsUsed.Add(input[l]);
}
//add the generated strigns to the list and return it
customMatchObject tempobj1 = new customMatchObject();
tempobj1.wordsUsed = wordsUsed.Distinct().ToList<string>(); ;
tempobj1.word = temp.Remove(temp.Length - 1);
tempobj1.separator = " ";
listObject.Add(tempobj1);
customMatchObject tempobj2 = new customMatchObject();
tempobj2.wordsUsed = wordsUsed.Distinct().ToList<string>(); ;
tempobj2.word = temponeWord;
tempobj2.separator = "";
listObject.Add(tempobj2);
customMatchObject tempobj3 = new customMatchObject();
tempobj3.wordsUsed = wordsUsed.Distinct().ToList<string>();
tempobj3.word = tempUScore.Remove(temp.Length - 1);
tempobj3.separator = "_";
listObject.Add(tempobj3);
//resetting the variables again
temp = "";
tempUScore = "";
temponeWord = "";
wordsUsed = new List<string>();
}
}
return listObject;
}