None

Input

Output

  • respell []

Endpoint

https://hub.xpub.nl/soupboat/si16/api/respell/

Try it



Respell

Respell receives as input a text as a string type, and substitute all the occurrences of a targeted word with a replacement as a string type chosen by the user.

from nltk.tokenize import word_tokenize
# text, target, and replacement are string types
def respell(text, target, replacement):
    target = target.lower()
    txt = word_tokenize(text)
    new = []

    for w in txt:
        if w == target:
            w = replacement
            new = new + [w]
        elif w == target[0:1].upper() + target[1:]:
            w = replacement[0:1].upper() + replacement[1:] 
            new = new + [w]
        elif w == target.upper():
            w = replacement.upper()
            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 replacing them, either for another word, for specific characters or for blank spaces, 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

respell("life is life","life","potato")
'potato is potato'
respell("life is life","life","🥙")
'🥙 is 🥙'