Difference between revisions of "CSC111 Homework 12"

From dftwiki3
Jump to: navigation, search
(Created page with '==Using bigrams to identify Language== Instead of single word frequency as we did in Lab 12, we'll use this time the frequency of blocks of 2 characters, also …')
 
(Requirements)
 
(23 intermediate revisions by the same user not shown)
Line 1: Line 1:
==Using bigrams to identify Language==
+
{|
 +
| width="40%" |
 +
__TOC__
 +
|
 +
<bluebox>
 +
No homework assignment this week.
  
Instead of single word frequency as we did in [[CSC111 Lab 12|Lab 12]], we'll use this time the frequency of blocks of 2 characters, also called ''bigrams''.
+
The problems listed below are '''optional'''.  Pick '''one''' of the problems, and  write a program that solves it.  Only one program is needed for this assignment.  The grade you obtain will replace the lowest assignment grade you have gotten so far.
  
The frequency of bigrams for the English language is tabulated in [http://en.wikipedia.org/wiki/Bigram | Wikipedia]:
+
The due date is the same as for other homework assignments: next Thursday at midnight. You can work in pairs or individually.  
 +
</bluebox>
 +
|}
  
 +
==Problem #1: Where should you eat today?==
  
th 1.52%      en 0.55%      ng 0.18%
+
This problem was suggested by Kristina.
he 1.28%      ed 0.53%      of 0.16%
 
in 0.94%      to 0.52%      al 0.09%
 
er 0.94%      it 0.50%      de 0.09%
 
an 0.82%      ou 0.50%      se 0.08%
 
re 0.68%      ea 0.47%      le 0.08%
 
nd 0.63%      hi 0.46%      sa 0.06%
 
at 0.59%      is 0.46%      si 0.05%
 
on 0.57%      or 0.43%      ar 0.04%
 
nt 0.56%      ti 0.34%      ve 0.04%
 
ha 0.56%      as 0.33%      ra 0.04%
 
es 0.56%      te 0.27%      ld 0.02%
 
st 0.55%      et 0.19%      ur 0.02%
 
  
 +
Write a program that reads the Web page located at http://www.smith.edu/diningservices/10Menus/10apr22.php and that search for your favorite dishes.  If it finds a house where your favorite dishes are offered, it displays the name of the house, and the menu for that house.
  
 +
Here is an example of how your program should get its input.  The user input is underlined.
  
==References==
+
  <u>python hw12a.py</u>
 +
 +
  Welcome to the Smith Menu Selection program.
 +
  Today is April 22, 2010
 +
 +
  What are your favorite dishes? <u>pasta icecream ROAST</u>
 +
 +
  Your favorite dishes are offered today in:
 +
 +
  Chapin: Icecream
 +
  Cutter-Ziskind: Icecream, Pot Roast
 +
  Hubbard: Pasta Bar
  
* http://en.wikipedia.org/wiki/Bigram
+
===Requirements===
 +
* Your program must request only one thing from the user: a string of characters containing one or several words.
 +
* Your program figures out which day is today (see http://pleac.sourceforge.net/pleac_python/datesandtimes.html for ways of getting date information from the computer), and looks at the Web page for that day only.  The day is coded in the URL of the Web page offering the menus.
 +
* Your program reports which house offers one of the words specified by the user in their menu, and displays that word and any accompanying word (for example, the  user entered "ROAST", and the program found "Pot Roast" in the menu offered at Cutter-Ziskind.)
 +
 
 +
===Submission===
 +
 
 +
* If you do this program, call it '''hw12a.py''' and submit it as:
 +
 
 +
    submit hw12 hw12a.py
 +
 
 +
 
 +
==Problem #2: Poem Generator==
 +
 
 +
* This idea for this problem was submitted by Jack.
 +
 
 +
* The general idea is taken from http://thinkzone.wlonk.com/PoemGen/PoemGen.htm.  Take a look at it and see how it works.  Generate some poems.
 +
 
 +
* Implement the same idea in Python.
 +
 
 +
===Requirements===
 +
 
 +
* The program contains  9 '''groups''' of words:
 +
** concrete nouns : SEA SHIP SAIL WIND ... SUN
 +
** abstract nouns : ADVENTURE COURAGE ENDURANCE ...
 +
**                  ...
 +
** interjections : O OH OOH AH LORD GOD...
 +
* The program also maintains many difference sentence '''patterns''', of the form:
 +
** THE 5 1 6 3S THE 1.
 +
** 5, 5 1S 6 3 A 5, 5 1.
 +
** 2 IS A 5 1.
 +
** ...
 +
** NEVER 3 A 1.
 +
* The program contains two (or more) different '''topics''', such as '''sea''' or '''city''', and will keep different sets of 9 groups of words for each.
 +
* The patterns are the same for all the topics.
 +
* You must use dictionaries in some way...
 +
* The program will generate 10 random poems on random topics, picking 10 random rules (the same rule can be picked twice or more times)
 +
* Each poem will use a pattern and pick random words in the group specified by the pattern.
 +
* Feel free, of course, to select your own words in the different groups, and to supply your own patterns, but make sure the rules contain both words and numbers!
 +
 
 +
===Submission===
 +
 
 +
If you write a program for this problem, call it hw12b.py and submit it as follows:
 +
 
 +
  submit hw12 hw12b.py
 +
 
 +
 +
<!--
 +
 
 +
http://pleac.sourceforge.net/pleac_python/datesandtimes.html
 +
 
 +
Ideas submitted so far (4/22/10):
 +
* write a program that gets today's menu at Smith.  User specifies house.  Program outputs (email?) result to user.  Reference URL = http://www.smith.edu/diningservices/10Menus/10apr22.php
 +
* write a more sophisticated poem generator
 +
 
 +
<br />
 +
<center>[[Image:thinking.gif]]</center>
 +
<br />
 +
-->
  
 
<br />
 
<br />

Latest revision as of 15:43, 22 April 2010

No homework assignment this week.

The problems listed below are optional. Pick one of the problems, and write a program that solves it. Only one program is needed for this assignment. The grade you obtain will replace the lowest assignment grade you have gotten so far.

The due date is the same as for other homework assignments: next Thursday at midnight. You can work in pairs or individually.

Problem #1: Where should you eat today?

This problem was suggested by Kristina.

Write a program that reads the Web page located at http://www.smith.edu/diningservices/10Menus/10apr22.php and that search for your favorite dishes. If it finds a house where your favorite dishes are offered, it displays the name of the house, and the menu for that house.

Here is an example of how your program should get its input. The user input is underlined.

 python hw12a.py

 Welcome to the Smith Menu Selection program.
 Today is April 22, 2010

 What are your favorite dishes? pasta icecream ROAST

 Your favorite dishes are offered today in:

 Chapin: Icecream
 Cutter-Ziskind: Icecream, Pot Roast
 Hubbard: Pasta Bar

Requirements

  • Your program must request only one thing from the user: a string of characters containing one or several words.
  • Your program figures out which day is today (see http://pleac.sourceforge.net/pleac_python/datesandtimes.html for ways of getting date information from the computer), and looks at the Web page for that day only. The day is coded in the URL of the Web page offering the menus.
  • Your program reports which house offers one of the words specified by the user in their menu, and displays that word and any accompanying word (for example, the user entered "ROAST", and the program found "Pot Roast" in the menu offered at Cutter-Ziskind.)

Submission

  • If you do this program, call it hw12a.py and submit it as:
   submit hw12 hw12a.py


Problem #2: Poem Generator

  • This idea for this problem was submitted by Jack.
  • Implement the same idea in Python.

Requirements

  • The program contains 9 groups of words:
    • concrete nouns : SEA SHIP SAIL WIND ... SUN
    • abstract nouns : ADVENTURE COURAGE ENDURANCE ...
    • ...
    • interjections : O OH OOH AH LORD GOD...
  • The program also maintains many difference sentence patterns, of the form:
    • THE 5 1 6 3S THE 1.
    • 5, 5 1S 6 3 A 5, 5 1.
    • 2 IS A 5 1.
    • ...
    • NEVER 3 A 1.
  • The program contains two (or more) different topics, such as sea or city, and will keep different sets of 9 groups of words for each.
  • The patterns are the same for all the topics.
  • You must use dictionaries in some way...
  • The program will generate 10 random poems on random topics, picking 10 random rules (the same rule can be picked twice or more times)
  • Each poem will use a pattern and pick random words in the group specified by the pattern.
  • Feel free, of course, to select your own words in the different groups, and to supply your own patterns, but make sure the rules contain both words and numbers!

Submission

If you write a program for this problem, call it hw12b.py and submit it as follows:

  submit hw12 hw12b.py