Thank you. This is exactly I want. Are you sure that building this way would be 'optimal' for 1000s of types? I like to generate common pattern of informative sentences from millions of sentences.
i am not at all sure it is the optimal solution, just one way to do it. it could surely be optimized for speed and/or memory consumption, typically one at the expense of the other. good luck! :-)