[Skip to Body]
Primary:
[Front Door]
[Current]
[Glance]
-
[Honesty]
[On Teaching and Learning]
Groupings:
[EBoards]
[Examples]
[Exams]
[Handouts]
[Homework]
[Labs]
[Outlines]
[Readings]
[Reference]
Misc:
[SamR]
[Java 1.5 API]
[Espresso]
[TAO of Java]
[CS152 2004F]
[CS152 2005S]
[CS152 2005F]
Assigned: Monday, February 13, 2006
Due: 8:00 a.m., Wednesday, February 15, 2006
Summary: In this assignment, you will write a
program that asks the user for a string and then finds the best
match
for that string in a file of strings.
Purpose: To ground you in a problem that we will return to many times this semester. To increase your facility with repetition in Java.
Contents:
One of the more interesting problems in computing is that of approximate string matching: Given a string to match and a sequence of candidate matches, find the best match. Spell checkers regularly use such an algorithm to suggest spelling corrections. Biologists also use such an algorithm to match genetic sequences.
We will consider this problem in a number of ways this semester. That is, we will explore different ways to represent the candidate matches and we will will explore different strategies for selecting among those matches.
In this first exploration, you have the freedom to choose how to compare strings.
Write a file that contains a list of a dozen or so names. (More is
better, but a dozen or so should suffice.) You can call the file
whatever you'd like, but names.txt is a good idea.
Write a Java program that prompts the user for a name and finds the
best
match in the file for that name. A good match might have
only one letter different, or one letter deleted, or one letter added.
A less good match might have a combination of those.
You may choose your own metric for best
, provided it decides that an
exact match (if one exists) is the best.
You are likely to need at least two loops: One to loop through the strings in the file, and one to loop through the string and the candidate string comparing characters.
You will probably want to write a subroutine,
qualityOfMatch(String a, String b) that assigns
a number to the quality of the match between a
and b. One of the loops will be in that subroutine.
When you are satisfied with your work, you should email me the method you have written.
Those of you who want to get extra credit on this assignment might consider writing particularly nice comparison metrics or provide an ordered list of candidates (from best to worst).
When you ask questions, I'll try to put the answers here.
Samuel) or first and last names (e.g., Samuel Rebelsky). If the latter, what form should they take?
Monday, 13 February 2006 [Samuel A. Rebelsky]
Tuesday, 14 February 2006 [Samuel A. Rebelsky]
[Skip to Body]
Primary:
[Front Door]
[Current]
[Glance]
-
[Honesty]
[On Teaching and Learning]
Groupings:
[EBoards]
[Examples]
[Exams]
[Handouts]
[Homework]
[Labs]
[Outlines]
[Readings]
[Reference]
Misc:
[SamR]
[Java 1.5 API]
[Espresso]
[TAO of Java]
[CS152 2004F]
[CS152 2005S]
[CS152 2005F]
Disclaimer:
I usually create these pages on the fly
, which means that I rarely
proofread them and they may contain bad grammar and incorrect details.
It also means that I tend to update them regularly (see the history for
more details). Feel free to contact me with any suggestions for changes.
This document was generated by
Siteweaver on Tue May 9 08:31:09 2006.
The source to the document was last modified on Tue Feb 14 15:52:09 2006.
This document may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CS152/2006S/Homework/hw.07.html.
You may wish to
validate this document's HTML
;
;
Check with Bobby