Exemplo n.º 1
0
        /// <summary>
        /// TODO: Cleanup Duplcation
        /// </summary>
        /// <param name="tokens"></param>
        public void AddTokens(List <string> tokens)
        {
            for (int i = 0; i + 1 < tokens.Count; i++)
            {
                var existingNode   = Nodes.FirstOrDefault(n => n.Data.Equals(tokens[i]));
                var connectionNode = Nodes.FirstOrDefault(n => n.Data.Equals(tokens[i + 1])) ?? new MarkovNode(tokens[i + 1]);

                if (existingNode == null)
                {
                    var newNode = new MarkovNode(tokens[i]);
                    newNode.AddConnection(new MarkovEdge(1.0, connectionNode));
                    Nodes.Add(newNode);
                }
                else
                {
                    existingNode.AddConnection(new MarkovEdge(1.0, connectionNode));
                }
            }
        }
Exemplo n.º 2
0
 public bool IsConnectedTo(MarkovNode node)
 {
     return(node == TargetNode);
 }
Exemplo n.º 3
0
 public MarkovEdge(double probability, MarkovNode target)
 {
     Probability = probability;
     TargetNode  = target;
 }