Beispiel #1
0
        static void loadBrain()
        {
            if (!File.Exists("kirkBrain.txt"))
            {
                File.Create("kirkBrain.txt");
            }
            else
            {
                string[] synapse = System.IO.File.ReadAllLines("kirkBrain.txt");
                string[] loadWord;
                foreach (string s in synapse)
                {
                    loadWord = s.Split(' ');
                    Word word = new Word();
                    associatedWords.Add(word);
                    word.Keyword = loadWord[0];
                    word.End =bool.Parse(loadWord[1]);
                    word.Start = bool.Parse(loadWord[2]);
                    int start = 0;
                    for (int i = 3; i < loadWord.Length; i++)
                    {
                        word.postwords.Add(loadWord[i].Substring(0, loadWord[i].IndexOf('(')));
                        start = loadWord[i].IndexOf('(') + 1;
                        word.occuranceCount.Add(int.Parse(loadWord[i].Substring(start,1)));

                    }
                }
            }
        }
Beispiel #2
0
        static void KIRKparse(string input)
        {
            int[] found = new int[2];
            if (input == "")
            {

            }
            else
            {
                string[] words = input.Split(' ');
                for (int i = 0; i < words.Length; i++)
                {
                    words[i] = RemoveSpecialCharacters(words[i]);
                }
                for (int j = 0; j < words.Length; j++)
                {
                    found[0] = int.MaxValue;
                    found[1] = int.MaxValue;

                    if (j < (words.Length - 1))
                    {
                        found = wordcatalogued(words[j], words[j + 1]);
                    }
                    else
                    {
                        found = wordcatalogued(words[j], "~");
                    }

                    if (found [0] < int.MaxValue && found[1] < int.MaxValue)
                    {
                        associatedWords[found[0]].occuranceCount[found[1]]++;
                        if (j == 0)
                        {
                            associatedWords[found[0]].Start = true;
                        }
                    }
                    else if (found[0] < int.MaxValue && j >= words.Length - 1)
                    {
                        associatedWords[found[0]].End = true;
                    }
                    else if (found[0]< int.MaxValue)
                    {
                        associatedWords[found[0]].postwords.Add(words[j + 1]);
                        associatedWords[found[0]].occuranceCount.Add(1);
                        associatedWords[found[0]].End = false;
                        if (j == 0)
                        {
                            associatedWords[found[0]].Start = true;
                        }

                    }
                    else
                    {
                        Word word = new Word();
                        associatedWords.Add(word);
                        word.Keyword = words[j];
                        if (j == 0)
                        {
                            word.Start = true;
                        }
                        if (j < (words.Length - 1))
                        {
                            if (words[j + 1] != "")
                            {
                                word.postwords.Add(words[j + 1]);
                                word.occuranceCount.Add(1);
                            }
                        }
                        else
                        {
                            word.End = true;
                        }
                    }
                }
            }
        }