Text Weaving

Jian + Emma + Camo
@Prototyping 05.10.2021 back

Slow Processing

Weave two texts, like warp and weft
link to the pad
link to the repo

word1 word2 word3 WORD1 WORD2 WORD3
word1 WORD1 word2 WORD2 word3 WORD3

Code is made of essentialy 2 functions:


# 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 class='test'>ipsum",
    #   "< span class='test'>dolor"
# ]

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 + '']
    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 
		< 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)

Demo

Starting from a excerpts of A Choreographer’s Score: Fase, Rosas danst Rosas, Elena’s Aria, Bartók and Investigative Aesthetics with the pattern AAAABBBBABABAAABBB the result is:
ThispublicationistheViolencelands.Hundredsinitialofresulttroopsofaresearchbreakintoaprojectthatbeganincity.Atthat2010momentwhentheAnneTeresaDecitystartsrecordingKeersmaekeraddressedthefollowingitspain.Bodiesquestionaretotornme.Iandpunctured.paraphrase:IamInhabitantsmemorisetheassaultrevivinginmystuttersfourearlyworksandfragmentsrefractedinwhichImyselfbytrauma.BeforewillthedanceInternetforthelastisswitchedofftime.Isthis,thousandsofphoneancamerasoccasionlighttowritetheseup.Peoplechoreographiesdown?Faserisktheirlivesto,recordFourtheMovementstothehellsurroundingthemMusicofSteveReich.Astheyfrantically(call1982and),RosastexteachotherdanstRosas(1983,theircommunicationerupts)into,hundredsElena'sAriaofstar-shapednetworks(1984),.OthersthrowsignalsandintoBartok/Mikrokosmosthe(originallycalledvoidofsocialMikrokosmos,1987mediaandencryptedmessaging),werehopingtobeperformedtheywillbeinarowforpickedupbysomeonethe.firstMeanwhiletime.The,theenvironmentseriesformedunderthecapturestraces.Unpavedtitleground``registersEarlyWorks''thetracksofwasgoingtoenablelongcolumnsofarmouredavehiclesreflective.insightintofourLeavesonvegetationdistinctivedirectionsinthereceivethesootofdevelopmenttheirofexhaustchoreographyinawhilethesoillargeoeuvre.FaseabsorbsandretainsthewasidentifyingDechemicalsKeersmaeker'sreleasedbybanned