Programming Project 5

This semester you will be writing a program that models elements of recognizing and creating characters. Optical character recognition is an important area of research that allows photographs or printed documents to be digitized; by doing so, these documents are made available for machine-based searching. On the flip side, http://en.wikipedia.org/wiki/CAPTCHA is a system for differentiating between humans and computers: the goal here is to generate a non-machine readable image that a human could identify. CAPTCHA helps reduce the amount of spam on the Internet.

We will implement a highly limited type of image matching, processing, and creation this semester. Rather than write this project at once, we will break the project down into several two-week sub-projects that are due throughout the semester. The rest of this document will detail the first such assignment.

PROJECT UPDATES AND CLARIFICATIONS

This fourth assignment will ask you to write some code that will help you determine if a pixel is part of a number. You will write a class Number to be saved in number.py. You will also need to copy your project 3 and 4 solutions into the same directory where you save this file.

You will have to do the following for this assignment:

Step 1: Writing Test Cases
Ideally, you should write your test cases before you write your code. However, testing objects, such as those of the Number class, are more difficult due to their stateful nature. We can no longer test all methods individually, without at least calling the constructor. For this reason, we will not be writing formal test cases for the project; we need a better testing infrastructure, which you will learn about in CS211 if you take it. Instead, we will provide tests for you; however, you should make sure you understand the tests and their formatting, as you will have to write your own tests for the next project.



Step 2: Writing Code
You will be completing the number.py file with the following methods:
A constructor that takes a color, type, width, and height, as arguments, in that order. You may assume inputs will always be valid, as specified in previous functions. Besides creating attributes for the arguments passed in, the constructor will create an attribute for softening the number, which it initially sets to False.
A method called match that takes a list as an argument, and tries to see if the incoming list of tiles matches any number, one through five, of any size from a 3x3 board to a 9x9 board. If a match is found, it set's the object's width, height, and type (one, two, three, four, or five) to the matched number. If the number cannot be matched, the method raises an exception, and leaves the object's state untouched. To raise an exception in python, simply type raise Exception() (we'll learn more about exceptions later).

See the test cases for examples.
A draw method that draws the current object, by passing its arguments to the draw method written in the previous project, and returns a string.
getColor, getType, getWidth, getHeight, and getSoften getters.
A to-string method that can be called with str(...), which returns the color of the number, followed by a space, followed by the type of the number.
You should get started writing your python code as soon as all of you finish your test suite and it passes both the public and release tests on Marmoset -- do not wait!

You must come up with your own formula for the methods. You will need to derive this formula on your own; discussing it with other students (including Piazza) is considered an Honor Code violation.

You will need the return statement to get your functions to return a value - DO NOT use the print statement for this!


Step 3: Testing Your Code on Your Test Suite
Once you have finished writing your python code, you will first want to test your python code with the test suite you wrote, before testing your python code on Marmoset. Testing your python code at home will give you instant results, while you'll have to wait a bit to test it on Marmoset. Ideally, your test suite is well written, and it's testing for almost everything (or even everything!) the release tests for the python code on Marmoset are checking too. To help you use your test cases, I have included a new driver.py file that will use your tests.txt file and print out whether or not the tests you wrote passed or failed, on the python code you wrote. To use this driver, make sure your project3.py, project4.py, and number.py tests.txt, and driver.py are all in the same directory, and from a terminal in that directory, type:

python driver.py

If you want this driver to stop running after a certain test (so you don't have to scroll through everything when you debug), simply put the word stop on a single line after the last test you want run.


Step 4: Submitting Your Code to Marmoset.
Once your code passes all your tests at home, you're ready to submit to Marmoset. See the instructions at the bottom of this page for Marmoset submission.

In an effort to get students to do their testing at home using their test suite, rather than on Marmoset, you will need to comment out all of your debug print statements from your code before submitting to Marmoset. Do not delete your debugging statements (you may need them later); just comment them out using #. Note that you DO NOT have to comment out your print statements to run your test suite at home using driver.py. Marmoset submission should be a last and rare step!


Sample Input and Output

Your python code will be tested on Marmoset in the same manner as your test cases. Ten sample tests have been provided in the tests.txt above: these tests are the Public Tests and Release Tests on Marmoset.

Release tests for the coding portion will be made available the Thursday morning before projects are due. Coding projects are used as both learning and assessment tools, and in order to get students to test their own code, and come up with their own solutions in a timely manner, the professor or TAs will not answer questions about release tests until they are publicly posted. However, we are very happy to answer questions about why your code doesn't pass *your* tests, at any time. Please get started on projects early, and write and use a high-quality test suite of your own, so you pass most or all of the release tests before the Thursday the project is due.
Project Hints and Guidelines

Remember, when designing your own test cases, try to do so in a thoughtful and structured approach, as we have done in class. What is the smallest possible image you could call your functions on? What is the next smallest one? What are all the corner cases?

Other hints and guidelines:
Project Grading

The project will be worth 30 points:

Project Submission

Do not submit the same files multiple times to try and get Marmoset to grade them faster (because it works like this). You will only slow down the results for yourself and the rest of the class. All requests are handled in order.

There are two due dates for the two different parts of the project (test cases and code). Once a due date passes you cannot resubmit that part of the assignment. However, you may submit either or part of both assignments before the first due date, if you are done early.


DUE DATE: Friday 4/17/2015 at 4:55pm: Code is due. In order to have your code work with Marmoset, you must also submit two files code.py (new) and SystemCall.java. Again, you do not need to know how these files work (or even open them); just make sure not to change them, and submit them with your number.py. Normally, Marmoset is set up to work with Java files, which is why we have this workaround. Submit ONLY your project3.py, project4.py, number.py, code.py and SystemCall.java files on Marmoset following the link to CS112-5C. (the C stands for CODE). Find the link on Marmoset to submit Project 5. Once you pass all the public tests, use your tokens wisely to start examining the release tests. Do not change the name of the files.

You may make as many submissions to Marmoset as you like, before the due date, but we will only grade the highest score. Remember to read and adhere to all of the information regarding projects and their submission and grading on the course syllabus. Remember that Marmoset can be slow due to heavy load, and under no circumstances will project due dates be extended because of this: get stared early.
Allowable resources: Class textbook, Python standard documentation Lecture & Lab Instructors. You may not look at or share other students' code in any manner. You may not look at or share test cases with other students. You may NOT work together or talk to other people (including outside sources besides the professor and GTA/UTAs) about the project. All work must be your own.