By: Robert Apeldorn.  Generate statistical random texts that can be read well  Allow for the output texts to be created quickly regardless the size.

Slides:



Advertisements
Similar presentations
Come.
Advertisements

Michael Alves, Patrick Dugan, Robert Daniels, Carlos Vicuna
The Linux Operating System Lecture 6: Perl for the Systems Administrator Tonga Institute of Higher Education.
Input & Output Machines
Introduction to Flowcharting A Supplement to Starting Out with C++, 4th Edition by Tony Gaddis Published by Addison-Wesley.
Java Planning our Programs Flowcharts Arithmetic Operators.
References and Data Structures. References Just as in C, you can create a variable that is a reference (or pointer) to another variable. That is, it contains.
Design and Implementation* Objective: To design and implement a program for a relatively small yet reasonably complicated problem. To introduce and review.
Assigned “term” Prefix or Suffix ?. definition Origin or prefix/suffix Definition.
Markov Chain Algorithm in Perl Yu-Chung Chau CS 265.
Algorithm and Flowchart Questions
Chapter 20 Thinking Big: Functions. Copyright © 2006 Pearson Addison-Wesley. All rights reserved Anatomy of a Function Functions are packages for.
Flowcharts Remember that a solution to a problem is called an algorithm. Algorithms are often a series of steps required to solve the problem. A flowchart.
Introduction to Perl. How to run perl Perl is an interpreted language. This means you run it through an interpreter, not a compiler. Your program/script.
Arrays Ethan Cerami New York University Today n Array Basics (Review) n Random Number Example n Passing Arrays to Functions n Strings.
Chapter 2: Algorithm Discovery and Design
CS0007: Introduction to Computer Programming Introduction to Arrays.
20-753: Fundamentals of Web Programming Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 8: Perl Basics Fundamentals of Web Programming.
Every week: Sign in at the door If you are new: Fill in Registration Form Ask a Mentor how to get started Make sure you are on the Athenry Parents/Kids.
Introduction to Perl Part III By: Cedric Notredame Adapted from (BT McInnes)
PERL Variables and data structures Andrew Emerson, High Performance Systems, CINECA.
– Intermediate Perl 9/16/ Intermediate Perl - References Intermediate Perl Session 1 · references · complex data structres.
Wow! I Didn’t Know I Could Do That with iThink/STELLA! Also known as the Ron Popeil (aka Ronco) approach: “But wait, there’s more!!” Chris Soderquist Pontifex.
Invitation to Computer Science, Java Version, Second Edition.
MCB 5472 Assignment #6: HMMER and using perl to perform repetitive tasks February 26, 2014.
[0][1][2][3][4][5][6][7][8][9] Bing David Ina Abhinav Erik Hyun Jim Fiona Gheeta Chelsea I can easily loop through all the student records by using a.
ECMM6018 Enterprise Networking For Electronic Commerce Tutorial 5 Server Side Scripting Perl.
4 1 Array and Hash Variables CGI/Perl Programming By Diane Zak.
CIS 280 Hashing and Hash Tables. Calendar Today: Hashing and Hash Tables Wednesday: Calculus due, work Friday: Cuckoo hashing and linear hashing Monday:
Conditions. Objectives  Understanding what altering the flow of control does on programs and being able to apply thee to design code  Look at why indentation.
Comp 335 File Structures Hashing.
Computer Science – Truth Jam Table JamBreadSandwich Yes No YesNo YesNo TeaMilkDrink No Yes NoYes NoYes What am I getting at?
Sed, awk, & perl CS 2204 Class meeting 13 *Notes by Mir Farooq Ali and other members of the CS faculty at Virginia Tech. Copyright 2003.
Strings and Pattern Matching Algorithms Pattern P[0..m-1] Text T[0..n-1] Brute Force Pattern Matching Algorithm BruteForceMatch(T,P): Input: Strings T.
1 Content-Aware Device Benchmarking Methodology/Terminology (draft-ietf-bmwg-ca-bench-meth-00) BMWG Meeting IETF-82 Taipei November 2011 Mike Hamilton.
Chapter 9: Perl Programming Practical Extraction and Report Language Some materials are taken from Sams Teach Yourself Perl 5 in 21 Days, Second Edition.
Introduction to Perl Part III By: Bridget Thomson McInnes 6 Feburary 2004.
A relation is an operation, or series of operations, that maps one number onto another.
1 Computer Science of Graphics and Games MONT 105S, Spring 2009 Session 1 Simple Python Programs Using Print, Variables, Input.
An Intro to Perl, Pt. 2 Hashes, Foreach Control, and the Split Function.
Lesson 1 Operating Systems, Part 1. Objectives Describe and list different operating systems Understand file extensions Manage files and folders.
5 1 Data Files CGI/Perl Programming By Diane Zak.
Sight Word List.
Programming Logic and Design Fourth Edition, Comprehensive Chapter 8 Arrays.
Chapter Twelve sed, awk & perl1 System Programming sed, awk & perl.
Digital Text and Data Processing Tokenisation. Today’s class □ Tokenisation and creation of frequency lists □ Keyword in context lists □ Moretti and distant.
Slide 1 Controlling Sequences of Events Traffic lights Event table.
Introduction to Perl NICOLE VECERE. Background General Purpose Language ◦ Procedural, Functional, and Object-oriented Developed for text manipulation.
Department of Electrical and Computer Engineering Introduction to Perl By Hector M Lugo-Cordero August 26, 2008.
Introduction to compilation process March 24. The following slides will show you step by step instruction how to get ready and build C language programs.
1 Content-Aware Device Benchmarking Methodology/Terminology (draft-ietf-bmwg-ca-bench-meth-01) BMWG Meeting IETF-83 Paris March 2012 Mike Hamilton
Beginning Fortran Introduction 13 October 2009 *Black text on white background provided for easy printing.
By: Jordan Hofstaedter. Make random outputs from inputs that actually make sense. If we let the computer produce random letters in English, chances are.
Python – May 16 Recap lab Simple string tokenizing Random numbers Tomorrow: –multidimensional array (list of list) –Exceptions.
JavaScript Functions. CSS Inheritance Which formatting applies? x y z input { display: block; } input.pref { background:red; } If you have a selector.
Markov Chain Algorithm in Perl Michael Conway CS 265 May 4, 2011.
CSC 4630 Meeting 17 March 21, Exam/Quiz Schedule Due to ice, travel, research and other commitments that we all have: –Quiz 2, scheduled for Monday.
Today's Ninja Challenge: Write Your First Computer Game!
Dept. of Animal Breeding and Genetics Programming basics & introduction to PERL Mats Pettersson.
CSC 4630 Perl 3 adapted from R. E. Beck. Problem But we worked on it first: Input: Read from a text file named in a command line argument Output: List.
Functions Commands Programming Steps Examples Printing Homework Hints.
Efficient Map Path Finding with Realistic Conditions Third Quarter Version Olex Ponomarenko.
Introduction to Programming the WWW I CMSC Winter 2004 Lecture 8.
CSC 212 – Data Structures Lecture 28: More Hash and Dictionaries.
Hash Tables in C Louis Manco.
Xamarin Intermediate for iOS development
Design and Implementation*
Markov-Chain Algorithm In Perl
See requirements for practice program on next slide.
Rate of Change The rate of change is the change in y-values over the change in x-values.
Presentation transcript:

By: Robert Apeldorn

 Generate statistical random texts that can be read well  Allow for the output texts to be created quickly regardless the size of the input text

 The markov chain algorithm emits output phrases by randomly choosing a suffix that follows the prefix  Suppose we have the text: “Show your flowcharts and conceal your tables and I will be mystified. Show your tables and your flowcharts will be obvious.” (end)

Input Prefix:Suffix words that follow: Show yourflowcharts tables your flowchartsand will flowcharts andconceal flowcharts willbe your tablesand will bemystified. obvious. be mystified.Show be obvious.(end)

 As I started up the undershirt onto his chest black, and big stomach muscles bulging under the light. “You see them?” Below the line where his ribs stopped were tow raised white welts. “See on the forehead.” “Oh, Brett I love you.” “Lets not talk. Talking’s all bilge. I’m going away tomorrow.” “Tomorrow?” “Yes. Didn’t I say so? I am.” “Let’s have a drink, then.”

 Use an anonymous array to keep track of the suffixes  Use a multiple assignment method to update the prefix  Special characters needed: $ for for indexed array, use [ ] brackets to index Use { } brackets to index hashes

# markov.pl: markov chain algorithm for 2-word prefixes $MAXGEN = 10000; $NONWORD = "\n"; $w1 = $w2 = $NONWORD; # initial state while (<>) { # read each line of input foreach (split) { $_); ($w1, $w2) = ($w2, $_);# multiple assignment } $NONWORD); # add tail $w1 = $w2 = $NONWORD; for ($i = 0; $i < $MAXGEN; $i++) { $suf = $statetab{$w1}{$w2};# array reference $r is number of elems exit if (($t = $suf->[$r]) eq $NONWORD); print "$t\n"; ($w1, $w2) = ($w2, $t);# advance chain }

Programming Language Time (seconds)Lines of source code C Java C++/STL/list1.570 Awk2.120 Perl1.018

 Kernighan, Brian W., and Rob Pike. The Practice of Programming (Addison-Wesley Professional Computing Series). New York: Addison-Wesley Professional, Print.