None
Input
Output
- reveal []
Endpoint
https://hub.xpub.nl/soupboat/si16/api/reveal/
Reveal
Reveal takes a text as string input and deletes all its characters except the input list of words.
from nltk.tokenize import word_tokenize
def reveal(text,group):
txt = word_tokenize(text)
txt_linebr = []
for token in txt:
if token == '<':
continue
elif token == 'br/':
token='<br/>'
txt_linebr.append(token)
elif token == '>':
continue
else:
txt_linebr.append(token)
new = []
for w in txt_linebr:
if w=='<br/>':
new = new + [w]
elif w not in group:
w = len(w) * ' '
new = new + [w]
elif w in group :
new = new + [w]
text = ' '.join(new)
final= text.replace(' .','.').replace(' ,',',').replace(' :',':').replace(' ;',';').replace('< ','<').replace(' >','>').replace(' / ','/').replace('& ','&')
return final
This function in itself could be understood as a filter to process and alter texts. By chosing to keeping specific words of a text and deleting all the others, the user of the tool can intervene inside a text. One could break down the meaning of a text or create new narrative meanings by exposing its structure, taking out or highlighting specific and meaningful words and detaching such text from its original context. This tool offers a broad spectrum of possibilities in which it can be used, from a very political and subversive use, to a more playful and poetic one.
text = f"""
Live
Live is life
Live
Live
When we all give the power
We all give the best
Every minute of an hour
Don't think about a rest
Then you all get the power
You all get the best
When everyone gives everything
And every song everybody sings
Then it's live
Live is life
Live is life
Live
Live is life, when we all feel the power
Live is life, come on stand up and dance
Live is life, when the feeling of the people
Live is life, is the feeling of the band
When we all give the power
We all give the best
Every minute of an hour
Don't think about a rest
Then you all get the power
You all get the best
When everyone gives everything
And every song everybody sings
Then it's live
Live is life
Live
Live is life
Live
Live
Live is life
Live
Live is life
And you call when it's over
You call it should last
Every minute of the future
Is a memory of the past
'Cause we all gave the power
We all gave the best
And everyone gave everything
And every song everybody sang
Live is life
"""
Examples
reveal(text,["Live","is","life","live"])
'Live Live is life Live Live live Live is life Live is life Live Live is life Live is life Live is life Live is life is live Live is life Live Live is life Live Live Live is life Live Live is life Live is life'