|
|
Line 9: |
Line 9: |
|
| |
|
|
| |
|
| ==Try out response to '?!'==
| | [[User:Clara/S13/Try out response to '?!'|Try out response to '?!']] |
| | |
| I the 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)
| |
| <source lang="python">
| |
| 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)
| |
| </source>
| |
| | |
| '''here is a part of the output'''
| |
| <br>
| |
| <br>
| |
| <span style="color: grey;">[circle the right punctuation ?/!]</span>/ <span style="color: grey;">[circle the right punctuation ?/!]</span><br><br>Nina Power<br><br>Part 1: <span style="color: grey;">[circle the right punctuation ?/!]</span><br><br>“[T]he entire thrust of the LTI The Langue of the Third Reich was towards visualisation<span style="color: grey;">[circle the right punctuation ,/.]</span>and if this process of visualizing could be achieved with recourse to Germanic traditions<span style="color: grey;">[circle the right punctuation ,/.]</span>by means of a runic sign<span style="color: grey;">[circle the right punctuation ,/.]</span>then so much the better<span style="color: grey;">[circle the right punctuation ,/.]</span>And as a jagged character the rune of life was related to the SS symbol<span style="color: grey;">[circle the right punctuation ,/.]</span>and as an ideological symbol also related to the spokes of the wheel of the sun<span style="color: grey;">[circle the right punctuation ,/.]</span>the swastika <span style="color: grey;">[circle the right punctuation ;/…]</span>Renan’s position: the question mark – the most important of all punctuation marks<span style="color: grey;">[circle the right punctuation ,/.]</span>A position in direct opposition to National Socialist intransigence and self-confidence <span style="color: grey;">[circle the right punctuation ;/…]</span>
| |
| <br>
| |
| <br>
| |
| '''here is another replace I used, it's very straight forward and basically randomly picks a replacement for punctuation within the text.'''
| |
| <source lang="python">
| |
| 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))
| |
| </source>
| |
|
| |
|
| =Steve= | | =Steve= |