Assignment 4: Lisp

Assignment

Write a function PARTOFSPEECH in Lisp that takes 6 parameters. Parameter 1 is a list of English nouns. Parameter 2 is a list of English verbs. Parameter 3 is a list of English articles. Parameter 4 is a list of English prepositions. Parameter 5 is a list of English adverbs. Parameter 6 is a list of lists, each of which is an English sentence. The function PARTOFSPEECH returns a list of lists corresponding to parameter 6, but PARTOFSPEECH replaces every word in every sentence with just the name of its part of speech, that is, noun, verb, article, preposition, or adverb. If a word appears in an English sentence that is not mentioned in any of the first five parameters, replace it with the word "unknown".

Logistics

  1. You should use gcl in the CSLab or Multilab.
  2. You will want to build a file, say three.lisp, containing your Lisp program. Then start Lisp, and type
     	(REQUIRE "three.lisp")
    
    to have the interpreter read in your file and then interact with you further. You will want to evaluate (QUIT) to exit the interactive session.
  3. You must not use SETQ, RPLACA, or RPLACD. You are restricted to “pure Lisp” .
  4. You will find it helpful to build other functions that PARTOFSPEECH can call to get its work done.
  5. Don't worry too much about efficiency. It is acceptable to scan each part-of-speech list for each word until you find it.
  6. Test your function by running it on a your own data. I suggest you build a function DRIVER that tries PARTOFSPEECH on several different inputs. You can cause several expressions to be evaluated by using the form PROGN.

Extra credit

  1. Make a related function RANDOMREPLACE that takes the same parameters as PARTOFSPEECH but returns sentences where each noun has been randomly replaced by some noun, and likewise for each verb, preposition, article, and adverb.