Giter VIP home page Giter VIP logo

anagram-server's Introduction

Build Status

Welcome to AnagramServer

AnagramServer is a web server that provides an API to load words into a data store and find their anagrams. In addition, the API provides routes to remove words, clear the data store, and show statistics about the words.

Routes

  • GET /: Returns HTML. This is the main route for interacting with the application.
  • POST /words.json: Takes a JSON array of words and adds them to the corpus (data store).
  • GET /anagrams/:word.json:
    • Returns a JSON array words that are anagrams of the word passed in the URL.
    • Supports an optional query param that indicates the maximum number of results to return.
  • DELETE /words/:word.json: Deletes a single word from the data store.
  • DELETE /words.json: Deletes all contents of the data store.
  • GET /stats: Returns a JSON object specifying the count of words in the corpus and min/max/median/average word length
  • GET /most: Returns a JSON object that identifies alphagrams in the corpus with the most anagrams

Build Instructions

  1. Download and install Python 3.5
  2. Clone this repository to your machine
  3. Open a terminal and change into the root of the repository
  4. Install virtualenv pip install virtualenv
  5. Create a virtual environment virtualenv venv
  6. Activate the virtual environment source venv/bin/activate
  7. Install Dependencies pip install -r requirements.txt

Running the server

  • Run python start_server.py

Running the tests

  • Run python scripts/run_tests.py

Adding the English dictionary to the corpus

  1. Make sure the server is running
  2. Run python scripts/populate_corpus.py

Implementation Details

The server is written in Python and uses Flask as a web framework.

The data store is an in-memory hash table where the key is an alphagram and the value is a set of words that map to that alphagram.

For example, the alphagram "dgo" maps to a set containing the words "dog" and "god".

The hash table makes anagram lookups easy. To find an anagram for a word the server simply finds its alphagram, looks it up in the hash table, and returns the corresponding set.

anagram-server's People

Contributors

adrielklein avatar

Stargazers

AKA avatar

Watchers

James Cloos 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.