User:Clara/S13/Try out response to '?!'

From XPUB & Lens-Based wiki

I then proceeded to mix and use what I learned from the classes to create my response to the text

One of many drafts were I used replace to change to punctuation in the text (this was for the print version)

txt = open('txt/!?_test.txt', 'r').read()

#!
txt = txt.replace('! ','<span style="color: grey;">[circle the right punctuation ?/!]</span>')
txt = txt.replace("!’",'<span style="color: grey;">[circle the right punctuation ?/!]</span>')
txt = txt.replace('!\n','<span style="color: grey;">[circle the right punctuation ?/!]</span>\n')
txt = txt.replace('!”','<span style="color: grey;">[circle the right punctuation ?/!]</span>')

#?
txt = txt.replace("? ",'<span style="color: grey;">[circle the right punctuation ?/!]</span>')
txt = txt.replace("?’",'<span style="color: grey;">[circle the right punctuation ?/!]</span>')
txt = txt.replace('?\n','<span style="color: grey;">[circle the right punctuation ?/!]</span>\n')
txt = txt.replace('?”','<span style="color: grey;">[circle the right punctuation ?/!]</span>')

#,
txt = txt.replace(", ",'<span style="color: grey;">[circle the right punctuation ,/.]</span>')

#.
txt = txt.replace(". ",'<span style="color: grey;">[circle the right punctuation ,/.]</span>')
txt = txt.replace(".’",'<span style="color: grey;">[circle the right punctuation ,/.]</span>')
txt = txt.replace(".”",'<span style="color: grey;">[circle the right punctuation ,/.]</span>')

#…
txt = txt.replace('… ','<span style="color: grey;">[circle the right punctuation ;/…]</span>')

#line break
txt = txt.replace("\n",'<br>')

print(txt)

here is a part of the output

[circle the right punctuation ?/!]/ [circle the right punctuation ?/!]

Nina Power

Part 1: [circle the right punctuation ?/!]

“[T]he entire thrust of the LTI The Langue of the Third Reich was towards visualisation[circle the right punctuation ,/.]and if this process of visualizing could be achieved with recourse to Germanic traditions[circle the right punctuation ,/.]by means of a runic sign[circle the right punctuation ,/.]then so much the better[circle the right punctuation ,/.]And as a jagged character the rune of life was related to the SS symbol[circle the right punctuation ,/.]and as an ideological symbol also related to the spokes of the wheel of the sun[circle the right punctuation ,/.]the swastika [circle the right punctuation ;/…]Renan’s position: the question mark – the most important of all punctuation marks[circle the right punctuation ,/.]A position in direct opposition to National Socialist intransigence and self-confidence [circle the right punctuation ;/…]

here is another replace I used, it's very straight forward and basically randomly picks a replacement for punctuation within the text.

txt = open('txt/!?_test.txt', 'r').read()

point = ("!","?","!!","??","!?","?!","!!!","?!?","???","!?!")
point2 = ("!","?","!!","??","!?","?!","!!!","?!?","???","!?!")
point3 = ("!","?","!!","??","!?","?!","!!!","?!?","???","!?!")
point4 = ("!","?","!!","??","!?","?!","!!!","?!?","???","!?!")
point5 = ("!","?","!!","??","!?","?!","!!!","?!?","???","!?!")
point6 = ("!","?","!!","??","!?","?!","!!!","?!?","???","!?!")
point7 = ("!","?","!!","??","!?","?!","!!!","?!?","???","!?!")


import random
import re
def replace(m):
    t=m.group(0)
    if t=="!":
        return random.choice(point)
    elif t=="?":
        return random.choice(point2)
    elif t=="??":
        return random.choice(point3)
    elif t=="?!":
        return random.choice(point4)
    elif t=="!!!":
        return random.choice(point5)
    elif t=="?!?":
        return random.choice(point6)
    elif t=="!?":
        return random.choice(point7)
    

print(re.sub(r"[!?,.]+", replace ,txt))