handling plurals

As mentioned in class, you will have to handle plurals for this assignment in the following case:
  A cat has 1 mouse.
Felix is a cat.
How many mice does Felix have?

You can do this in one of two ways:

  1. Use a file containing the plural facts needed for the set of input given below and load it in along with your parse code.
    (TIP: To load in two files at once: 1 ?- ['file1', 'file2'].)

  2. Write a new parse rule that handles sentences of the form:
      The plural of mouse is mice.
    Handling it like this is nicer and might get you a little bit of extra credit.


handin instructions

  1. Make a file with your parse code in it.

  2. Load the file into SWI-Prolog on the Unix machines, along with any files containing plural information that you need.

  3. Start the main rule running and give the input that follows, along with any extra input required to handle plurals. (The input below is given assuming you used the provided sentence reading code. If not, format the input in lists as necessary.)

      Carmen is a cat.
    A cat is an animal.
    A cat has 1 tail.
    A cat has 9 lives.
    Is Carmen a cat?
    Is Carmen an animal?
    How many tails does Carmen have?
    How many lives does Carmen have?
    Elijah is a prophet.
    A prophet is a person.
    A person has 1 life.
    Is Elijah a prophet?
    Is Elijah a person?
    Is Elijah a cat?
    How many lives does Elijah have?
    A redtail is a hawk.
    A hawk is a bird.
    A bird is a vertebrate.
    A vertebrate is an animal.
    An animal has 2 parents.
    Red is a redtail.
    How many parents does Red have?

    If you want to show off any other cool things you did, show them off after you run this basic set of input.

  4. Copy the transcript of your session into a file using an editor. (The command emacs brings up a good editor. You can select a region of text by holding down the left mouse button and dragging. Paste by clicking the middle mouse button.)

  5. Print the session transcript. (The command ppanel brings up a print dialog.)

  6. Print your Prolog code.

  7. Give the code and the session transcript (labeled with your name, email, and section) to me by 11:20am Friday, 3/13.


sample transcript

sanjuan% prolog
Welcome to SWI-Prolog (Version 2.9.5)
Copyright (c) 1993-1997 University of Amsterdam.  All rights reserved.

For help, use ?- help(Topic). or ?- apropos(Word).

1 ?- consult('read.pl').
[WARNING: (/homes/iws/jpower/read.pl:8)
        Singleton variables: W]
[WARNING: (/homes/iws/jpower/read.pl:21)
        Singleton variables: C]
[WARNING: (/homes/iws/jpower/read.pl:74)
        Singleton variables: S, P, C]
[WARNING: (/homes/iws/jpower/read.pl:105)
        Singleton variables: Num]
read.pl compiled, 0.00 sec, 14,552 bytes.

Yes
2 ?- talk.
|: Carmen is a cat.
[carmen, is, a, cat, .]
ok
|: A cat is an animal.
[a, cat, is, an, animal, .]
ok
|: The plural of tail is tails.
[the, plural, of, tail, is, tails, .]
ok
|: A cat has 1 tail.
[a, cat, has, 1, tail, .]
ok
ok
|: A cat has 9 lives.
[a, cat, has, 9, lives, .]
ok
|: Is Carmen a cat?
[is, carmen, a, cat, ?]
yes
|: Is Carmen an animal?
[is, carmen, an, animal, ?]
yes
|: How many tails does Carmen have?
[how, many, tails, does, carmen, have, ?]
1
|: How many lives does Carmen have?
[how, many, lives, does, carmen, have, ?]
9
|: Elijah is a prophet.
[elijah, is, a, prophet, .]
ok
|: A prophet is a person.
[a, prophet, is, a, person, .]
ok
|: The plural of life is lives.
[the, plural, of, life, is, lives, .]
ok
|: A person has 1 life.
[a, person, has, 1, life, .]
ok
|: Is Elijah a prophet?
[is, elijah, a, prophet, ?]
yes
|: Is Elijah a person?
[is, elijah, a, person, ?]
yes
|: Is Elijah a cat?
[is, elijah, a, cat, ?]
unknown
|: Is Carmen a prophet?
[is, carmen, a, prophet, ?]
unknown
|: How many lives does Elijah have?
[how, many, lives, does, elijah, have, ?]
1
|: A redtail is a hawk.
[a, redtail, is, a, hawk, .]
ok
|: A hawk is a bird.
[a, hawk, is, a, bird, .]
ok
|: A bird is a vertebrate.
[a, bird, is, a, vertebrate, .]
ok
|: A vertebrate is an animal.
[a, vertebrate, is, an, animal, .]
ok
|: An animal has 2 parents.
[an, animal, has, 2, parents, .]
ok
|: Red is a redtail.
[red, is, a, redtail, .]
ok
|: How many parents does Red have?
[how, many, parents, does, red, have, ?]
2
|: quit.
[quit, .]

Yes

Last modified: Tue Mar 10 15:20:38 PST 1998