kalexmills / stochrammar

Stochastic grammar library implemented in Java.
GNU Affero General Public License v3.0
0 stars 0 forks source link

Cleanup Design by removing act() from GrammarToken and pass in a FunctionalInterface. #7

Open kalexmills opened 6 years ago

kalexmills commented 6 years ago

Right now, the GrammarToken allows users to define (a) the means by which a token replaces itself and (b) the way in which a token acts on an entity.

At the time of this writing, implementing classes must define both operations in the same class. This is inherently inflexible, and inhibits code-reuse.

To resolve the problem, GrammarTokens should define the way in which a token replaces itself. Rather than inheriting the act method, users should be able to pass an act method to a GrammarToken as a higher-order-function.

This change would allow stochrammar to include provide several standard GrammarToken implementations for different ways of replacing tokens with other tokens, along with unified APIs on top of them.