Skip to content

lhvubtqn/predictive-text

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Predictive Text

Check if a word is in a dataset and get suggestions for it.

Problem

Given a set of files, each file contains multiple words. With a given word, decide whether it is in datasets or not. Give suggestions (words that similar) for that word.

Solution

I decide to use an data structure to store datasets and handle user's requests. Let's call it Dictionary.

Dictionary is an interface. I implement TrieDict.scala as it direct child class. It uses Trie as the data structure for storing datasets and handling requests.

I also implement TwoDataStructuresDict.scala, a child class of Dictionary. It contains two data structures, Searcher and Suggester, the former is used to check if a word is in the datasets or not, the latter it used to get suggestions for that word.

For TwoDataStructuresDict to get Searcher and Suggester at run-time, I use a Design Pattern called Dependency Injection, that is implemented after interface ServiceInjector. That ServiceInjector will inject specific Searcher and Suggester to TwoDataStructuresDict.

For more detail, see the diagram below:

Class Diagram

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages