|
|
<!DOCTYPE html>
|
|
|
<html lang="en">
|
|
|
<head>
|
|
|
<meta charset="UTF-8" />
|
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
|
<title>Weaving - 05-10-2021</title>
|
|
|
<link rel="stylesheet" href="../global.css" />
|
|
|
<link rel="stylesheet" href="style.css" />
|
|
|
<script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js"></script>
|
|
|
</head>
|
|
|
<body>
|
|
|
<div class="contents">
|
|
|
<h1 class="title">Text Weaving</h1>
|
|
|
<div class="meta">
|
|
|
Jian + Emma + Camo <br />
|
|
|
<a href="https://pad.xpub.nl/p/SP16_0510">@Prototyping 05.10.2021</a>
|
|
|
<a href=".." class="back">back</a>
|
|
|
</div>
|
|
|
<div class="intro">
|
|
|
<h2>Slow Processing</h2>
|
|
|
<ul>
|
|
|
<li>
|
|
|
~ if nltk is a form of mapping language, vltk is a form of mapping language
|
|
|
from a particular vantage point
|
|
|
</li>
|
|
|
<li>
|
|
|
~ pick a text or a collection of texts from the pad from last week or the
|
|
|
one of this week
|
|
|
</li>
|
|
|
<li>
|
|
|
~ choose a linguistic pattern to apply over the text, for example: all
|
|
|
verbs, every third word of a sentence, the 50 most used words, collocations
|
|
|
you observe, words with multiple meanings, x of y, question marks etc. the
|
|
|
processing can be both manual or automatic.
|
|
|
</li>
|
|
|
<li>~ what is the output?</li>
|
|
|
</ul>
|
|
|
</div>
|
|
|
|
|
|
<div class="process">
|
|
|
Weave two texts, like warp and weft <br />
|
|
|
<a href="https://pad.xpub.nl/p/replacing_cats">link to the pad</a> <br />
|
|
|
<a href="https://git.xpub.nl/kamo/text_weaving">link to the repo</a>
|
|
|
|
|
|
<p>
|
|
|
word1 word2 word3 WORD1 WORD2 WORD3 <br />
|
|
|
word1 WORD1 word2 WORD2 word3 WORD3
|
|
|
</p>
|
|
|
|
|
|
<p>
|
|
|
Code is made of essentialy 2 functions:
|
|
|
<ul>
|
|
|
<li>1. the former is for splitting a text into a list of elements (atm it splits the txt in single words, but could be made to work with phrases or even chapters). With this function we process two texts for the second function.</li>
|
|
|
<li>2. the latter takes the two arrays and a pattern structured as a string alternating A and B es: 'ABAB', 'AAABBB'.</li>
|
|
|
</ul>
|
|
|
</p>
|
|
|
|
|
|
<pre class="prettyprint">
|
|
|
<code>
|
|
|
# 1. HTML TOKENIZER (word + span)
|
|
|
# return a list of tag from a text
|
|
|
# each item in the list is transformed into a html < span> tag,
|
|
|
# with the class defined by the text_class argument
|
|
|
#
|
|
|
# es: to_html('Lorem ipsum dolor', 'test')
|
|
|
# return
|
|
|
# [
|
|
|
# "< span class='test'>Lorem</ span>",
|
|
|
# "< span class='test'>ipsum</ span>",
|
|
|
# "< span class='test'>dolor</ span>"
|
|
|
# ]
|
|
|
|
|
|
def to_html(text, text_class):
|
|
|
text_html = []
|
|
|
text_list = word_tokenize(text)
|
|
|
for word in text_list:
|
|
|
text_html += ['< span class="' + text_class + '">' + word + '</ span>']
|
|
|
return text_html
|
|
|
|
|
|
# 2. WEAVER
|
|
|
# weave two texts following a pattern structured as a string of A and B
|
|
|
# es: ABABAAAABBBB
|
|
|
# the repetition argument specifies how many times the pattern is repeated
|
|
|
# the start1 and start2 arguments specify the starting point in the texts' array
|
|
|
# it returns a string
|
|
|
|
|
|
def weave(text1, text2, pattern, repetition, start1=0, start2=0):
|
|
|
embroidery = ''
|
|
|
text1_cursor = start1
|
|
|
text2_cursor = start2
|
|
|
repeated_pattern = pattern * repetition
|
|
|
for choice in repeated_pattern:
|
|
|
if choice == 'A':
|
|
|
embroidery += text1[text1_cursor]
|
|
|
text1_cursor += 1
|
|
|
if choice == 'B':
|
|
|
embroidery += text2[text2_cursor]
|
|
|
text2_cursor += 1
|
|
|
return embroidery
|
|
|
|
|
|
|
|
|
# DEMO
|
|
|
|
|
|
text_a = to_html('Lorem ipsum dolor', 'text1')
|
|
|
text_b = to_html('Sit amet pariatur magna', 'text2')
|
|
|
text_embroidery = weave(text_a, text_b, 'ABBAB', 1)
|
|
|
|
|
|
# BASIC HTML5 boilerplate
|
|
|
|
|
|
html_boilerplate = '''
|
|
|
< !DOCTYPE html >
|
|
|
< html lang="en" >
|
|
|
< head >
|
|
|
< meta charset="UTF-8" />
|
|
|
< meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
|
|
< meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
|
< title > Document </ title >
|
|
|
< link rel="stylesheet" href="style.css" />
|
|
|
< /head >
|
|
|
< body >
|
|
|
< div class= "text">
|
|
|
|
|
|
{{{contents}}}
|
|
|
|
|
|
< /div>
|
|
|
< /body>
|
|
|
< /html>
|
|
|
'''
|
|
|
|
|
|
# the {{{contents}}} line will be replaced with our text_embroidery
|
|
|
html_out = html_boilerplate.replace('{{{contents}}}', text_embroidery)
|
|
|
print(html_out)
|
|
|
</code>
|
|
|
</pre>
|
|
|
|
|
|
<h2 class='demo'>Demo</h2>
|
|
|
Starting from a excerpts of <a href="https://www.rosas.be/nl/publications/425-a-choreographer-s-score-fase-rosas-danst-rosas-elena-s-aria-bartok">A Choreographer’s Score: Fase, Rosas danst Rosas, Elena’s Aria, Bartók</a> and <a href="https://www.versobooks.com/books/3801-investigative-aesthetics">Investigative Aesthetics</a> with the pattern <span class='text1'>AAAA</span><span class='text2'>BBBB</span><span class='text1'>A</span><span class='text2'>B</span><span class='text1'>A</span><span class='text2'>B</span><span class='text1'>AAA</span><span class='text2'>BBB</span> the result is:
|
|
|
|
|
|
<div class="result">
|
|
|
<span class="text1">This</span><span class="text1">publication</span
|
|
|
><span class="text1">is</span><span class="text1">the</span
|
|
|
><span class="text2">Violence</span><span class="text2">lands</span
|
|
|
><span class="text2">.</span><span class="text2">Hundreds</span
|
|
|
><span class="text1">initial</span><span class="text2">of</span
|
|
|
><span class="text1">result</span><span class="text2">troops</span
|
|
|
><span class="text1">of</span><span class="text1">a</span
|
|
|
><span class="text1">research</span><span class="text2">break</span
|
|
|
><span class="text2">into</span><span class="text2">a</span
|
|
|
><span class="text1">project</span><span class="text1">that</span
|
|
|
><span class="text1">began</span><span class="text1">in</span
|
|
|
><span class="text2">city</span><span class="text2">.</span><span class="text2">At</span
|
|
|
><span class="text2">that</span><span class="text1">2010</span
|
|
|
><span class="text2">moment</span><span class="text1">when</span
|
|
|
><span class="text2">the</span><span class="text1">Anne</span
|
|
|
><span class="text1">Teresa</span><span class="text1">De</span
|
|
|
><span class="text2">city</span><span class="text2">starts</span
|
|
|
><span class="text2">recording</span><span class="text1">Keersmaeker</span
|
|
|
><span class="text1">addressed</span><span class="text1">the</span
|
|
|
><span class="text1">following</span><span class="text2">its</span
|
|
|
><span class="text2">pain</span><span class="text2">.</span
|
|
|
><span class="text2">Bodies</span><span class="text1">question</span
|
|
|
><span class="text2">are</span><span class="text1">to</span
|
|
|
><span class="text2">torn</span><span class="text1">me</span><span class="text1">.</span
|
|
|
><span class="text1">I</span><span class="text2">and</span
|
|
|
><span class="text2">punctured</span><span class="text2">.</span
|
|
|
><span class="text1">paraphrase</span><span class="text1">:</span
|
|
|
><span class="text1">I</span><span class="text1">am</span
|
|
|
><span class="text2">Inhabitants</span><span class="text2">memorise</span
|
|
|
><span class="text2">the</span><span class="text2">assault</span
|
|
|
><span class="text1">reviving</span><span class="text2">in</span
|
|
|
><span class="text1">my</span><span class="text2">stutters</span
|
|
|
><span class="text1">four</span><span class="text1">early</span
|
|
|
><span class="text1">works</span><span class="text2">and</span
|
|
|
><span class="text2">fragments</span><span class="text2">refracted</span
|
|
|
><span class="text1">in</span><span class="text1">which</span
|
|
|
><span class="text1">I</span><span class="text1">myself</span
|
|
|
><span class="text2">by</span><span class="text2">trauma</span
|
|
|
><span class="text2">.</span><span class="text2">Before</span
|
|
|
><span class="text1">will</span><span class="text2">the</span
|
|
|
><span class="text1">dance</span><span class="text2">Internet</span
|
|
|
><span class="text1">for</span><span class="text1">the</span
|
|
|
><span class="text1">last</span><span class="text2">is</span
|
|
|
><span class="text2">switched</span><span class="text2">off</span
|
|
|
><span class="text1">time</span><span class="text1">.</span><span class="text1">Is</span
|
|
|
><span class="text1">this</span><span class="text2">,</span
|
|
|
><span class="text2">thousands</span><span class="text2">of</span
|
|
|
><span class="text2">phone</span><span class="text1">an</span
|
|
|
><span class="text2">cameras</span><span class="text1">occasion</span
|
|
|
><span class="text2">light</span><span class="text1">to</span
|
|
|
><span class="text1">write</span><span class="text1">these</span
|
|
|
><span class="text2">up</span><span class="text2">.</span
|
|
|
><span class="text2">People</span><span class="text1">choreographies</span
|
|
|
><span class="text1">down</span><span class="text1">?</span
|
|
|
><span class="text1">Fase</span><span class="text2">risk</span
|
|
|
><span class="text2">their</span><span class="text2">lives</span
|
|
|
><span class="text2">to</span><span class="text1">,</span
|
|
|
><span class="text2">record</span><span class="text1">Four</span
|
|
|
><span class="text2">the</span><span class="text1">Movements</span
|
|
|
><span class="text1">to</span><span class="text1">the</span
|
|
|
><span class="text2">hell</span><span class="text2">surrounding</span
|
|
|
><span class="text2">them</span><span class="text1">Music</span
|
|
|
><span class="text1">of</span><span class="text1">Steve</span
|
|
|
><span class="text1">Reich</span><span class="text2">.</span
|
|
|
><span class="text2">As</span><span class="text2">they</span
|
|
|
><span class="text2">frantically</span><span class="text1">(</span
|
|
|
><span class="text2">call</span><span class="text1">1982</span
|
|
|
><span class="text2">and</span><span class="text1">)</span><span class="text1">,</span
|
|
|
><span class="text1">Rosas</span><span class="text2">text</span
|
|
|
><span class="text2">each</span><span class="text2">other</span
|
|
|
><span class="text1">danst</span><span class="text1">Rosas</span
|
|
|
><span class="text1">(</span><span class="text1">1983</span><span class="text2">,</span
|
|
|
><span class="text2">their</span><span class="text2">communication</span
|
|
|
><span class="text2">erupts</span><span class="text1">)</span
|
|
|
><span class="text2">into</span><span class="text1">,</span
|
|
|
><span class="text2">hundreds</span><span class="text1">Elena</span
|
|
|
><span class="text1">'s</span><span class="text1">Aria</span
|
|
|
><span class="text2">of</span><span class="text2">star-shaped</span
|
|
|
><span class="text2">networks</span><span class="text1">(</span
|
|
|
><span class="text1">1984</span><span class="text1">)</span><span class="text1">,</span
|
|
|
><span class="text2">.</span><span class="text2">Others</span
|
|
|
><span class="text2">throw</span><span class="text2">signals</span
|
|
|
><span class="text1">and</span><span class="text2">into</span
|
|
|
><span class="text1">Bartok/Mikrokosmos</span><span class="text2">the</span
|
|
|
><span class="text1">(</span><span class="text1">originally</span
|
|
|
><span class="text1">called</span><span class="text2">void</span
|
|
|
><span class="text2">of</span><span class="text2">social</span
|
|
|
><span class="text1">Mikrokosmos</span><span class="text1">,</span
|
|
|
><span class="text1">1</span><span class="text1">987</span
|
|
|
><span class="text2">media</span><span class="text2">and</span
|
|
|
><span class="text2">encrypted</span><span class="text2">messaging</span
|
|
|
><span class="text1">)</span><span class="text2">,</span><span class="text1">were</span
|
|
|
><span class="text2">hoping</span><span class="text1">to</span
|
|
|
><span class="text1">be</span><span class="text1">performed</span
|
|
|
><span class="text2">they</span><span class="text2">will</span
|
|
|
><span class="text2">be</span><span class="text1">in</span><span class="text1">a</span
|
|
|
><span class="text1">row</span><span class="text1">for</span
|
|
|
><span class="text2">picked</span><span class="text2">up</span
|
|
|
><span class="text2">by</span><span class="text2">someone</span
|
|
|
><span class="text1">the</span><span class="text2">.</span
|
|
|
><span class="text1">first</span><span class="text2">Meanwhile</span
|
|
|
><span class="text1">time</span><span class="text1">.</span
|
|
|
><span class="text1">The</span><span class="text2">,</span><span class="text2">the</span
|
|
|
><span class="text2">environment</span><span class="text1">series</span
|
|
|
><span class="text1">formed</span><span class="text1">under</span
|
|
|
><span class="text1">the</span><span class="text2">captures</span
|
|
|
><span class="text2">traces</span><span class="text2">.</span
|
|
|
><span class="text2">Unpaved</span><span class="text1">title</span
|
|
|
><span class="text2">ground</span><span class="text1">``</span
|
|
|
><span class="text2">registers</span><span class="text1">Early</span
|
|
|
><span class="text1">Works</span><span class="text1">''</span
|
|
|
><span class="text2">the</span><span class="text2">tracks</span
|
|
|
><span class="text2">of</span><span class="text1">was</span
|
|
|
><span class="text1">going</span><span class="text1">to</span
|
|
|
><span class="text1">enable</span><span class="text2">long</span
|
|
|
><span class="text2">columns</span><span class="text2">of</span
|
|
|
><span class="text2">armoured</span><span class="text1">a</span
|
|
|
><span class="text2">vehicles</span><span class="text1">reflective</span
|
|
|
><span class="text2">.</span><span class="text1">insight</span
|
|
|
><span class="text1">into</span><span class="text1">four</span
|
|
|
><span class="text2">Leaves</span><span class="text2">on</span
|
|
|
><span class="text2">vegetation</span><span class="text1">distinctive</span
|
|
|
><span class="text1">directions</span><span class="text1">in</span
|
|
|
><span class="text1">the</span><span class="text2">receive</span
|
|
|
><span class="text2">the</span><span class="text2">soot</span
|
|
|
><span class="text2">of</span><span class="text1">development</span
|
|
|
><span class="text2">their</span><span class="text1">of</span
|
|
|
><span class="text2">exhaust</span><span class="text1">choreography</span
|
|
|
><span class="text1">in</span><span class="text1">a</span
|
|
|
><span class="text2">while</span><span class="text2">the</span
|
|
|
><span class="text2">soil</span><span class="text1">large</span
|
|
|
><span class="text1">oeuvre</span><span class="text1">.</span
|
|
|
><span class="text1">Fase</span><span class="text2">absorbs</span
|
|
|
><span class="text2">and</span><span class="text2">retains</span
|
|
|
><span class="text2">the</span><span class="text1">was</span
|
|
|
><span class="text2">identifying</span><span class="text1">De</span
|
|
|
><span class="text2">chemicals</span><span class="text1">Keersmaeker</span
|
|
|
><span class="text1">'</span><span class="text1">s</span
|
|
|
><span class="text2">released</span><span class="text2">by</span
|
|
|
><span class="text2">banned</span>
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
</div>
|
|
|
</body>
|
|
|
</html>
|