author | Christian Urban <christian dot urban at kcl dot ac dot uk> |
Fri, 25 Sep 2015 08:51:12 +0100 | |
changeset 330 | 0806e45d873c |
parent 328 | bc03ff3d347c |
child 331 | a2c18456c6b7 |
permissions | -rw-r--r-- |
95
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
1 |
\documentclass[dvipsnames,14pt,t,xelatex]{beamer} |
252
e8ef8f38ca84
added style files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
2 |
\usepackage{../slides} |
e8ef8f38ca84
added style files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
3 |
\usepackage{../graphics} |
215
828303e8e4af
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
98
diff
changeset
|
4 |
\usepackage{../langs} |
828303e8e4af
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
98
diff
changeset
|
5 |
\usepackage{../data} |
0 | 6 |
|
252
e8ef8f38ca84
added style files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
7 |
\hfuzz=220pt |
e8ef8f38ca84
added style files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
8 |
|
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
9 |
%\setmonofont[Scale=.88]{Consolas} |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
10 |
%\newfontfamily{\consolas}{Consolas} |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
11 |
|
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
12 |
\lstset{language=Scala, |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
13 |
style=mystyle, |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
14 |
numbersep=0pt, |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
15 |
numbers=none, |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
16 |
xleftmargin=0mm} |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
17 |
|
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
18 |
\newcommand{\bl}[1]{\textcolor{blue}{#1}} |
95
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
19 |
|
0 | 20 |
% beamer stuff |
252
e8ef8f38ca84
added style files
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
21 |
\renewcommand{\slidecaption}{AFL 01, King's College London} |
0 | 22 |
|
23 |
||
24 |
\begin{document} |
|
25 |
||
26 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
27 |
\begin{frame}[t] |
0 | 28 |
\frametitle{% |
29 |
\begin{tabular}{@ {}c@ {}} |
|
1 | 30 |
\\[-3mm] |
31 |
\LARGE Automata and \\[-2mm] |
|
32 |
\LARGE Formal Languages (1)\\[-3mm] |
|
0 | 33 |
\end{tabular}} |
34 |
||
35 |
\begin{center} |
|
1 | 36 |
\includegraphics[scale=0.3]{pics/ante1.jpg}\hspace{5mm} |
37 |
\includegraphics[scale=0.31]{pics/ante2.jpg}\\ |
|
38 |
\footnotesize\textcolor{gray}{Antikythera automaton, 100 BC (Archimedes?)} |
|
0 | 39 |
\end{center} |
40 |
||
41 |
\normalsize |
|
42 |
\begin{center} |
|
43 |
\begin{tabular}{ll} |
|
44 |
Email: & christian.urban at kcl.ac.uk\\ |
|
95
dbe49327b6c5
added new stuff
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
93
diff
changeset
|
45 |
Office: & S1.27 (1st floor Strand Building)\\ |
0 | 46 |
Slides: & KEATS |
47 |
\end{tabular} |
|
48 |
\end{center} |
|
49 |
||
50 |
||
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
51 |
\end{frame} |
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
52 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
0 | 53 |
|
54 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
55 |
\begin{frame}[c] |
|
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
56 |
\frametitle{The Goal of this Course} |
0 | 57 |
|
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
58 |
\begin{center} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
59 |
\begin{tikzpicture}[scale=1, |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
60 |
node/.style={ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
61 |
rectangle,rounded corners=3mm, |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
62 |
very thick,draw=black!50,minimum height=18mm, minimum width=20mm, |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
63 |
top color=white,bottom color=black!20}] |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
64 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
65 |
\node at (3.05, 1.8) {\Large\bf A Compiler}; |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
66 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
67 |
\node (0) at (-2.3,0) {}; |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
68 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
69 |
\node (A) at (0,0) [node] {}; |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
70 |
\node [below right] at (A.north west) {lexer}; |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
71 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
72 |
\node (B) at (3,0) [node] {}; |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
73 |
\node [below right=1mm] at (B.north west) {\mbox{}\hspace{-1mm}parser}; |
0 | 74 |
|
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
75 |
\node (C) at (6,0) [node] {}; |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
76 |
\node [below right] at (C.north west) {\mbox{}\hspace{-1mm}code gen}; |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
77 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
78 |
\node (1) at (8.4,0) {}; |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
79 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
80 |
\draw [->,line width=4mm] (0) -- (A); |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
81 |
\draw [->,line width=4mm] (A) -- (B); |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
82 |
\draw [->,line width=4mm] (B) -- (C); |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
83 |
\draw [->,line width=4mm] (C) -- (1); |
0 | 84 |
\end{tikzpicture} |
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
85 |
\end{center} |
0 | 86 |
|
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
87 |
\only<2,3>{ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
88 |
\begin{textblock}{1}(1,2) |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
89 |
\begin{bubble}[9.8cm] |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
90 |
\normalsize |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
91 |
lexer input: a string\smallskip\\ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
92 |
\hspace{5mm}\code{"read(n);"}\medskip\\ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
93 |
lexer output: a sequence of tokens\smallskip\\ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
94 |
\hspace{5mm}\code{key(read); lpar; id(n); rpar; semi} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
95 |
\end{bubble} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
96 |
\end{textblock}} |
0 | 97 |
|
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
98 |
\only<3>{ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
99 |
\begin{textblock}{1}(6,7.8) |
0 | 100 |
\begin{tabular}{c} |
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
101 |
\includegraphics[scale=0.2]{../pics/rosetta.jpg}\\[-2mm] |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
102 |
\footnotesize lexing $\Rightarrow$ recognising words (Stone of Rosetta) |
0 | 103 |
\end{tabular} |
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
104 |
\end{textblock}} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
105 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
106 |
\only<4>{ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
107 |
\begin{textblock}{1}(1,1.5) |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
108 |
\begin{bubble}[8.5cm] |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
109 |
\normalsize |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
110 |
parser input: a sequence of token\smallskip\\ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
111 |
parser output: an abstract syntax tree\smallskip\\ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
112 |
\footnotesize |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
113 |
\hspace{2cm}\begin{tikzpicture} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
114 |
\node {\code{read}} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
115 |
child {node {\code{lpar}}} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
116 |
child {node {\code{n}}} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
117 |
child {node {\code{rpar}}}; |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
118 |
\end{tikzpicture} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
119 |
\end{bubble} |
1 | 120 |
\end{textblock}} |
0 | 121 |
|
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
122 |
\only<5,6>{ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
123 |
\begin{textblock}{1}(1,1.5) |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
124 |
\begin{bubble}[4cm] |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
125 |
\normalsize |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
126 |
code generator:\smallskip\\ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
127 |
\hspace{5mm}\code{istore 2}\\ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
128 |
\hspace{5mm}\code{iload 2}\\ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
129 |
\hspace{5mm}\code{ldc 10}\\ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
130 |
\hspace{5mm}\code{isub}\\ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
131 |
\hspace{5mm}\code{ifeq Label2}\\ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
132 |
\hspace{5mm}\code{iload 2}\\ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
133 |
\hspace{5mm}\code{...}\\ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
134 |
\end{bubble} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
135 |
\end{textblock}} |
1 | 136 |
|
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
137 |
\only<6>{ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
138 |
\begin{textblock}{6}(8.4,7) |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
139 |
\begin{bubble}[5cm] |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
140 |
\mbox{\begin{tikzpicture}[scale=0.58,rounded corners=0mm] |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
141 |
\begin{axis}[axis x line=bottom, axis y line=left, ylabel=secs, |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
142 |
xlabel=n, |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
143 |
enlargelimits=0.05, |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
144 |
ybar interval=0.7, legend style=small] |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
145 |
\addplot file {interpreted2.data}; |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
146 |
\addplot file {compiled2.data}; |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
147 |
%\legend{interpreted, compiled} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
148 |
\end{axis} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
149 |
\end{tikzpicture}} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
150 |
\end{bubble} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
151 |
\end{textblock}} |
1 | 152 |
|
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
153 |
\end{frame} |
1 | 154 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
155 |
||
0 | 156 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
157 |
\begin{frame}[c] |
|
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
158 |
\frametitle{The subject is quite old} |
0 | 159 |
|
160 |
\begin{itemize} |
|
1 | 161 |
\item Turing Machines, 1936 |
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
162 |
\item Regular Expressions, 1956\\ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
163 |
\item The first compiler for COBOL, 1957\\ (Grace Hopper) |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
164 |
\item But surprisingly research papers are still published nowadays |
0 | 165 |
\end{itemize} |
166 |
||
1 | 167 |
\begin{flushright} |
168 |
\includegraphics[scale=0.3]{pics/hopper.jpg}\\ |
|
169 |
\footnotesize\textcolor{gray}{Grace Hopper} |
|
170 |
\end{flushright} |
|
171 |
||
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
172 |
\mbox{}\\[-10mm] |
1 | 173 |
{\footnotesize\textcolor{gray}{(she made it to David Letterman's Tonight Show, \url{http://www.youtube.com/watch?v=aZOxtURhfEU})}} |
0 | 174 |
|
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
175 |
\end{frame} |
1 | 176 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
177 |
||
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
178 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
179 |
\begin{frame}[c] |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
180 |
\frametitle{Why Bother?} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
181 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
182 |
\begin{columns}[b] |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
183 |
\begin{column}{.5\textwidth} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
184 |
Ruby, Python\\ and Others\bigskip\\ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
185 |
\begin{tikzpicture}[y=.08cm, x=.10cm] |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
186 |
%axis |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
187 |
\draw (0,0) -- coordinate (x axis mid) (30,0); |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
188 |
\draw (0,0) -- coordinate (y axis mid) (0,30); |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
189 |
%ticks |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
190 |
\foreach \x in {0,5,...,30} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
191 |
\draw (\x,1pt) -- (\x,-3pt) node[anchor=north] {\footnotesize\x}; |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
192 |
\foreach \y in {0,5,...,30} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
193 |
\draw (1pt,\y) -- (-3pt,\y) node[anchor=east] {\footnotesize\y}; |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
194 |
%labels |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
195 |
\node[below=0.6cm] at (x axis mid) {\footnotesize number of \texttt{a}s}; |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
196 |
\node[rotate=90,left=1cm] at (y axis mid) {\footnotesize time in secs}; |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
197 |
%plots |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
198 |
\draw[color=blue] plot[mark=*] |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
199 |
file {re-python.data}; |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
200 |
\draw[color=brown] plot[mark=triangle*] |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
201 |
file {re-ruby.data}; |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
202 |
%legend |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
203 |
\begin{scope}[shift={(4,20)}] |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
204 |
\draw[color=blue] (0,0) -- |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
205 |
plot[mark=*] (0.25,0) -- (0.5,0) |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
206 |
node[right]{\small Python}; |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
207 |
\draw[yshift=-\baselineskip, color=brown] (0,0) -- |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
208 |
plot[mark=triangle*] (0.25,0) -- (0.5,0) |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
209 |
node[right]{\small Ruby}; |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
210 |
\end{scope} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
211 |
\end{tikzpicture} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
212 |
\end{column} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
213 |
\begin{column}{.5\textwidth} |
330
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
214 |
Us (after next lecture)\\\mbox{}\bigskip\\ |
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
215 |
\begin{tikzpicture}[y=.08cm, x=.0003cm] |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
216 |
%axis |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
217 |
\draw (0,0) -- coordinate (x axis mid) (12000,0); |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
218 |
\draw (0,0) -- coordinate (y axis mid) (0,30); |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
219 |
%ticks |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
220 |
\foreach \x in {0,4000,...,12000} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
221 |
\draw (\x,1pt) -- (\x,-3pt) node[anchor=north] {\footnotesize\x}; |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
222 |
\foreach \y in {0,5,...,30} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
223 |
\draw (1pt,\y) -- (-3pt,\y) node[anchor=east] {\footnotesize\y}; |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
224 |
%labels |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
225 |
\node[below=0.6cm] at (x axis mid) {\footnotesize number of \texttt{a}s}; |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
226 |
\node[rotate=90, left=1cm] at (y axis mid) {\footnotesize time in secs}; |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
227 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
228 |
%plots |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
229 |
\draw[color=green] plot[mark=square*, mark options={fill=white} ] |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
230 |
file {re2b.data}; |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
231 |
\draw[color=black] plot[mark=square*, mark options={fill=white} ] |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
232 |
file {re3.data}; |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
233 |
\end{tikzpicture} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
234 |
\end{column} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
235 |
\end{columns}\bigskip\medskip |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
236 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
237 |
\hspace{2cm}matching \texttt{[a?]\{n\}[a]\{n\}} against |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
238 |
$\underbrace{\texttt{a}...\texttt{a}}_n$ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
239 |
\end{frame} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
240 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
241 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
242 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
243 |
\begin{frame}[c] |
327
9470cd124667
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
255
diff
changeset
|
244 |
\frametitle{Lectures 1 - 5} |
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
245 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
246 |
transforming strings into structured data\\[10mm] |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
247 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
248 |
\alert<2>{\LARGE\bf Lexing} \onslide<2>{\hfill{}baseed on regular expressions}\medskip\\ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
249 |
\hspace{5mm}(recognising ``words'')\\[6mm] |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
250 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
251 |
{\LARGE\bf Parsing}\medskip\\ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
252 |
\hspace{5mm}(recognising ``sentences'') |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
253 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
254 |
\begin{textblock}{1}(10,9.1) |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
255 |
\begin{tabular}{c} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
256 |
\includegraphics[scale=0.1]{../pics/rosetta.jpg}\\[-2mm] |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
257 |
\footnotesize Stone of Rosetta |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
258 |
\end{tabular} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
259 |
\end{textblock} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
260 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
261 |
\end{frame} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
262 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
263 |
|
1 | 264 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
265 |
\begin{frame}[t] |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
266 |
\frametitle{Familiar Regular Expr.} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
267 |
\small |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
268 |
\begin{center} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
269 |
\texttt{[a-z0-9\_.-]+ @ [a-z0-9.-]+ . [a-z.]\{2,6\}} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
270 |
\end{center}\smallskip |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
271 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
272 |
\begin{center} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
273 |
\begin{tabular}{@{}lp{8.5cm}@{}} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
274 |
\pcode{re*} & matches 0 or more times\\ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
275 |
\pcode{re+} & matches 1 or more times\\ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
276 |
\pcode{re?} & matches 0 or 1 times\\ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
277 |
\pcode{re\{n\}} & matches exactly \pcode{n} number of times\\ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
278 |
\pcode{re\{n,m\}} & matches at least \pcode{n} and at most {\tt m} times\\ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
279 |
\pcode{[...]} & matches any single character inside the brackets\\ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
280 |
\pcode{[^...]} & matches any single character not inside the |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
281 |
brackets\\ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
282 |
\pcode{a-zA-Z} & character ranges\\ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
283 |
\pcode{\\d} & matches digits; equivalent to \pcode{[0-9]}\\ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
284 |
\pcode{.} & matches every character except newline\\ |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
285 |
\pcode{(re)} & groups regular expressions and remembers |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
286 |
the matched text |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
287 |
\end{tabular} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
288 |
\end{center} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
289 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
290 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
291 |
\end{frame} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
292 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
293 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
294 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1 | 295 |
\begin{frame}[c] |
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
296 |
\frametitle{Today} |
0 | 297 |
|
1 | 298 |
\begin{itemize} |
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
299 |
\item the ultimate goal is to implement a small compiler |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
300 |
(a really small one for the JVM)\bigskip |
1 | 301 |
\end{itemize} |
302 |
||
303 |
Let's start with: |
|
304 |
||
305 |
\begin{itemize} |
|
306 |
\item a web-crawler |
|
307 |
\item an email harvester |
|
327
9470cd124667
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
255
diff
changeset
|
308 |
\item \textcolor{gray}{a web-scraper} |
1 | 309 |
\end{itemize} |
310 |
||
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
311 |
\end{frame} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
312 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
0 | 313 |
|
2 | 314 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
3 | 315 |
\begin{frame}[t] |
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
316 |
\frametitle{A Web-Crawler} |
2 | 317 |
|
3 | 318 |
\mbox{}\\[10mm] |
319 |
||
2 | 320 |
\begin{enumerate} |
321 |
\item given an URL, read the corresponding webpage |
|
322 |
\item extract all links from it |
|
323 |
\item call the web-crawler again for all these links |
|
324 |
\end{enumerate} |
|
325 |
||
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
326 |
\end{frame} |
2 | 327 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
328 |
||
329 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
330 |
\mode<presentation>{ |
|
3 | 331 |
\begin{frame}[t] |
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
332 |
\frametitle{A Web-Crawler} |
2 | 333 |
|
3 | 334 |
\mbox{}\\[10mm] |
335 |
||
336 |
||
2 | 337 |
\begin{enumerate} |
338 |
\item given an URL, read the corresponding webpage |
|
339 |
\item if not possible print, out a problem |
|
340 |
\item if possible, extract all links from it |
|
341 |
\item call the web-crawler again for all these links |
|
342 |
\end{enumerate}\bigskip\pause |
|
343 |
||
3 | 344 |
\small (we need a bound for the number of recursive calls) |
2 | 345 |
|
346 |
\small (the purpose is to check all links on my own webpage) |
|
347 |
\end{frame}} |
|
348 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
349 |
||
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
350 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
351 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
352 |
\begin{frame}[c] |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
353 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
354 |
\begin{textblock}{1}(2,5) |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
355 |
\begin{tabular}{c} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
356 |
\includegraphics[scale=0.15]{pics/servers.png}\\[-2mm] |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
357 |
\small Server |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
358 |
\end{tabular} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
359 |
\end{textblock} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
360 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
361 |
\begin{textblock}{1}(5.6,4) |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
362 |
\begin{tikzpicture}[scale=1.1] |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
363 |
\draw[white] (0,1) node (X) {}; |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
364 |
\draw[white] (2,1) node (Y) {}; |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
365 |
\draw[white] (0,0) node (X1) {}; |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
366 |
\draw[white] (2,0) node (Y1) {}; |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
367 |
\draw[white] (0,-1) node (X2) {}; |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
368 |
\draw[white] (2,-1) node (Y2) {}; |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
369 |
\draw[red, <-, line width = 2mm] (X) -- (Y); |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
370 |
\node [inner sep=5pt,label=above:\textcolor{black}{GET request}] at ($ (X)!.5!(Y) $) {}; |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
371 |
\draw[red, ->, line width = 2mm] (X1) -- (Y1); |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
372 |
\node [inner sep=5pt,label=above:\textcolor{black}{webpage}] at ($ (X1)!.5!(Y1) $) {}; |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
373 |
\draw[red, <-, line width = 2mm] (X2) -- (Y2); |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
374 |
\node [inner sep=7pt,label=above:\textcolor{black}{POST data}] at ($ (X2)!.5!(Y2) $) {}; |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
375 |
\end{tikzpicture} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
376 |
\end{textblock} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
377 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
378 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
379 |
\begin{textblock}{1}(9,5.5) |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
380 |
\begin{tabular}{c} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
381 |
\includegraphics[scale=0.15]{pics/laptop.png}\\[-2mm] |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
382 |
\small Browser |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
383 |
\end{tabular} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
384 |
\end{textblock} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
385 |
\end{frame} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
386 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
387 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
388 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
389 |
|
0 | 390 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
391 |
\begin{frame}[c] |
|
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
392 |
\frametitle{Scala} |
1 | 393 |
|
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
394 |
\small A simple Scala function for reading webpages: |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
395 |
\smallskip |
0 | 396 |
|
98
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
397 |
\footnotesize |
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
398 |
\lstinputlisting{../progs/app0.scala} |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
399 |
\medskip\pause |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
400 |
|
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
401 |
\lstinline{get_page("""http://www.inf.kcl.ac.uk/staff/urbanc/""")} |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
402 |
\bigskip\medskip\pause |
0 | 403 |
|
3 | 404 |
|
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
405 |
\small A slightly more complicated version for handling errors properly: |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
406 |
\smallskip |
2 | 407 |
|
98
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
408 |
\footnotesize |
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
409 |
\lstinputlisting{../progs/app1.scala} |
1 | 410 |
|
0 | 411 |
|
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
412 |
\end{frame} |
0 | 413 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
414 |
||
415 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
98
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
416 |
\begin{frame}[c] |
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
417 |
\frametitle{Why Scala?} |
98
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
418 |
|
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
419 |
\begin{textblock}{6}(1,3) |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
420 |
\begin{tabular}{l} |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
421 |
\mbox{}\hspace{-1mm}\includegraphics[scale=0.36]{pics/twitter.png}\\[-1mm] |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
422 |
\includegraphics[scale=0.30]{pics/linked.png}\\ |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
423 |
\includegraphics[scale=0.30]{pics/guardian.jpg}\\[-3mm] |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
424 |
\mbox{}\hspace{-2mm}\includegraphics[scale=0.38]{pics/morgan.png}\\[-3mm] |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
425 |
\includegraphics[scale=0.30]{pics/suisse.png}\\ |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
426 |
\includegraphics[scale=0.20]{pics/edf.png}\\[-1mm] |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
427 |
\includegraphics[scale=0.08]{pics/novell.png}\\[-1mm] |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
428 |
\includegraphics[scale=0.30]{pics/foursquare.png}\\ |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
429 |
\includegraphics[scale=0.30]{pics/hsbc.png}\\ |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
430 |
{\large\bf ...} |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
431 |
\end{tabular} |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
432 |
\end{textblock} |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
433 |
|
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
434 |
\only<2->{ |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
435 |
\begin{textblock}{6}(6,3) |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
436 |
\includegraphics[scale=0.35]{pics/jobgraph.png}\\ |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
437 |
\end{textblock}} |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
438 |
|
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
439 |
\only<3->{ |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
440 |
\begin{textblock}{6}(7.3,9.2) |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
441 |
\begin{tabular}{l} |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
442 |
\footnotesize 2013: 1$\%$\\[-2mm] |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
443 |
\footnotesize 2014: 3$\%$\\[-2mm] |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
444 |
\footnotesize 2015: 9$\%$\\[-2mm] |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
445 |
\footnotesize 2016: 27$\%$\\[-2mm] |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
446 |
\footnotesize 2017: 81$\%$\\[-2mm] |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
447 |
\footnotesize 2018: 243$\%$ \raisebox{-1mm}{\includegraphics[scale=0.02]{pics/smiley.jpg}} |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
448 |
\end{tabular} |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
449 |
\end{textblock}} |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
450 |
|
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
451 |
\only<3->{ |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
452 |
\begin{textblock}{6}(6,9.5) |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
453 |
\footnotesize 5 yrs $\begin{cases}\mbox{}\\[1.4cm]\end{cases}$ |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
454 |
\end{textblock}} |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
455 |
|
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
456 |
\only<4->{ |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
457 |
\begin{textblock}{11}(5,14.1) |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
458 |
\textcolor{gray}{ |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
459 |
\footnotesize {\bf in London today:} 1 Scala job for every 30 Java jobs;\\[-2mm] |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
460 |
Scala programmers seem to get up to 20\% better salary} |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
461 |
\end{textblock}} |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
462 |
|
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
463 |
|
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
464 |
\only<5->{ |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
465 |
\begin{textblock}{1}(3,6) |
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
466 |
\begin{bubble}[8.5cm] |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
467 |
\normalsize |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
468 |
Scala is a functional and object-oriented programming |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
469 |
language; compiles to the JVM; does not need null-pointer |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
470 |
exceptions; a course on Coursera\\ |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
471 |
\mbox{}\hfill\url{http://www.scala-lang.org} |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
472 |
\end{bubble} |
98
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
473 |
\end{textblock}} |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
474 |
|
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
475 |
\end{frame} |
98
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
476 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
477 |
|
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
478 |
|
1f3d89fe9820
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
479 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
3 | 480 |
\begin{frame}[t] |
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
481 |
\frametitle{A Regular Expression} |
3 | 482 |
|
483 |
\begin{itemize} |
|
484 |
\item \ldots{} is a pattern or template for specifying strings |
|
485 |
\end{itemize}\bigskip |
|
486 |
||
487 |
\begin{center} |
|
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
488 |
\only<1>{\scode{"https?://[^"]*"}}% |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
489 |
\only<2>{\scode{""""https?://[^"]*"""".r}} |
3 | 490 |
\end{center}\bigskip\bigskip |
491 |
||
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
492 |
matches for example\smallskip\\ |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
493 |
\hspace{2mm}\code{"http://www.foobar.com"}\\ |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
494 |
\hspace{2mm}\code{"https://www.tls.org"}\\ |
3 | 495 |
|
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
496 |
\end{frame} |
3 | 497 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
498 |
||
499 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
500 |
\begin{frame}[t] |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
501 |
\frametitle{Finding Operations} |
0 | 502 |
|
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
503 |
{\bf\code{rexp.findAllIn(string)}}\medskip |
3 | 504 |
|
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
505 |
returns a list of all (sub)strings that match the |
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
506 |
regular expression |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
507 |
\bigskip\bigskip |
0 | 508 |
|
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
509 |
|
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
510 |
{\bf\code{rexp.findFirstIn(string)}}\medskip |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
511 |
|
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
512 |
returns either |
0 | 513 |
|
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
514 |
\begin{itemize} |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
515 |
\item \code{None} if no (sub)string matches or |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
516 |
\item \code{Some(s)} with the first (sub)string |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
517 |
\end{itemize} |
0 | 518 |
|
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
519 |
\end{frame} |
0 | 520 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
521 |
||
522 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
3 | 523 |
\begin{frame}[c] |
0 | 524 |
|
3 | 525 |
\footnotesize |
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
526 |
\lstinputlisting{../progs/app2.scala} |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
527 |
|
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
528 |
\end{frame} |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
529 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
0 | 530 |
|
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
531 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
532 |
\begin{frame}[c] |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
533 |
|
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
534 |
\small |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
535 |
A version that only crawls links in ``my'' domain: |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
536 |
|
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
537 |
\footnotesize |
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
538 |
\lstinputlisting{../progs/app3.scala} |
0 | 539 |
|
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
540 |
\end{frame} |
0 | 541 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
542 |
||
543 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
544 |
\begin{frame}[c] |
|
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
545 |
\lstset{xleftmargin=-4mm} |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
546 |
\small |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
547 |
A little email harvester: |
3 | 548 |
|
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
549 |
\footnotesize |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
550 |
\lstinputlisting{../progs/app4.scala}\bigskip |
3 | 551 |
|
552 |
\tiny |
|
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
553 |
\url{http://net.tutsplus.com/tutorials/other/8-regular-expressions-you-should-know/} |
3 | 554 |
|
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
555 |
\end{frame} |
3 | 556 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
557 |
||
558 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
14 | 559 |
\begin{frame}[t] |
3 | 560 |
\frametitle{\begin{tabular}{c}Regular Expressions\end{tabular}} |
0 | 561 |
|
330
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
562 |
Their inductive definition: |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
563 |
|
14 | 564 |
|
330
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
565 |
\begin{textblock}{6}(2,7.5) |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
566 |
\begin{tabular}{@ {}rrl@ {\hspace{13mm}}l} |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
567 |
\bl{$r$} & \bl{$::=$} & \bl{$\varnothing$} & null\\ |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
568 |
& \bl{$\mid$} & \bl{$\epsilon$} & empty string / \pcode{""} / $[]$\\ |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
569 |
& \bl{$\mid$} & \bl{$c$} & character\\ |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
570 |
& \bl{$\mid$} & \bl{$r_1 + r_2$} & alternative / choice\\ |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
571 |
& \bl{$\mid$} & \bl{$r_1 \cdot r_2$} & sequence\\ |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
572 |
& \bl{$\mid$} & \bl{$r^*$} & star (zero or more)\\ |
3 | 573 |
\end{tabular} |
574 |
\end{textblock} |
|
575 |
||
330
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
576 |
|
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
577 |
\only<2->{\footnotesize |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
578 |
\begin{textblock}{9}(2,0.5) |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
579 |
\begin{bubble}[9.8cm] |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
580 |
\lstinputlisting{../progs/app01.scala} |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
581 |
\end{bubble} |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
582 |
\end{textblock}} |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
583 |
|
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
584 |
\end{frame} |
3 | 585 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
586 |
||
587 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
588 |
\begin{frame}[t] |
|
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
589 |
\frametitle{Regular Expressions} |
3 | 590 |
|
14 | 591 |
\small |
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
592 |
In Scala:\bigskip |
14 | 593 |
|
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
594 |
\footnotesize |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
595 |
\lstinputlisting{../progs/app51.scala} |
0 | 596 |
|
597 |
||
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
598 |
\end{frame} |
0 | 599 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
600 |
||
601 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
602 |
\begin{frame}[t] |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
603 |
\frametitle{Strings} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
604 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
605 |
\ldots are lists of characters. For example \code{"hello"} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
606 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
607 |
\begin{center} |
330
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
608 |
\bl{$[h, e, l, l, o]$} or just \bl{$hello$} |
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
609 |
\end{center} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
610 |
|
330
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
611 |
the empty string: \bl{$[]$} or \bl{\pcode{""}}\bigskip\\ |
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
612 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
613 |
the concatenation of two strings: |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
614 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
615 |
\begin{center} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
616 |
\bl{$s_1 \,@\, s_2$} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
617 |
\end{center} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
618 |
|
330
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
619 |
\bl{\textit{foo $@$ bar = foobar}, \textit{baz $@\, []$ = baz}} |
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
620 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
621 |
\end{frame} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
622 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
623 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
624 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
330
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
625 |
\begin{frame}[c] |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
626 |
\frametitle{Languages, Strings} |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
627 |
|
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
628 |
\begin{itemize} |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
629 |
\item \alert{\bf Strings} are lists of characters, for example |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
630 |
\begin{center} |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
631 |
\bl{$[]$},\;\bl{$abc$} \hspace{2cm}(Pattern match: \bl{$c\!::\!s$}) |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
632 |
\end{center}\bigskip |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
633 |
|
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
634 |
|
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
635 |
\item A \alert{\bf language} is a set of strings, for example\medskip |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
636 |
\begin{center} |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
637 |
\bl{$\{[], hello, \textit{foobar}, a, abc\}$} |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
638 |
\end{center}\bigskip |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
639 |
|
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
640 |
\item \alert{\bf Concatenation} of strings and sets |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
641 |
|
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
642 |
\begin{center} |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
643 |
\begin{tabular}{rcl} |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
644 |
\bl{$\textit{foo}\;@\;bar$} & \bl{$=$} & \bl{$\textit{foobar}$}\medskip\\ |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
645 |
\bl{$A\;@\;B$} & \bl{$\dn$} & \bl{$\{ s_1\,@\,s_2 \;\mid\; s_1 \in A \wedge s_2 \in B\}$} |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
646 |
\end{tabular} |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
647 |
\end{center} |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
648 |
|
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
649 |
%\item The \alert{\bf meaning} of a regular expression is a set of |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
650 |
% strings, or language. |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
651 |
\end{itemize} |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
652 |
|
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
653 |
\end{frame} |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
654 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
655 |
|
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
656 |
|
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
657 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
0 | 658 |
\mode<presentation>{ |
659 |
\begin{frame}[c] |
|
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
660 |
\frametitle{\begin{tabular}{c}The Meaning of a\\[-2mm] |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
661 |
Regular Expression\end{tabular}} |
0 | 662 |
|
4 | 663 |
\begin{textblock}{15}(1,4) |
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
664 |
\begin{tabular}{rcl} |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
665 |
\bl{$L(\varnothing)$} & \bl{$\dn$} & \bl{$\varnothing$}\\ |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
666 |
\bl{$L(\epsilon)$} & \bl{$\dn$} & \bl{$\{[]\}$}\\ |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
667 |
\bl{$L(c)$} & \bl{$\dn$} & \bl{$\{[c]\}$}\\ |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
668 |
\bl{$L(r_1 + r_2)$} & \bl{$\dn$} & \bl{$L(r_1) \cup L(r_2)$}\\ |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
669 |
\bl{$L(r_1 \cdot r_2)$} & \bl{$\dn$} & \bl{$\{ s_1 \,@\, s_2 \;|\; s_1 \in L(r_1) \wedge s_2 \in L(r_2) \}$}\\ |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
670 |
\bl{$L(r^*)$} & \bl{$\dn$} & \onslide<4->{\bl{$\bigcup_{n \ge 0} L(r)^n$}}\\ |
4 | 671 |
\end{tabular}\bigskip |
3 | 672 |
|
4 | 673 |
\onslide<2->{ |
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
674 |
\hspace{5mm}\bl{$L(r)^0 \;\dn\; \{[]\}$}\\ |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
675 |
\bl{$L(r)^{n+1} \;\dn\; L(r) \,@\, L(r)^n$}\hspace{9mm}\onslide<3->{\small\textcolor{gray}{(append on sets)}\\ |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
676 |
\small\hspace{5cm}\textcolor{gray}{$\{ s_1 @ s_2 \;|\; s_1\in L(r) \wedge s_2 \in L(r)^n \}$}} |
4 | 677 |
} |
678 |
\end{textblock} |
|
679 |
||
0 | 680 |
\end{frame}} |
681 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
682 |
||
5 | 683 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
684 |
\begin{frame}[c] |
|
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
685 |
\frametitle{The Meaning of Matching} |
5 | 686 |
|
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
687 |
\begin{bubble}[10cm] |
5 | 688 |
\large |
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
689 |
A regular expression \bl{$r$} matches a string \bl{$s$} |
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
690 |
provided |
5 | 691 |
|
692 |
\begin{center} |
|
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
693 |
\bl{$s \in L(r)$}\\ |
5 | 694 |
\end{center} |
330
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
695 |
\end{bubble}\bigskip\bigskip |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
696 |
|
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
697 |
\ldots and the point of the next lecture is |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
698 |
to decide this problem as fast as possible (unlike Python, |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
699 |
Ruby) |
5 | 700 |
|
254
dcd4688690ce
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
253
diff
changeset
|
701 |
\end{frame} |
5 | 702 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
703 |
||
0 | 704 |
|
705 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
706 |
\begin{frame}[c] |
|
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
707 |
\frametitle{Written Exam} |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
708 |
|
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
709 |
\begin{itemize} |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
710 |
\item Accounts for 75\%.\bigskip |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
711 |
|
330
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
712 |
\item You will understand the question ``\textit{Is this relevant for |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
713 |
the exam?}'' is very demotivating for the lecturer!\bigskip\\ |
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
714 |
|
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
715 |
\item Deal: Whatever is in the homework (and is not marked |
330
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
716 |
``\textit{optional}'') is relevant for the exam.\bigskip |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
717 |
|
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
718 |
\item Each lecture has also a handout. There are also handouts about |
0806e45d873c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
328
diff
changeset
|
719 |
notation and Scala. |
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
720 |
\end{itemize} |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
721 |
|
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
722 |
\end{frame} |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
723 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
724 |
|
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
725 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
726 |
\begin{frame}[t] |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
727 |
\frametitle{Coursework} |
0 | 728 |
|
729 |
\begin{itemize} |
|
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
730 |
\item Accounts for 25\%. Two strands. Choose \alert{\bf one}!\bigskip |
0 | 731 |
\end{itemize} |
732 |
||
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
733 |
\begin{columns}[t] |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
734 |
\begin{column}{.5\textwidth} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
735 |
\underline{\bf Strand 1}\medskip |
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
736 |
\begin{itemize} |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
737 |
\item four programming subtasks: |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
738 |
\begin{itemize} |
328
bc03ff3d347c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
327
diff
changeset
|
739 |
\item matcher (5\%, 16.10.) |
bc03ff3d347c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
327
diff
changeset
|
740 |
\item lexer (5\%, 06.11.) |
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
741 |
\item parser (5\%, 27.11.) |
328
bc03ff3d347c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
327
diff
changeset
|
742 |
\item compiler (10\%, 11.12.) |
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
743 |
\end{itemize} |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
744 |
\end{itemize} |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
745 |
\end{column} |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
746 |
|
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
747 |
\hspace{-45pt}\vrule{}\hspace{10pt} |
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
748 |
\begin{column}{.5\textwidth} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
749 |
\underline{\bf Strand 2}\smallskip\begin{itemize} |
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
750 |
\item one task: prove the correctness of a regular expression matcher in |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
751 |
the Isabelle theorem prover |
328
bc03ff3d347c
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
327
diff
changeset
|
752 |
\item 25\%, submission 11.12. |
253
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
753 |
\end{itemize} |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
754 |
\end{column} |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
755 |
\end{columns}\medskip |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
756 |
|
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
757 |
\small |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
758 |
\begin{itemize} |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
759 |
\item Solving more than one strand will {\bf not} give you more |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
760 |
marks.\\[-2mm] |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
761 |
\item The exam will contain in much, much smaller form |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
762 |
elements from both (but will also be in lectures and HW). |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
763 |
\end{itemize} |
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
764 |
|
75c469893514
added coursework
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
252
diff
changeset
|
765 |
\end{frame} |
0 | 766 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
767 |
||
255
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
768 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
769 |
\begin{frame}[c] |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
770 |
\frametitle{\begin{tabular}{c}\\[3cm]\alert{Questions?}\end{tabular}} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
771 |
|
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
772 |
\mbox{} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
773 |
\end{frame} |
96a99237fa42
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
254
diff
changeset
|
774 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
0 | 775 |
\end{document} |
776 |
||
777 |
%%% Local Variables: |
|
778 |
%%% mode: latex |
|
779 |
%%% TeX-master: t |
|
780 |
%%% End: |
|
781 |