Skip to content

An application that exposes a REST API to find words from an input of letters

License

Notifications You must be signed in to change notification settings

juanavelez/wordfinder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WordFinder

An application that exposes a REST API to find all the words that can be derived from the combination of an input of letters.

Dependencies

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

Required Software

To build the code maven version 3 and java 8 JDK are necessary.

Building the application

On the command line execute:

mvn clean package

The output of this build is found in the target directory

Running tests

On the command line execute:

mvn clean verify

Installing the application

  • 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$.

Configuring the application

NOTE The configuration properties (config.properties) for the application can be found in the $WFD$/config folder.

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.

Running the application

NOTE For usability, files found within the $WFD$/config folder are part of the classpath.

  • 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

Exposed REST methods

GET words/:letters

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:

["hat","ah","ha","th","at","a"]
[]

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

About

An application that exposes a REST API to find words from an input of letters

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published