Assignment 2: Extending ISA Hierarchies
CSE 415: Introduction to Artificial Intelligence
The University of Washington, Seattle, Autumn 2011
The reading for this assignment is Chapter 4 (Knowledge Representation) of Introduction to Artificial Intelligence Using Python.
Due Friday, October 14 through Catalyst CollectIt at 2:00 PM.

You should turn in 3 files: (1) a file named plurals.py, (2) a file named LinneusWithPlurals.py and (3) a file named LinneusWithPluralsAndHasLinks.py.
 

PART I: From Singular To Plural (20 points).

 
Create a file called plurals.py that defines four functions. Each one takes a string argument w. You may assume that it represents one word and that the word is a noun.
  • isSingular(w): returns True if w represents a singular word.
  • isPlural(w): returns True if w represents a plural word.
  • toSingular(w): If w is already singular, return it. Otherwise, return a new word that represents the singular form of w.
  • toPlural(w): If w is already plural, return it. Otherwise, return a new word that represents the plural form of w.
Your file should define a dictionary of special cases and use this dictionary (or the sets of keys or values from it) in all four functions. You do not need to handle all English nouns correctly. However, you should handle the most regular forms correctly and handle all unit test cases correctly. Regular cases:
singular ending -- plural ending
s, x, or z -- add es.
[consonant] y -- change y to ies. (i.e., change y to ies unless the y is preceded by a vowel.)
[vowel or non-sxz consonant] -- add s.    (corrected from "[non-s consonant] -- add s.")
us -- change to i.
PART II: Linneus with Plurals (30 points).

Download this version of Linneus: Linneus2011.py. In this version, all the printing is done in the Linneus function, and the process function returns strings without doing any printing. Your program's functionality will be automatically tested by making calls to your process function.

Add to the Linneus program the capability of understanding names of classes of objects by their plural forms. You may either access your plural-related functions by importing your file plurals.py, or you may incorporate the functionality into the main Linneus2011 file, if you prefer.

The following patterns should work:

>>> A person is a being.
I understand.
>>> What are people?
People are beings.
>>> Beings are creatures.
I understand.
>>> What is a creature?
A creature is something more general than a being.
>>> What are creatures?
Creatures are something more general than beings.
>>> Are people creatures?
Yes, they are.
>>> Why are people creatures?
Because people are beings, and beings are creatures.
>>> Octopi are beings.
I understand.
>>> Is an octopus a creature?
Yes, it is.
>>> Why is an octopus a creature?
Because an octopus is a being, and a being is a creature.
PART III: Working with HAS Links (50 points).

Further extend your program's capability by creating a new version that includes all the plural capabilities and, in addition, implements HAS links, supporting the syntactic forms that occur in the following example dialog.
>>> Dogs have tails.
I understand.
>>> Do dogs have tails?
Yes, they do.
>>> Collies are dogs.
I understand.
>>> Do collies have tails?
Yes, they do.
>>> Why do collies have tails?
Because collies are dogs, and dogs have tails.
>>> Dogs have legs.
I understand.
>>> Legs have feet.
I understand.
>>> Why do collies have feet?
Because collies are dogs, dogs have legs, and legs have feet.
It is recommended, for consistency, that all your links be represented in their singular forms, with conversion from and to plural done when needed for the input and output. Notice that the conversational patterns involving HAS relationships are limited to plural forms in this assignment. Thus, you don't have to support the pattern: "A dog has a tail."

The inference of HAS relationships should follow the rules described in the reading and in class.

If your program correctly handles the storing of the HAS links (in response to statements such as "Dogs have tails.") and correctly handles the answering of questions of the form "Do collies have tails?" (with the various cases that can occur), you'll get 30 points. If the program correctly handles the WHY questions involving HAS links, you'll get 20 more points.

Updates and Corrections If necessary, updates and corrections will be posted here and mentioned in class or on the mailing list or in the GoPost discussion area related to Assignment 2. Unit test information will be posted in GoPost.

(last updated Oct. 11 at 7:41 PM, with the correction to the pluralization rule involving words ending in non-s consonants.)