computation as an expressive mediumhomes.lmc.gatech.edu/~bmagerko6/classes/lcc6310/slides/...agenda...

54
Computation as an Expressive Computation as an Expressive Medium Medium Medium Medium Lab Lab 9: Lamb Chop’s Play : Lamb Chop’s Play-Along Along Joshua Cuneo Joshua Cuneo

Upload: trantu

Post on 21-Mar-2018

219 views

Category:

Documents


4 download

TRANSCRIPT

Computation as an Expressive Computation as an Expressive MediumMediumMediumMedium

Lab Lab 99: Lamb Chop’s Play: Lamb Chop’s Play--AlongAlong

Joshua CuneoJoshua Cuneo

AgendaAgendaAgendaAgenda

RecursionRecursionHTMLHTML Parsing PartParsing Part II III IHTML HTML Parsing, Part Parsing, Part II.III.IProject Project 4 4 + Examples+ Examples

RecursionRecursionRecursionRecursion

void method1()void method1() {

println("I'm in method 1");th d2()method2();

}

void method2() {

println("I'm in method 2");p ( );}

RecursionRecursionRecursionRecursionid th d1()void method1()

{println("Beginning of method 1");method1();println("End of method 1");

}}

Rec sionRec sionRecursionRecursionRecursion basically means calling aRecursion basically means calling aRecursion basically means calling a Recursion basically means calling a method from inside itself.method from inside itself.

int factorial(int n) {if(n > 1) {

What the?!?

if(n > 1) {return n * factorial(n-1);

}l t 1else return 1;

}

Inside Itself?!Inside Itself?!Inside Itself?!Inside Itself?!f t i l(3) i t f t i l(i t ) { ( 3)factorial(3); int factorial(int n) {

if(n > 1) {return n * factorial(n-1);

}

(n = 3)

}else return 1;

}

Inside Itself?!Inside Itself?!Inside Itself?!Inside Itself?!factorial(3); int factorial(int n) { (n 3)factorial(3); int factorial(int n) {

if(n > 1) {return n * factorial(n-1);

}else return 1;

(n = 3)

;}

int factorial(int n) {if(n > 1) {return n * factorial(n 1);

(n = 2)

return n * factorial(n-1);}else return 1;

}

Inside Itself?!Inside Itself?!Inside Itself?!Inside Itself?!factorial(3); int factorial(int n) { (n 3) int factorial(int n) { (n 2)factorial(3); int factorial(int n) {

if(n > 1) {return n * factorial(n-1);

}else return 1;

(n = 3) int factorial(int n) {if(n > 1) {

return n * factorial(n-1);}else return 1;

(n = 2)

;}

;}

int factorial(int n) {if(n > 1) {

(n = 1) if(n > 1) {return n * factorial(n-1);

}else return 1;

}

Inside Itself?!Inside Itself?!Inside Itself?!Inside Itself?!factorial(3); int factorial(int n) { (n 3) int factorial(int n) { (n 2)factorial(3); int factorial(int n) {

if(n > 1) {return n * factorial(n-1);

}else return 1;

(n = 3) int factorial(int n) {if(n > 1) {

return n * factorial(n-1);}else return 1;

(n = 2)

;}

;}

1

Inside Itself?!Inside Itself?!Inside Itself?!Inside Itself?!factorial(3); int factorial(int n) { (n 3)factorial(3); int factorial(int n) {

if(n > 1) {return n * factorial(n-1);

}else return 1;

(n = 3)

;}

int factorial(int n) {if(n > 1) {return n * 1;

(n = 2)

return n * 1;}else return 1;

}

Inside Itself?!Inside Itself?!Inside Itself?!Inside Itself?!factorial(3); int factorial(int n) { (n 3)factorial(3); int factorial(int n) {

if(n > 1) {return n * factorial(n-1);

}else return 1;

(n = 3)

;}

int factorial(int n) {if(n > 1) {return 2 * 1;

(n = 2)

return 2 * 1;}else return 1;

}

Inside Itself?!Inside Itself?!Inside Itself?!Inside Itself?!factorial(3); int factorial(int n) { (n 3)factorial(3); int factorial(int n) {

if(n > 1) {return n * factorial(n-1);

}else return 1;

(n = 3)

;}

2

Inside Itself?!Inside Itself?!Inside Itself?!Inside Itself?!f t i l(3) i t f t i l(i t ) { ( 3)factorial(3); int factorial(int n) {

if(n > 1) {return n * 2;

}

(n = 3)

}else return 1;

}

Inside Itself?!Inside Itself?!Inside Itself?!Inside Itself?!f t i l(3) i t f t i l(i t ) { ( 3)factorial(3); int factorial(int n) {

if(n > 1) {return 3 * 2;

}

(n = 3)

}else return 1;

}

Inside Itself?!Inside Itself?!Inside Itself?!Inside Itself?!f t i l(3) 6factorial(3); 6

HTMLHTMLHTMLHTML

<font color = “red”>Some stuff.</font>

Attribute

Tag Text End Tag

HTMLHTMLHTMLHTML

<html>

</html>

HTMLHTMLHTMLHTML

<html><head>

</head>

</html>

HTMLHTMLHTMLHTML

<html><head><title>Welcome to Awesome Class!!!</title><title>Welcome to Awesome Class!!!</title></head>

</html>

HTMLHTMLHTMLHTML

<html><head><title>Welcome to Awesome Class!!!</title><title>Welcome to Awesome Class!!!</title></head>

<body><body>

</body></html>

HTMLHTMLHTMLHTML

<html><head><title>Welcome to Awesome Class!!!</title><title>Welcome to Awesome Class!!!</title></head>

<body><body>

This is awesome class!!!

</body></html>

HTML HierarchyHTML HierarchyHTML HierarchyHTML Hierarchy<html>html<head><title>Welcome to Awesome Class!!!</title></head>

<body>

This is awesome class!!!

head body

title This is Awesome</body></html>

e

Welcome to Awesome Class!!!

This is Awesome Class!!!

Awesome Class!!!

HTML HierarchyHTML HierarchyHTML HierarchyHTML Hierarchy<html>html<head><title>Welcome to Awesome Class!!!</title></head>

<body>

This is awesome class!!!

head body

title This is Awesome</body></html>

e

Welcome to Awesome Class!!!

This is Awesome Class!!!

Awesome Class!!!

HTML HierarchyHTML HierarchyHTML HierarchyHTML Hierarchy<html>html<head><title>Welcome to Awesome Class!!!</title></head>

<body>

This is awesome class!!!

head body

title This is Awesome</body></html>

t t e

Welcome to Awesome Class!!!

This is Awesome Class!!!

Awesome Class!!!

HTML HierarchyHTML HierarchyHTML HierarchyHTML Hierarchy<html>html<head><title>Welcome to Awesome Class!!!</title></head>

<body>

This is awesome class!!!

head body

title This is Awesome</body></html>

e

Welcome to Awesome Class!!!

This is Awesome Class!!!

Awesome Class!!!

HTML HierarchyHTML HierarchyHTML HierarchyHTML Hierarchy<html>html<head><title>Welcome to Awesome Class!!!</title></head>

<body>

This is awesome class!!!

head body

title This is Awesome</body></html>

e

Welcome to Awesome Class!!!

This is Awesome Class!!!

Awesome Class!!!

HTML ParsingHTML ParsingHTML ParsingHTML Parsing

Space: The Final Frontier. These are the voyages of the <b>Starship Enterprise</b>. It’s continuing mission: to explore strange new worlds, to seek out new life and new civilizations <b>to boldly go</b> where no onecivilizations, <b>to boldly go</b> where no one has gone before.

HTML ParsingHTML ParsingHTML ParsingHTML Parsing

Space: The Final Frontier. These are the voyages of the <b>Starship Enterprise</b>. It’s continuing mission: to explore strange new worlds, to seek out new life and new civilizations <b>to boldly go</b> where no onecivilizations, <b>to boldly go</b> where no one has gone before.

HTMLParserHTMLParserhttp://htmlparser sourceforge nethttp://htmlparser sourceforge nethttp://htmlparser.sourceforge.nethttp://htmlparser.sourceforge.net

HTMLParserHTMLParserHTMLParserHTMLParser

import org.htmlparser.*;import org.htmlparser.util.*;

Parser parser;NodeList nodelist;

HTMLParserHTMLParserHTMLParserHTMLParservoid setup(){{String url = "http://lcc.gatech.edu/~bmagerko6/classes/";url += "LCC6310/examples/parseTest.htm";

h l ( l)parser = new org.htmlparser.Parser(url);nodelist = parser.parse(null);

}

NOT javax.swing.text.html.parser.Parser

HTMLParserHTMLParserHTMLParserHTMLParservoid setup(){{String url = "http://lcc.gatech.edu/~bmagerko6/classes/";url += "LCC6310/examples/parseTest.htm";

try{parser = new org.htmlparser.Parser("http://www.google.com");nodelist = parser.parse(null);

}catch (ParserException e){{

}}

HTMLParserHTMLParserHTMLParserHTMLParservoid getNode()void getNode(){for(int i = 0; i < nodelist.size(); i++){{Node n = nodelist.elementAt(i);

}}

HTMLParserHTMLParserHTMLParserHTMLParservoid getNode()void getNode(){for(int i = 0; i < nodelist.size(); i++){{Node n = nodelist.elementAt(i);

if (n instanceof Tag) {

Tag t = (Tag) n;g ( g) ;println(t.getTagName());

}}}

}

HTMLParserHTMLParserHTMLParserHTMLParservoid getNode(NodeList nodelist)void getNode(NodeList nodelist){for(int i = 0; i < nodelist.size(); i++){{Node n = nodelist.elementAt(i);

if (n.getChildren() != null) {

getNode(n.getChildren());g ( g ());}

}}}

HTMLParserHTMLParserHTMLParserHTMLParservoid getNode(NodeList nodelist)void getNode(NodeList nodelist){for(int i = 0; i < nodelist.size(); i++){N d d li t l tAt(i)

html

Node n = nodelist.elementAt(i);

if (n.getChildren() != null) {

head body

getNode(n.getChildren());}

}}

title

W l

This is Awesome Class!!!

}Welcome to Awesome Class!!!

HTMLParserHTMLParserHTMLParserHTMLParservoid getNode(NodeList nodelist)void getNode(NodeList nodelist){for(int i = 0; i < nodelist.size(); i++){N d d li t l tAt(i)

html

Node n = nodelist.elementAt(i);

if (n.getChildren() != null) {

head body

getNode(n.getChildren());}

}}

title

W l

This is Awesome Class!!!

}Welcome to Awesome Class!!!

HTMLParserHTMLParserHTMLParserHTMLParservoid getNode(NodeList nodelist)void getNode(NodeList nodelist){for(int i = 0; i < nodelist.size(); i++){N d d li t l tAt(i)

html

Node n = nodelist.elementAt(i);

if (n.getChildren() != null) {

head body

getNode(n.getChildren());}

}}

title

W l

This is Awesome Class!!!

}Welcome to Awesome Class!!!

HTMLParserHTMLParserHTMLParserHTMLParservoid getNode(NodeList nodelist)void getNode(NodeList nodelist){for(int i = 0; i < nodelist.size(); i++){N d d li t l tAt(i)

html

Node n = nodelist.elementAt(i);

if (n.getChildren() != null) {

head body

getNode(n.getChildren());}

}}

title

W l

This is Awesome Class!!!

}Welcome to Awesome Class!!!

HTMLParserHTMLParserHTMLParserHTMLParservoid getNode(NodeList nodelist)void getNode(NodeList nodelist){for(int i = 0; i < nodelist.size(); i++){N d d li t l tAt(i)

html

Node n = nodelist.elementAt(i);

if (n.getChildren() != null) {

head body

getNode(n.getChildren());}

}}

title

W l

This is Awesome Class!!!

}Welcome to Awesome Class!!!

HTMLParserHTMLParserHTMLParserHTMLParservoid getNode(NodeList nodelist)void getNode(NodeList nodelist){for(int i = 0; i < nodelist.size(); i++){N d d li t l tAt(i)

html

Node n = nodelist.elementAt(i);

if (n.getChildren() != null) {

head body

getNode(n.getChildren());}

}}

title

W l

This is Awesome Class!!!

}Welcome to Awesome Class!!!

HTMLParserHTMLParserHTMLParserHTMLParservoid getNode(NodeList nodelist)void getNode(NodeList nodelist){for(int i = 0; i < nodelist.size(); i++){N d d li t l tAt(i)

html

Node n = nodelist.elementAt(i);

if (n.getChildren() != null) {

head body

getNode(n.getChildren());}

}}

title

W l

This is Awesome Class!!!

}Welcome to Awesome Class!!!

HTMLParserHTMLParserHTMLParserHTMLParservoid getNode(NodeList nodelist)void getNode(NodeList nodelist){for(int i = 0; i < nodelist.size(); i++){N d d li t l tAt(i)

html

Node n = nodelist.elementAt(i);

if (n.getChildren() != null) {

head body

getNode(n.getChildren());}

}}

title

W l

This is Awesome Class!!!

}Welcome to Awesome Class!!!

HTMLParserHTMLParserHTMLParserHTMLParservoid getNode(NodeList nodelist)void getNode(NodeList nodelist){for(int i = 0; i < nodelist.size(); i++){N d d li t l tAt(i)

html

Node n = nodelist.elementAt(i);

if (n.getChildren() != null) {

head body

getNode(n.getChildren());}

}}

title

W l

This is Awesome Class!!!

}Welcome to Awesome Class!!!

HTMLParserHTMLParserHTMLParserHTMLParservoid getNode(NodeList nodelist)void getNode(NodeList nodelist){for(int i = 0; i < nodelist.size(); i++){N d d li t l tAt(i)

html

Node n = nodelist.elementAt(i);

if (n.getChildren() != null) {

head body

getNode(n.getChildren());}

}}

title

W l

This is Awesome Class!!!

}Welcome to Awesome Class!!!

HTMLParserHTMLParserHTMLParserHTMLParservoid getNode(NodeList nodelist)void getNode(NodeList nodelist){for(int i = 0; i < nodelist.size(); i++){N d d li t l tAt(i)

html

Node n = nodelist.elementAt(i);

if (n.getChildren() != null) {

head body

getNode(n.getChildren());}

}}

title

W l

This is Awesome Class!!!

}Welcome to Awesome Class!!!

HTMLParserHTMLParserHTMLParserHTMLParservoid getNode(NodeList nodelist)void getNode(NodeList nodelist){for(int i = 0; i < nodelist.size(); i++){N d d li t l tAt(i)

html

Node n = nodelist.elementAt(i);

if (n.getChildren() != null) {

head body

getNode(n.getChildren());}

}}

title

W l

This is Awesome Class!!!

}Welcome to Awesome Class!!!

HTMLParserHTMLParserHTMLParserHTMLParser<html><h d><head><title>Welcome to Awesome Class!!!</title></head>

<body>

<a href="http://www.google.com">Awesome Link 1</a><br /><a href="http://www.homestarrunner.com">Awesome Link 2</a><br /><a href="http://www.pvponline.com">Awesome Link 3</a><br />

</body></body></html>

HTMLParserHTMLParserHTMLParserHTMLParser<html><h d><head><title>Welcome to Awesome Class!!!</title></head>

<body>

<a href="http://www.google.com">Awesome Link 1</a><br /><a href="http://www.homestarrunner.com">Awesome Link 2</a><br /><a href="http://www.pvponline.com">Awesome Link 3</a><br />

</body></body></html>

HTMLParserHTMLParserHTMLParserHTMLParser<html><h d><head><title>Welcome to Awesome Class!!!</title></head>

<body>

<a href="http://www.google.com">Awesome Link 1</a><br /><a href="http://www.homestarrunner.com">Awesome Link 2</a><br /><a href="http://www.pvponline.com">Awesome Link 3</a><br />

</body></body></html> Attributes

HTMLParserHTMLParserHTMLParserHTMLParserTagNameFilter linkfilter = new TagNameFilter("A");g g ( );

NodeList links = nodelist.extractAllNodesThatMatch(linkfilter,true);

for(int i = 0; i < links.size(); i++){

Node n = links.elementAt(i);

Tag t = (Tag) n;String linkSrc = t.getAttribute(HREF);

}}

ReviewReview

RecursionRecursionHTML BasicsHTML BasicsHTML Parsing BasicsHTML Parsing BasicsHTML Parsing BasicsHTML Parsing BasicsUsing Recursion with HTML ParsingUsing Recursion with HTML Parsing

ProjectProject 44Project Project 44H t t i d t id d f f di dHypertext was conceived as a computer-aided form of reading and writing whose structure matches that of the human mind (a tangled web of association), thus enabling humans to make sense of the exponential growth of knowledge experienced in the 20th century The World-Widegrowth of knowledge experienced in the 20th century. The World Wide Web, while a rather anemic implementation of hypertext, makes up for these deficiencies by providing us a with a sneak preview of what it might be like to have a truly global repository of knowledge. But making sense y g y g gof the world is not just a matter of structure but of process, of the dynamic construction of meaning. And as we've been discovering together, computation is fundamentally a process medium. What would you do to th b? C t l t th t d i ll d thi tthe web? Create an applet that dynamically does something to one or more web pages (e.g. collage, systematic distortion, re-layout, ironic superposition, etc.).

Project Grading CriteriaProject Grading Criteriaj gj gConceptConcept

-- 11 if not greatif not great-- 1 1 if not greatif not great

T h i l R li tiT h i l R li tiTechnical RealizationTechnical Realization-- 1 1 if it crashes if it crashes -- 1 1 if the interface is counterintuitive or hard if the interface is counterintuitive or hard to useto use

Visual DesignVisual Design--1 1 if not greatif not great