GithubHelp home page GithubHelp logo

spellchecker's Introduction

#Spellchecker

Spell checker service composed by server and client.

(This project was developed in 2014, it won't work if the WordReference API changes)

##Requirements

The server exposes two simple methods:

  • check(language,word):boolean
  • add(language, word):boolean

The client has only a command line interface. When started you are required to provide the name of file to parse. During the parsing phase if a word is not recognized by the server you have two choices: add the word to the common repository or discard it and carry on with the parsing. When the file has been completely parsed the client shows how many words are not valid and the list of them.

Client and server are going to be deployed in different locations. You can decide which type of communication has to be implemented between client and server, however the data exchanged between them has to be maintained as low as possible.

Spring framework can't be used to implement this solution.

##Solution

  • Created three maven projects, httpclient, encapsulating HTTP communication, spellchecker and spellcheckerClient
  • The server has been developed using the Spark framework (http://www.sparkjava.com/). It contains a jetty server embedded, this way it's not necessary to package the application and deploy it in a WAS. It can be executed as a simple Java application, and exposes the two methods.
  • The methods have been published as REST Web Services. This changes a bit the value they can return, and it's not a boolean anymore. Of course, if everything is OK they return the status 200, but depending on the service, the other return values differ, between 404 (NOT FOUND) for the check service or 409 (CONFLICT) for the add service. It's a conflict because you can't add a word that already exists in the repository. The services also return a JSON in the responseBody with additional information.
  • To check the validity of the words, I have used the WordReference API (http://www.wordreference.com/docs/api.aspx). I had to create a personal account and use an API key. The problem with this API is that it's limited to 600 requests per hour, so if you test the application several times in a row it can fail.
  • To manage the http communication Client <-> Server <-> WordReference, I have used the Apache HttpClient API
  • I assume that there can't be no hyphens at the end of the lines in the file, so every line only contains full words
  • If the user decides to add a word that doesn't exist in WordReference to the repository, that word becomes a valid word
  • No unit tests, sorry, just playing around :)
  • No logging API. To report errors the applications use the standard output.

##Execution

Finally, to execute the applications, you can run them using an IDE, or using maven:

Server: mvn compile exec:java -Dexec.mainClass="com.raulavila.spellchecker.server.SpellCheckerServer"

Client: mvn compile exec:java -Dexec.mainClass="com.raulavila.spchclient.client.SpellCheckerClient"

Note that httpclient project must be installed in the local repository previous to the execution of the projects.

spellchecker's People

Contributors

raulavila avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.