Code Monkey home page Code Monkey logo

code-challenge's Introduction

DataMade Code Challenge: Parserator

Welcome to the DataMade code challenge! ๐Ÿ‘‹

Your task is to recreate the address parsing form in DataMade's Parserator web service. Parserator can take input strings that represent addresses (like 123 main st chicago il) and split them up into their component parts:

Example of Parserator parsing the string "123 main st chicago il"

In this repo, we've provided the basic scaffolding of the templates, views, and routes that comprise the app. You'll need to flesh out certain code blocks in the frontend and backend code in order to send API requests, process them on the server, and display the results to the user.

You can use vanilla JavaScript or jQuery to complete the JavaScript portions of this assessment.

To get started, fork this repo and follow the instructions below.

Installation

Development requires a local installation of Docker and Docker Compose. These are the only two system-level dependencies you should need.

Once you have Docker and Docker Compose installed, build the application containers:

docker-compose build

Next, run the app:

docker-compose up

The app will log to the console, and you should be able to visit it at http://localhost:8000.

Completing the challenge

Once you have the app up and running on your computer, you'll need to flesh out certain code blocks to complete the parsing interface.

Note: You can use the following address strings for testing during implementation:

  • โœ… Valid: 123 main st chicago il
  • โŒ Invalid: 123 main st chicago il 123 main st

Step 1: Implement the parse method

In parserator_web/views.py, use usaddress to implement the AddressParse.parse() method. It should return two pieces of data:

  • address_components: The parsed address
  • address_type: The type of address provided

Step 2: Complete the API endpoint

In parserator_web/views.py, complete the AddressParse.get() method to return three pieces of data:

  • input_string: The string that the user sent
  • address_components: A dictionary of parsed components that comprise the address, in the format {address_part: tag} (returned by AddressParse.parse())
  • address_type: A string representing type of the parsed address (returned by AddressParse.parse())

Don't forget to handle strings that cannot be parsed and return errors!

Step 3: Wire up the form to send requests to the API

In parserator_web/templates/parserator_web/index.html, fill out the <script> tag in the extra_js block, adding JavaScript code that will use the form to send form data to the API endpoint fleshed out in Step 2.

Step 4: Display results from the API

In parserator_web/templates/parserator_web/index.html, extend the <script> tag in the extra_js block to display results from the API endpoint in the hidden element <div id="address-results">.

Make sure that if the API raises an error, it displays this error to the user.

Step 5: Add unit tests

The tests/ directory contains two stubbed tests. Complete each test by making a request to the API endpoint and verifying that it passes or fails, and returns the expected output.

You can run the tests using Docker:

docker-compose -f docker-compose.yml -f tests/docker-compose.yml run --rm app

Note that, in addition to running the unit tests, the testing script will lint your JavaScript and Python code. Don't forget to fix any linting errors these commands surface!

Not familiar with pytest? Consult our testing guidelines for quick start instructions, plus tips and tricks for testing Django applications.

Step 6: Submit your work

To submit your work, create a feature branch for your code, commit your changes, push your commits up to your fork, and open up a pull request against master. Finally, drop a link to your pull request in your application.

code-challenge's People

Contributors

fgregg avatar hancush avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  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.