I need to be able to process one word or words and verify that it has valid syllables. There are some syllabification rules that could be used:
V CV VC CVC CCV CCCV CVCC
where V is a vowel and C is a consonant. e.g.,
pronunciation (5 Pro-nun-ci-a-tion; CCV-CVC-CV-V-CVC)
Or is there a simple code that can be used, or a library in c++? In class we’re talking about binary search trees, hash tables, etc, but i can’t really see the relation. Any help would appreciated, thanks.
Whenever we have collected a full pattern-string, we can either discard it and begin collecting to a new pattern-string, or keep it and try to get a longer pattern-string. We don’t know in advance (without examining the rest of the input-string), whether we should keep or discard the current string, so we need to keep both possibilities in mind.
We can build a state machine that can keep track of this for us. The base-states are identified by the sequence of characters we have examined so far:
Since we don’t always know which action to take, we can be in several possible states at once. Those sets of possible states form super-states:
The transitions are between super-states. Each member of the super-state is advanced with the same symbol. All members without such transition are discarded. If a member has two possible destinations, both are added to the new super-state.
You might notice that some rows are very similar. Super-state 3 and 7 have the same transitions. As are 6 and 11, and 8 and 13. You could collapse those into one state each, and update the indices. I’m not going to demonstrate that here.
This could easily be encoded into a programming language:
Example: