Speed up processing large automata

Large automata, specifically those that contain repetitions after
non-deterministic matches consumed a ton of space and time to generate
ngrams for.  On my laptop <<[^]]*alt=[^]\\|}]{10,20}>> took 56 seconds.
With this patch it take .25 seconds.

The core of the change is to simplify the expression as you process the
ngram automaton rather than create a huge mess and simplify it later.

Change-Id: Idfb0c55ef2d49fbe7b11d5951febdf1d0e7e3613