This won't be helpful but, shouldn't it be ue-tray for "true?" I thought pig-latin splits words at the first vowel?
On Oct 11, 9:35 pm, Spencer Chastain <sechast...@gmail.com> wrote: > So, I'm making a toy robot - something that converts typed text into pig > latin. > > And I have that working, except I thought it might be nice to revert the > text into plain english if the document was edited again later on. > > I figured the easiest way to do this would be to annotate the text per the > range of each pig latin word with the original un-translated word. > > So I added code such that at each word translation, the translated word was > annotated with the original. > > Except now, the text updates seem to stop after the first annotation. If I > comment out setting the Annotation, it works fine. If I uncomment the > setting of the Annotation, it stops working. What's even more confusing, > the Annotation doesn't seem to be coming across - I go back into edit the > blip, during which I have my code dump all annotations - nothing there! > > String original = text.getText(); > if(original.startsWith("pig:")) > { > int end = original.length(); > while(end > 4) > { > int start = original.lastIndexOf(' ', end-1)+1; > if(start < 4) > { > start = 4;} > > String word = original.substring(start, end).trim(); > if(word.length() > 0) > { > String pigged = ""; > if(/*starts with vowel*/) > { > pigged = word + "-ay";} > > else > { > pigged = word.substring(1) + "-" + word.charAt(0) + "ay";} > > logMsg += "'" + word + "' => '" + pigged + "' [" + start + ", " + end + > "]\n"; > Range r = new Range(start, end); > text.replace(r, pigged); > // Range nr = new Range(start, start+pigged.length()); > // text.setAnnotation(nr, "sechastain/pl/" + start, word);} > end = start-1; > } > > text.replace(new Range(0, 4), ""); > > } > > Annotation commented out: ell-tay e-may omething-say rue-tay > Annotation uncommented: pig:tell me something rue-tay > > Come to think of it, other than a range annotation (when I highlight text) > and the occasional lang Annotation, I don't see much annotations. I guess I > just always expected to see more from other places I've read. > > Any thoughts off hand? > > --Spencer --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Wave API" group. To post to this group, send email to google-wave-api@googlegroups.com To unsubscribe from this group, send email to google-wave-api+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/google-wave-api?hl=en -~----------~----~----~----~------~----~------~--~---