Reducing memory requirements and computational costs for the baum-welch algorithm and application to automatic stochastic network grammar acquisition