An application that exposes a REST API to find all the words that can be derived from the combination of an input of letters.
WordFinder requires:
- Spring Context 4.3.12.Release
- Vert.x Web 3.5.0
- Vertx Dependent Verticle Deployer 1.0.1
- Vertx Spring Verticle Factory 1.0.2
- Log4j2 2.6.2
- Slf4j 1.7.21
To build the code maven version 3 and java 8 JDK are necessary.
On the command line execute:
mvn clean package
The output of this build is found in the target directory
On the command line execute:
mvn clean verify
-
Locate the zip file generated by the build (target/wordfinder-kit.zip) and decompress.
-
Change directory to where the zip file was decompressed. We'll call this directory
$WFD$ .
NOTE The configuration properties (config.properties) for the application can be found in the
The application relies on several inputs for its normal execution:
-
The file with the english words to be loaded (NOTE: If a word contains characters different from the range a-z and A-Z, those characters will be ignored).
The application includes by default a file in the config directory named english_words.txt. The contents of this file are taken from http://www-01.sil.org/linguistics/wordlists/english/wordlist/wordsEn.txt.
If a different file is needed, modify the config.properties file property words.location. The value should be a location that it is accessible from within the running application. Because this property feeds a SpringFramework resource it needs to denote a valid resource. Its default value is classpath:english-words.txt
-
The points for letters. This is configured using the letter.points property within the config.properties. This is a JSON-coded string. Its default value is:
{
"aeilnorstu" : 1,
"dg" : 2,
"bcmp": 3,
"fhvwy" : 4,
"k" : 5,
"jx" : 8,
"qz" : 10
}
-
The host to be used for the REST server. This is configured using the rest.server.host. Default value is localhost
-
The port where the REST server will listen. This is configured using the rest.server.port. Default value is 8080
NOTE Changes to the config.properties made will only take effect the next time the application is executed.
NOTE For usability, files found within the
-
Change directory to
$WFD$ -
Locate the wordfinder.sh shell script. Make sure its executable flag(s) is(are) set.
-
Run the script from the command line:
> ./wordfinder.sh
This GET method accepts one or more letters (regardless of case) to find all the possible combination of valid words.
It responds back with a JSON array of words (content-type : application/json).
Examples:
-
Open your browser and point to http://localhost:8080/words/hat
This will return
["hat","ah","ha","th","at","a"]
-
Open your browser and point to http://localhost:8080/words/zzz
This will return
[]
NOTE The search is not case sensitive to the input :letters and the characters in :letters not corresponding to the range 'a'-'z' and 'A'-'Z' will be ignored