A challenge to display my knowledge in Scala. The purpose of the challenge is to suggest four words based on a keyword.
Note: Check the Test_DE.pdf for more detailed information.
-
What would you change if the list of keywords was much larger (several millions) ? Use Spark that can create more partitions which can benefit from caching (in memory) that will make the app run faster. And also, it can optimization of each transformation and run it in parallel.
-
What would you change if the requirements were to match any portion of the keywords (for example, given the string “pro”, the program could suggest the keyword “reprobe”) ? We can replace
startsWith
withindexOf
orcontains
(which is using justindexOf
)
- Memory: At least 128MB
- Operating System: Any operating system.
- Disk Space: At least 124MB (for JRE) of available disk space.
- Memory: At least 2GB
- Operating System: Linux kernel version 3.10 or higher, Windows x Pro/Ent x64.
- Disk Space: 3GB of available disk space (For docker images and builds).
NOTE: You may find all the details in the following page Docker System requirements
You can follow this link Install Sbt to install Sbt
You can follow this link Install Docker to install Docker
Note: This workshop is tested with Docker Community Edition
17.12.0-ce-win47 (15139), build 9c692cd
onWin 10 Pro Version 1909 Build 18363.720
.
From the root directory of the project, you can:
sbt compile
sbt run --string "project runway,pinterest,river,kayak,progenex,progeria,pg&e,project,free,tv,bank,proactive,progesterone,press,democrat,priceline,pandora,reprobe,paypal" --delimiter "," --keyword "pro"
Note: If you use sbt run without argument you will have an exception thrown with an example of the command that needs to be run with the App.
For example you can try:
sbt run --string "project runway,pinterest,river,kayak,progenex,progeria,pg&e,project,free,tv,bank,proactive,progesterone,press,democrat,priceline,pandora,reprobe,paypal" --delimiter "," --keyword "pro"
And you will get this result displayed in your terminal
proactive
progenex
progeria
progesterone
sbt package
NOTE: sbt package is packaging the project in a JAR file which is a normal Java JAR file.
sbt test
After installing Docker and you want to run the project you can just run the following command:
Note: You should be in root of the folder to execute these commands
You should build the image
docker build -t auto-complete:v0.1 .
Then you can run a container with the image built using:
docker run -e "FILE_PATH=docs/Words.txt" -e "KEYWORD=prog" auto-complete:v0.1
docker run -e "STRING=project runway,pinterest,river,kayak,progenex,progeria,pg&e,project free tv,bank,proactive,progesterone,press democrat,priceline,pandora,reprobe,paypal" -e "DELIMITER=," -e "KEYWORD=prog" auto-complete:v0.1