GetDesc() public method

public GetDesc ( ) : string
return string
    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;
        }
    }
Beispiel #2
0
    public string FindMatchingText(WordData wd)
    {
        string description = wd.GetDesc();
        string word = wd.GetWord();
        char[] descriptionArr = description.ToLower().ToCharArray();
        char[] wordArr = word.ToLower().ToCharArray();

        for (int i = 0; i < descriptionArr.Length; i++)
        {
            if (CheckCurrentIndex(i, descriptionArr, wordArr))
            {
                return addBeginEnd(i, description, word);
            }
        }
        return description.Insert(0, beginWord + word + endWord + "\n");
    }