Exemplo n.º 1
0
        public override bool Equals(System.Object obj)
        {
            // If parameter is null return false.
            if (obj == null)
            {
                return(false);
            }

            // If parameter cannot be cast to Point return false.
            MarkovWord p = obj as MarkovWord;

            if ((System.Object)p == null)
            {
                return(false);
            }

            // Return true if the fields match:
            return((Text == p.Text) && (POS == p.POS));
        }
Exemplo n.º 2
0
        private void AnalyzeButton_Click(object sender, EventArgs e)
        {
            Dictionary <MarkovKey, Dictionary <MarkovWord, int> > wordDict = new Dictionary <MarkovKey, Dictionary <MarkovWord, int> >(new MarkovKeyEqualityComparer());
            int wordOrder = 2;

            wordDict = BuildWordDict(InputBox.Text, wordOrder);
            wordDict = BuildWordDict(InputBox2.Text, wordDict, wordOrder);

            int           outputLength = 1000;
            StringBuilder chain        = new StringBuilder("");

            System.Random r = new System.Random();
            // string currentWords[] = new string[]{ "In", "a" };
            Queue <MarkovWord> currentWords = new Queue <MarkovWord>();

            for (int i = 0; i < wordOrder; i++)
            {
                currentWords.Enqueue(wordDict.ElementAt(0).Key.Words.ElementAt(i));
            }

            for (int i = 0; i < outputLength; i++)
            {
                MarkovWord dequeuedItem = currentWords.Dequeue();
                chain.Append(dequeuedItem.Text + " ");
                MarkovKey newKey = new MarkovKey(new List <MarkovWord>());
                newKey.Words.Add(dequeuedItem);
                for (int j = 0; j < wordOrder - 1; j++)
                {
                    newKey.Words.Add(currentWords.ElementAt(j));
                }

                currentWords.Enqueue(RetrieveRandomWord(wordDict[newKey], r));
            }

            OutputBox.Text = chain.ToString();

            //Stanford.NLP.CoreNLP.CSharp.TaggerDemo.TagText(InputBox.Text);
        }
Exemplo n.º 3
0
 public bool Equals(MarkovWord x)
 {
     return((x.Text == Text) && (x.POS == POS));
 }