Manipulating text

Hi all,

I would like to manipulate a text with Processing in this way:

  1. Enter a text from a file .doc or .odt;
  2. Run this rule: place the last letter of the text at the beginning of the text and, than, swipe toward right all the letters maintaining the same puntuaction and word length
  3. Save the new text as a new page .doc or .odt
  4. Continue this rule until the text return to the original one.

Exemple :

  1. He is tall, isn’t he? (original text inserted)
  2. Eh ei stal, lis’n th? (new text with the rule applied and saved in a new page (step 3)
  3. He he ista, lli’s nt? (the same rule in step 2 applied to the new text until the loop is closed).



1 Like

Start by using split(..., " ") or splitTokens to break the sentence into words.

Each word could be placed in a class Word.

You can have an array of Word.

The class would have methods:

  • removeLastLetter (starting at last word) returns a char, e in Example 1
  • AddLetterAtStart

Pseudo code

char firstLetter = array[last entry].removeLastLetter(); 

for (int i...) {
   firstLetter = array[i].removeLastLetter(); 

In the methods you have to skip the special signs like , ’

1 Like

If you are using p5.js, take a look on the documentation for “regular expressions”. They can help you split on both spaces and punctuators.

For the “open a word document” part, I don’t know if you can import a word reading class from other library (hummm… libreoffice?). That would work on java mode only.

1 Like