Lab 10

Due: Dec 14, 11:55pm

Instructions

  • Turn in the code (a cpp file or ideone.com link), and the run outputs as requested below.
  • Remember to format the code as described and the book and text, and to include comments including complete commetns at the beginning of the program.

Grading

Feature %
Program correctness and completeness with respect to defination 70%
Code Format (Indenting, variable names) 10%
Code Comments 10%
Turning in the run the requested inputs below.. 10%
Turn in a list of extra features added, with a total of points being sought  

Problem

Shakespeare Word Search

Your goal is to use Object Oriented techniques to read the complete works of Shakespeare from a file, and allow for word searches.

A complete version of all works of Shakespeare in a single file is available here: Shakespeare.txt.

Your program must do at least the following:

  1. Read in the entire file of Shakespeare books, and parse it into Books and Paragraphs, where Books is object the contains an entire book (definition below), and Paragraph is an object representation of a paragraph (also below). Thus there will be an array of Books, and each book will be a title plus an array of paragraphs.
  2. Show the user a list of the book titles, alone with the number of paragraphs found in each.
  3. Ask the user for a word to search, and show the users how many paragraphs in each book has a match for this word.
  4. Repeat the above step until the user is done.

Extra credit

Since this is the lass project you will have the opportunity to explore this problem, and add extra credit toward your overall grade. Following are a list of possible options, with a percent of how much it add to your OVERALL grade. You may propose additional improvements for extra credit by emailing me with a proposal, and I will decide if it can be approved, and how much it is worth. The maximum extra credit is 10%.

Some options:

  1. (0.5%) Highlight the matching words (bold or color)
  2. (1%) Add an option to show the matching paragraphs from a selected book (shown in the example below).
  3. (1%) Choose whether to see matching paragraph or just sentences.
  4. (1%) Add support for a second author or set of works. The second file must be at least 1Mb, and you will need to format it appropriately. You will have two programs, one for Shakespeare, and another for the new file.
  5. (2%) Add support for 5 or more authors, and start with a menu listing the options, and allowing the user to select the works, then to the other operations. This option is mutually exclusive with #2.
  6. (1%) Add support to #3 to search ALL books.
  7. (2%) Add support to #1 & #2 to search for pairs of words, not necessarily adjacent.
  8. (1%) Add support to #5 to search for words within some specified numbers of word apart.
  9. (2%) Add Stemming.
  10. More to come ...

The Class Definitations

class paragraph {
    private:
        string text;
    public:
        paragraph();
        void setText(string p);
        bool search(string word);
        void display();
};

class book {
    private:
        string title;
        vector<paragraph> paragraphs;
    public:
        book();
        void setTitle(string title);
        string getTitle();
        int search(string word);
        void add(paragraph p);
        void clear();
        int getParaCount();
        void displayMatches(string search);
};

 

The program should have a vector of book.

Run Example

Welcome to the Shakespeare search program
Books (# of paragraphs)
1.  THE SONNETS (311)
2.  ALLS WELL THAT ENDS WELL (233)
3.  THE TRAGEDY OF ANTONY AND CLEOPATRA (313)
4.  AS YOU LIKE IT (243)
5.  THE COMEDY OF ERRORS (149)
6.  THE TRAGEDY OF CORIOLANUS (331)
7.  CYMBELINE (290)
8.  THE TRAGEDY OF HAMLET, PRINCE OF DENMARK (313)
9.  THE FIRST PART OF KING HENRY THE FOURTH (237)
10.  SECOND PART OF KING HENRY IV (259)
11.  THE LIFE OF KING HENRY THE FIFTH (279)
12.  THE FIRST PART OF HENRY THE SIXTH (312)
13.  THE SECOND PART OF KING HENRY THE SIXTH (287)
14.  THE THIRD PART OF KING HENRY THE SIXTH (285)
15.  KING HENRY THE EIGHTH (233)
16.  KING JOHN (198)
17.  THE TRAGEDY OF JULIUS CAESAR (211)
18.  THE TRAGEDY OF KING LEAR (310)
19.  LOVE'S LABOUR'S LOST (144)
20.  THE TRAGEDY OF MACBETH (506)
21.  THE MERCHANT OF VENICE (203)
22.  THE MERRY WIVES OF WINDSOR (308)
23.  A MIDSUMMER NIGHT'S DREAM (172)
24.  MUCH ADO ABOUT NOTHING (197)
25.  THE TRAGEDY OF OTHELLO, MOOR OF VENICE (223)
26.  KING RICHARD THE SECOND (212)
27.  KING RICHARD III (344)
28.  THE TRAGEDY OF ROMEO AND JULIET (294)
29.  THE TAMING OF THE SHREW (213)
30.  THE TEMPEST (165)
31.  THE LIFE OF TIMON OF ATHENS (226)
32.  THE TRAGEDY OF TITUS ANDRONICUS (195)
33.  THE HISTORY OF TROILUS AND CRESSIDA (306)
34.  TWELFTH NIGHT; OR, WHAT YOU WILL (245)
35.  THE TWO GENTLEMEN OF VERONA (200)
36.  THE WINTER'S TALE (184)
37.  A LOVER'S COMPLAINT (50)
Number of Books: 37

Word to search for:sail
1.  THE SONNETS has 5 matches.
2.  ALLS WELL THAT ENDS WELL has 1 matches.
3.  THE TRAGEDY OF ANTONY AND CLEOPATRA has 7 matches.
4.  AS YOU LIKE IT has 1 matches.
5.  THE COMEDY OF ERRORS has 2 matches.
6.  THE TRAGEDY OF CORIOLANUS has 1 matches.
7.  CYMBELINE has 5 matches.
8.  THE TRAGEDY OF HAMLET, PRINCE OF DENMARK has 5 matches.
10.  SECOND PART OF KING HENRY IV has 2 matches.
11.  THE LIFE OF KING HENRY THE FIFTH has 3 matches.
12.  THE FIRST PART OF HENRY THE SIXTH has 2 matches.
13.  THE SECOND PART OF KING HENRY THE SIXTH has 3 matches.
14.  THE THIRD PART OF KING HENRY THE SIXTH has 6 matches.
16.  KING JOHN has 5 matches.
17.  THE TRAGEDY OF JULIUS CAESAR has 1 matches.
19.  LOVE'S LABOUR'S LOST has 2 matches.
20.  THE TRAGEDY OF MACBETH has 3 matches.
21.  THE MERCHANT OF VENICE has 6 matches.
22.  THE MERRY WIVES OF WINDSOR has 1 matches.
23.  A MIDSUMMER NIGHT'S DREAM has 2 matches.
24.  MUCH ADO ABOUT NOTHING has 1 matches.
25.  THE TRAGEDY OF OTHELLO, MOOR OF VENICE has 9 matches.
26.  KING RICHARD THE SECOND has 1 matches.
27.  KING RICHARD III has 3 matches.
28.  THE TRAGEDY OF ROMEO AND JULIET has 4 matches.
29.  THE TAMING OF THE SHREW has 1 matches.
30.  THE TEMPEST has 8 matches.
33.  THE HISTORY OF TROILUS AND CRESSIDA has 5 matches.
34.  TWELFTH NIGHT; OR, WHAT YOU WILL has 5 matches.
37.  A LOVER'S COMPLAINT has 1 matches.
Enter book number to view matches, 0 for a new search, -1 to end: 29

Matches of "sail" in book " THE TAMING OF THE SHREW"

  TRANIO. Sir, what are you that offer to beat my servant?  VINCENTIO. What am I, sir? Nay, what are you, sir? O immortal gods!
    O fine villain! A silken doublet, a velvet hose, a scarlet cloak,
    and a copatain hat! O, I am undone! I am undone! While I play the
    good husband at home, my son and my servant spend all at the
    university.
  TRANIO. How now! what's the matter?
  BAPTISTA. What, is the man lunatic?
  TRANIO. Sir, you seem a sober ancient gentleman by your habit, but
    your words show you a madman. Why, sir, what 'cerns it you if I
    wear pearl and gold? I thank my good father, I am able to
    maintain it.
  VINCENTIO. Thy father! O villain! he is a sailmaker in Bergamo.
  BAPTISTA. You mistake, sir; you mistake, sir. Pray, what do you
    think is his name?
  VINCENTIO. His name! As if I knew not his name! I have brought him
    up ever since he was three years old, and his name is Tranio.
  PEDANT. Away, away, mad ass! His name is Lucentio; and he is mine
    only son, and heir to the lands of me, Signior Vicentio.
  VINCENTIO. Lucentio! O, he hath murd'red his master! Lay hold on
    him, I charge you, in the Duke's name. O, my son, my son! Tell
    me, thou villain, where is my son, Lucentio?
  TRANIO. Call forth an officer.


Enter book number to view matches, 0 for a new search, -1 to end: 

Topic attachments
I Attachment History Action Size Date Who Comment
Texttxt Shakespeare.txt r1 manage 5337.2 K 2015-11-17 - 18:11 JimSkon  
Edit | Attach | Watch | Print version | History: r34 | r6 < r5 < r4 < r3 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r4 - 2015-11-18 - JimSkon
 
  • Edit
  • Attach
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback