Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Sylabizator.Sylabizator sylabizator = new Sylabizator.Sylabizator();

            //findAllEnglishSentences(100);
            //findAllPolishSentences(12);
            //cutStrangeWords();

            Nodev2 root = new Nodev2(' ');

            root.createGraph();
            root.teach();
            string[] results = new string[100];
            for (int i = 0; i < 100; i++)
            {
                results[i] = root.generateNewWord();
                Console.WriteLine("{0}", results[i]);
            }

            Console.Write("\n");

            SentenceNode sentenceRoot = new SentenceNode("NULL", sylabizator);

            //sylabizator.Model.updateLanguage(Sylabizator.SylabizatorLanguage.Polish);
            sentenceRoot.teach("english_sentences.txt");

            for (int i = 0; i < 100; i++)
            {
                Console.WriteLine("{0}", sentenceRoot.generateNewSentence());
            }

            Console.Write("\n");

            //sentenceRoot.teachRandomWords("strange_words.txt", 50);

            //List<string> poem = sentenceRoot.generatePoem(4, 15, 4);
            List <string> poem = sentenceRoot.generatePoem(8, 7, 2);

            //List<string> poem = sentenceRoot.generatePoem(9, 4, 3);
            //List<string> poem = sentenceRoot.generatePoem(24, 3, 2);

            Console.Write("\n\n");
            for (int i = 0; i < poem.Count; i++)
            {
                Console.WriteLine(poem[i]);
            }

            Console.WriteLine("\nFinished.");
            Console.ReadKey();
            return;
        }
Ejemplo n.º 2
0
        public static string[] Syllables(this string s, Sylabizator.Sylabizator sylabizator)
        {
            // Zwracana listę sylab słowa.
            // Jan Grzywacz.
            List <string> wrapper = new List <string> {
                s
            };
            List <string> tmp = sylabizator.divideIntoSyllables(wrapper, false);

            string[] syllables = tmp[0].Split(new char[] { '-' });

            /*Console.WriteLine("");
             * for (int i = 0; i < syllables.Length; i++) Console.WriteLine(syllables[i]);*/

            return(syllables);
        }
Ejemplo n.º 3
0
        // Klasa tworząca zdania ze słów, na takiej samej zasadzie jak NodeV2.
        // Jedyna różnica jest taka, że liczby i suma wszystkich słów potomnych
        // przechowywana jest w węźle, który je posiada - nie w jego dzieciach.
        // Jan Grzywacz.

        public SentenceNode(string word, Sylabizator.Sylabizator sylabizator)
        {
            // Tworzymy pustą listę słów, która
            // będzie wypełniana podczas uczenia.
            // Jan Grzywacz.

            children = new List <SentenceNode>();
            marked   = new List <bool>();
            counters = new List <int>();

            if (word != "NULL")
            {
                children.Add(new SentenceNode("NULL", sylabizator));
                counters.Add(0);
                marked.Add(false);
            }

            this.sylabizator = sylabizator;
            this.word        = word;
            this.total       = 0;
        }