/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Syllabizator;

import java.util.HashMap;
import java.util.Map;

/**
 *
 * @author Jarek
 */
public class Net
{
    private Map <String,Node> occuredSyllables;
    
    public Net()
    {
        this.occuredSyllables = new HashMap<String,Node>();
    }
    
    public void add(String s,String pre)
    {
        Node n = this.occuredSyllables.get(s);
        if(n != null && pre != null)
        {
            this.occuredSyllables.get(pre).add(n);
        }
        else if(n == null && pre != null)
        {
            Node newNode = new Node(s);
            this.occuredSyllables.put(s, newNode);
            this.occuredSyllables.get(pre).add(newNode);
        }
        else if(n == null && pre == null)
        {
            Node newNode = new Node(s);
            this.occuredSyllables.put(s, newNode);
        }
        else
        {
            //TODO: add counter incremet?
        }
    }
}

@@ -257,16 +257,42 @@
 il.Map;%0D
+%0Aimport java.util.Random;%0D
 %0A%0D%0A/**%0D%0A
@@ -388,16 +388,45 @@
 ables;%0D%0A
+    private int nWords = 0;%0D%0A
     %0D%0A  
@@ -1034,32 +1034,73 @@
 = new Node(s);%0D%0A
+            newNode.incrementCounter();%0D%0A
             this
@@ -1147,88 +1147,1014 @@
     
-%7D%0D%0A        else%0D%0A        %7B%0D%0A            //TODO: add counter incremet?%0D%0A        %7D
+    nWords++;%0D%0A        %7D%0D%0A        else if(n != null && pre == null)%0D%0A        %7B%0D%0A            n.incrementCounter();%0D%0A            nWords++;%0D%0A        %7D%0D%0A    %7D%0D%0A    %0D%0A    public void setUnconditionalProbs()%7B%0D%0A        double distribution = 0, tmp;%0D%0A        for (Node sylNode : occuredSyllables.values()) %7B%0D%0A            tmp = (double)sylNode.getNStartingNodes() / nWords;%0D%0A            distribution += tmp;%0D%0A            sylNode.setStartingNodeCDF(distribution);%0D%0A        %7D%0D%0A    %7D%0D%0A    %0D%0A    public void setConditionalProbs()%7B%0D%0A        for (Node sylNode : occuredSyllables.values())%7B%0D%0A               sylNode.setConditionalProbs();%0D%0A        %7D   %0D%0A    %7D%0D%0A    %0D%0A    public Node getFirstSyllable()%7B%0D%0A        Random gen = new Random();%0D%0A        double rand = gen.nextDouble();%0D%0A        Node last = null;%0D%0A        for (Node sylNode : occuredSyllables.values())%7B%0D%0A            if (rand %3C= sylNode.getStartingNodeCDF())%0D%0A                return sylNode;%0D%0A            last = sylNode;%0D%0A        %7D%0D%0A        %0D%0A        return last;
 %0D%0A  

Update Net.java