1 / 13

Dense Bags, Markov Text Generation, and a Midterm, oh my

Dense Bags, Markov Text Generation, and a Midterm, oh my. CMSC 433 Bill Pugh and Nelson Padua-Perez. Upcoming schedule. Project 5 - Dense bags and Markov text Due next Thursday, April 6th 2nd Midterm, Monday, April 10th Readings from now to midterm: Chapter 7: Recursion

elpida
Download Presentation

Dense Bags, Markov Text Generation, and a Midterm, oh my

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Dense Bags, Markov Text Generation,and a Midterm,oh my CMSC 433 Bill Pugh and Nelson Padua-Perez

  2. Upcoming schedule • Project 5 - Dense bags and Markov text • Due next Thursday, April 6th • 2nd Midterm, Monday, April 10th • Readings from now to midterm: • Chapter 7: Recursion • Section 8.1: Tree terminology

  3. DenseBag • Like a set, but can contain duplicates • Example { 1, 3, 1, 1, 3, 5 } • which is the same as { 1, 1, 1, 3, 3, 5 }

  4. DenseBag<E> operations • In addition to the operations supported on any Collection, we need to support: Set<E> getUniqueElements() int getCount(E e) E choose(Random r) • Given the DenseBag { 1, 1, 1, 3, 3, 5 }, what would these methods do?

  5. Efficiency • Most operations on a dense bag should take O(1) average time • time is average because it may depend on hashing • choose(Random r) may take time proportional to the number of unique elements in the bag

  6. Couple of notes • remove(Object o) will remove only one instance • uniqueElements returns elements that occur at least once • getCount(E e) returns 0 if e doesn’t occur in the bag at all

  7. Iterators • Assume we have DenseBag<Integer> = { 1, 1, 1, 3, 3, 5 } • What do you think an iterator over the dense bag would do? • order in which we do iteration doesn’t matter

  8. Honors requirement • For honors section, you need to make remove work on DenseBag iterators • calling remove on an iterator removes the element you just iterated over

  9. Markov Text • We want to generate a transition table showing, given a list of the words/characters most recently generated, a DenseBag of the word/character that occurred next in the training documents

  10. Example • Consider building a 2nd order predictor based on the characters in xxxxyyxxz • Assume I start with xx • xx occurs 4 times, and is followed by: • a x twice • a y once • a z once • So when generating random text, xx should be followed by an x 50% of the time, a y 25% of the time, and a z 25% of the time

  11. Questions • What data structures would be helpful for this? • How do we handle starting? • what characters/words start the randomly generated sequence • How do we handle ending? • When should we stop the generated text?

  12. Creating and training a MarkovText • A MarkovText is created with a specific order • Train it on a sequence of strings • pass the updateMarkovTransitions method an Iterator<String> • A MarkovText can be trained on multiple sequences

  13. Project fun • We’ve provided you with 12 Sherlock Holmes stories, plus the text of Hamlet • You can generate text from one Sherlock Holmes story, all 12, or even a Sherlock Holmes and Hamlet mashup. • Various classes provided to read/write text from files and some some automatic generation code • will work once you have implemented the project

More Related