private void splitSentence(WordData sentence)
{
string description = sentence.GetDesc();
char[] descriptionArr = description.ToLower().ToCharArray();
int splitLength; //sentence will be split in four parts
int numSpaces = 0;
List<int> spaceIndices = new List<int>();
spaceIndices.Add(0);
for (int i = 0; i < descriptionArr.Length; i++) //find spaces
{
if (char.IsWhiteSpace(descriptionArr[i]))
{
numSpaces++;
spaceIndices.Add(i);
}
}
splitLength = numSpaces / 4;
if (splitLength > 0)
{
int k = 0;
int j;
string str;
for (j=0; j < numSpaces; j = +splitLength)
{
str = new string(descriptionArr, spaceIndices[j], spaceIndices[j + splitLength]);
fragments[k] = str;
k++;
}
str = new string(descriptionArr, spaceIndices[j], descriptionArr.Length);
fragments[3] = str;
}
}