None
Input
Output
- stich []
Endpoint
https://hub.xpub.nl/soupboat/si16/api/stich/
Stitch
Stitch receives as input a text as a string type, and replaces all the occurrences of a target word, with a character or a word that is repeated as many times as the length of the target.
from nltk.tokenize import word_tokenize
# text, target, and replacement are string types
def stich(text, target, replacement):
target = target.lower()
txt = word_tokenize(text)
new = []
for w in txt:
if w == target:
w = len(w)*replacement
new = new + [w]
elif w == target[0].upper() + target[1:]:
w = len(w)*replacement
new = new + [w]
elif w== target.upper():
w = len(w)*replacement
new = new + [w]
else:
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 targeting specific words and stitching them, with a character or a word that is repeated as many times as the length of the target , 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.
Examples
stich("life is life","life"," ")
' is '
stich("life is life","life","*")
'**** is ****'