Hello,
My goal is to replace words from a String with synonyms. Right now the code can replace one word with another one and write the sentence in my text file. But I would like to have different opportunities to replace the words randomly and write the different sentences with the different combinations to my text file. Is there any way to do so? I am very new to Processing and couldn’t find any solution. So I would be grateful for any help. Thanks in advance!
Sophie
Oh and in addition another question would be: Is it possible to add random text sizes to the words as well? Many thanks!!
PrintWriter output;
String s = "Wie froh bin ich, daß ich weg bin! Bester Freund, was ist das Herz des Menschen! Dich zu verlassen, den ich so liebe, von dem ich unzertrennlich war, und froh zu sein!";
void setup() {
size(600,360);
background(255);
}
void draw() {
s = s.replaceAll("Wie", "Und");
s = s.replaceAll("froh", "ausgelassen");
s = s.replaceAll("bin", "bin");
s = s.replaceAll("ich", "ich");
s = s.replaceAll("daß", "daß");
s = s.replaceAll("weg", "fort");
s = s.replaceAll("Bester", "Erster");
s = s.replaceAll("Freund", "Vertrauter");
s = s.replaceAll("was", "was");
s = s.replaceAll("ist", "befindet");
s = s.replaceAll("das", "das");
s = s.replaceAll("Herz", "Zentrum");
s = s.replaceAll("des", "des");
s = s.replaceAll("Menschen", "Sterblichen");
s = s.replaceAll("verlassen", "entfernen");
s = s.replaceAll("liebe", "anbete");
s = s.replaceAll("unzertrennlich", "vertraut");
s = s.replaceAll("sein", "entstammen");
output = createWriter("positions.text");
output.print(s);
output.flush();
output.close();
stop();
}