Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSCE 121, Sec 200, 507, 508 Overview of Chapters 23 and 24 Fall 2010 Prof. Jennifer L. Welch.

Similar presentations


Presentation on theme: "CSCE 121, Sec 200, 507, 508 Overview of Chapters 23 and 24 Fall 2010 Prof. Jennifer L. Welch."— Presentation transcript:

1 CSCE 121, Sec 200, 507, 508 Overview of Chapters 23 and 24 Fall 2010 Prof. Jennifer L. Welch

2 Ch 23: Text Manipulation Running example of analyzing email logs using – strings – iostreams – maps Introduces regular expressions: – way of concisely describing patterns in text CSCE 121-2002

3 Mail File xxx ---- From: John Doe To: Mary Smith Subject: Saying Hello Date: Fri, 21 Nov 1997 09:55:06 -0600 Message-ID: This is a message just to say hello. So, "Hello". ---- From: Joe Q. Public To: Mary Smith, jdoe@test.example Date: Tue, 1 Jul 2003 10:52:37 +0200 Message-ID: Hi everyone. ---- To: "Mary Smith: Personal Account" From: John Doe Subject: Re: Saying Hello Date: Fri, 21 Nov 1997 11:00:00 -0600 Message-ID: In-Reply-To: References: This is a reply to your reply. ---- --- CSCE 121-2003 Want to find all messages from “John Doe” and print out their subjects Want to find all messages from “John Doe” and print out their subjects

4 Overview Read entire mail file into a “Mail_file” data structure: – vector : holds all the lines of the mail file, one line per vector entry – vector : indicates the sequence of messages; each message is represented by an iterator (pointer) to the first line of the message and an iterator to the last line of the message CSCE 121-2004

5 Overview for each message in the Mail_file do: – find the sender of the message – make a pair of the sender (the key) and the entire message (the value) – insert the pair into a multimap (a map in which a key can occur multiple times with different values) Use function equal_range of multimap to iterate through the multimap to get each message with key “John Doe” and find its subject CSCE 121-2005

6 Regular Expressions How can we efficiently find the sender and the subject of each message in the mail file? More generally, how can we concisely express certain patterns in text and how can we efficiently locate them? Use concept of regular expressions, which provide ways to express – repeating patterns – groupings of pieces of the expression – alternation (options) CSCE 121-2006

7 Regular Expressions There is an elegant theory of regular expressions Efficient implementation techniques are based on the concept of finite state machines More information on the theory in CSCE 222 and CSCE 433 Regular expressions are available in many programming languages and many different “dialects” CSCE 121-2007

8 Regular Expression Example Using the syntax that will be in the next version of C++: Subject: (FW:|Re:)?(.*) recognizes an email subject line with an optional “FW:” or “Re:”, followed by zero or more characters. CSCE 121-2008

9 Ch 24: Numerics Overview of some fundamental language and library facilities that support numeric computation Problems of size, precision and truncation are addressed bulk of the chapter discusses multi-dimensional arrays (C- style and an n-dimensional matrix library random numbers: useful in testing, simulation, and games list of standard mathematical functions introduce standard library complex numbers CSCE 121-2009


Download ppt "CSCE 121, Sec 200, 507, 508 Overview of Chapters 23 and 24 Fall 2010 Prof. Jennifer L. Welch."

Similar presentations


Ads by Google