Esempio n. 1
0
        public Chain()
        {
            links = new Dictionary <string, ChainLink>();
            ChainLink link = new ChainLink("", null);

            Console.WriteLine(link);
            links.Add(link.Token, link);
        }
Esempio n. 2
0
        private void generateOutput()
        {
            ChainLink link = chain.getFirstLink();

            output.Write(link.Token + " ");
            for (int i = 0; i < average; i++)
            {
                link = link.getNextLink();
                output.Write(link.Token + " ");
                if (i % 6 == 0)
                {
                    output.Write("\n");
                }
            }
        }
Esempio n. 3
0
 public void AddLink(ChainLink link)
 {
     //if (Token == "")
     //return;
     if (nextLinks.ContainsKey(link.Token))
     {
         linkOcurences[link.Token] = linkOcurences[link.Token] + 1;
     }
     else
     {
         nextLinks.Add(link.Token, link);
         linkOcurences.Add(link.Token, 1);
         linkProbability.Add(link.Token, 0.0);
     }
     linkCount++;
     updateProbability();
 }
Esempio n. 4
0
 public ChainLink(string token, ChainLink endLink)
 {
     this.Token      = token;
     nextLinks       = new Dictionary <string, ChainLink>();
     linkOcurences   = new Dictionary <string, int>();
     linkProbability = new Dictionary <string, double>();
     if (endLink != null)
     {
         nextLinks.Add(endLink.Token, endLink);
         linkOcurences.Add(endLink.Token, 1);
         linkProbability.Add(endLink.Token, 1.0);
         linkCount = 1;
     }
     else
     {
         linkCount = 0;
     }
 }
Esempio n. 5
0
 public void AddLink(string prevToken, string newToken)
 {
     //Console.WriteLine("prevToken: " + prevToken);
     //Console.WriteLine("newToken: " + newToken);
     if (links.ContainsKey(prevToken))
     {
         if (links.ContainsKey(newToken))
         {
             links[prevToken].AddLink(links[newToken]);
         }
         else
         {
             ChainLink link = new ChainLink(newToken, null);
             links.Add(link.Token, link);
             links[prevToken].AddLink(link);
         }
     }
     else
     {
         throw new Exception();
     }
 }