Given a list of sentences build a suggestion engine, where if we provide an input word it returns the most frequent next word from the input list.
For Example:
[
["Alice", "jumped", "into", "the", "hole"],
["A", "rabbit", "jumped", "into", "the", "hole"],
["The", "king", "sent", "forth", "his", "troops"],
.....
]
In this particual example if "the" is the input word, the suggestion should be "hole" because, ["the", "hole"] appeared twice in the list of sentences where as ["the", "king"] appeared only once.
If "hole" is the input we return empty string because no suggestion exists.
Any suggestions on how to do this ?