Coding Samples

Coding projects for courses and self-study since 2001.



Computational linguistics projects (2013) SJSU for MA, Linguistics and Computation Linguistics certificate. Final projects from natural language processing course (this write-up discusses the labs below).

  • POS (part of speech) tagging using HMM (Hidden Markov Model) > code  |  screenshot
  • Naïve Bayes classifier and word-sense disambiguation > code  |  screenshot
  • Script to summarize word frequency > code  |  screenshot
  • Spelling correction using Levenshtein (minimal-edit) distance > code  |  screenshot


Developing database-backed web applications using PHP and MySQL. CIS-380 in the internet programming sequence, College of San Mateo (2009).

AJAX (Asynchronous JavaScript and XML)

Javascript coding plus using various libraries and APIs from Google. (Yahoo! libraries no longer supported). CIS-112 in the internet programming sequence, College of San Mateo (2009).

Object-oriented Programming Methods (using Java)

Object-oriented development using Java. CIS-255 computer science fundamentals sequence, College of San Mateo (2005).

  • StudentRecords is an application that processes Student records contained in a simple flat-file [student.dat]. StudentRecords adds each student record to the student.dat file (appends to the end of the file) in the format "lastName:firstName:studentID:gpa". Clicking the Display All Student Records button initiates the process of opening the student.dat file and determining the number of records in the file, and then creating an array of student references of that size; populating the array with Student object instances; and then sorting the array so that the results are in alphabetical order. The application incorporates try-catch exception handling; file i/o; and sorting algorithms [using a QuickSort routine provided by Prof. Green, modified to handle String comparisons rather than integer values]; in a graphical user interface:

    StudentRecords application--Adding a new student record   StudentRecords after clicking Add button   StudentRecords after clicking Display All

    Adding a new student   After clicking the Add button, the field entries are validated, and if everything is okay, the student record is added to the student.dat file; the details of the student record are displayed in the output [above, center]. Clicking the Display All Student Records button outputs all sorted records in the output. [above, right]
  • ScreenSaver application emulates a screensaver by drawing 100 random filled shapes (lines, triangles, spheres). This application uses the Java2D API. Classes from previous projects [the MyShape interface, plus the MyLine, MyTriangle, and MySphere classes] were modified for this project.
  • MyShapeTest applet that demonstrates polymorphism by using an array of superclass references to instantiate subclass objects.
  • ShapeTest applet that instantiates three different arrays of shapes (MyLine, MyTriangle, MyCircle). This project exercises aggregation (also known as "composition", which defines a "has-a" relationship) as well as inheritance ("is-a"). MyLine is the superclass in a simple inheritance hierarchy that includes MyTriangle and MyCircle. MyLine defines two points (using the Point class) and then draws a line between the two points. MyTriangle extends MyLine and adds a new point object to define the third point in the triangle. MyCircle extends MyLine and adds a private member (radius); MyCircle uses only one point from MyLine. The class is the driver applet that instantiates three arrays comprising four objects each (MyLine[], MyTriangle[], MyCircle[]) using Math.random to generate the data necessary for the constructors. Colors for the lines are also generated using Math.random().
  • Complex is an abstract data type that represents a complex number and performs basic math operations (add, subtract, multiply, divide) on a complex number. The is a driver application that instantiates two Complex objects and then performs calculations using the two objects.
  • Morse Code, a Java application that generates Morse code from a basic input line (just letters a-z and digits 0-9).
  • Sieve of Eratosthenes, an applet that generates all the prime numbers between 2 and 999. Here's the source code listing.
  • Pig Latin application (must compile and run using javac, that is, not an applet). This Java class accepts user input (a single word, a phrase, or a complete sentence) and converts to 'pig latin,' according to simplified rules: 1) words starting with vowels have 'way' added to them; and all other words have their first letter moved to the end, with 'ay' tacked on after that. The class extends JFrame and uses an anonymous inner class to handle event processing (that is, it listens on the text input component and then invokes the algorithm that converts the words). Key elements of this program: Using StringTokenizer class, passing it a new string of delimiters, calling a separate method (printLatinWord()) that actually performs the conversion. Uses Swing components.
  • Airline Reservation system, an applet that assigns seats in a 10-seat airplane based on user input (a 1 for first class, a 2 for economy). Seats 1-5 are first class, seats 6-10 are economy class. When one or the other class seating is full, offer the user a seat on the alternate class (if a seat is available). If the user doesn't want the seat in the alternative seat class, display a message saying "next flight leaves in 3 hours." Use an array of booleans for the seating chart. Here's the [code listing]. Uses Swing components.

XML Processing and Web Services

Notre Dame de Namur University (2004)

Foundation class for now-defunct MA in Computer Science program launched by NDNU in the Fall of 2004. Code samples below include both client and server-side Java (Servlets and JSPs), WSDL, SOAP, and so on (although none of the samples below is running on this website because the service provider makes no Tomcat or other Java server infrastructure available).

Addressbook Manager (Final Project)

Application to manage XML-based address book (AddressBook.xml) file. Developed user interface to add, delete, search, and edit contacts in the AddressBook.xml file. Implemented as JavaServer Pages (JSPs), deployed to Apache Tomcat. For more details...

Code listings:

Other projects
  • Click here for larger screenshotWeb service that calculates compound interest payment amounts and total cost over the life of a loan, and a simple Java console based client that calls the Web service. This Web service has been deployed on a Tomcat 5 install running Axis. Here's the web-services deployment descriptor file for the project, the WSDL that was generated by Axis/Tomcat after deploying to the server. Screenshot shows the client program executing and obtaining response from the Web service.
  • Write a Java program that uses the SAX parser to parse the AddressBook.xml, search for an printout one of the contacts from the AddressBook.xml. This was a real pain, no question, and seemed like more trouble than it was worth. I've a feeling JAXB might have been a better choice, but I'm still trying to get a handle on JAXB.
  • Write a simple Newspaper.xml file based on this XML Schema (newspaper.xsd), and a Java program ( that gets a headline that matches the name of the author entered at the command line.
  • Write a Java program [] that finds a contact in the AddressBook [note that when you click on the link to display the addressbook.xml, you're getting the results as filtered by the XML Stylesheet] and displays all the data about that contact. Uses the DOM interfaces. This program has two versions:
    • the version is very simple. It finds the contact's last name, then first name, then backs up the tree to find the Contact node for that contact, then sends to a recursive method the other complexElements of the XML (PrimaryInfo, HomeAddress, HomePhones, and so on (see the AddressBook.xsd for details)).
    • is an alternative approach, which spends a lot of time extracting just the information of interest, without the element names, and prints out in a more 'narrative' style the particulars of the found contact. I think the way I'm working with the data in this latter program would have been better suited to JAXB—I'll try that later, after I've finished creating the SAX version of this program.
  • Create an XML Schema, XML document, and XSLT stylesheet for an AddressBook. Using XPath expressions to find only certain nodes.
  • Create DTDs to be used for XML addressbook. Two primary approaches:

Fundamental Java Programming

Foundation course in programming, CIS-101, Golden Gate University (2004). Projects listed are applications (console based) originally created using JDK 1.4.1 but recompiled with JDK 7 (Feb 2014). Blackjack and TuitionCalculator are less trivial than the others. Compiled class files available for download.

Last updated 10 Nov 2019