Skip to content

Instantly share code, notes, and snippets.

@youpy
Created March 20, 2009 05:05
Show Gist options
  • Save youpy/82224 to your computer and use it in GitHub Desktop.
Save youpy/82224 to your computer and use it in GitHub Desktop.
/* appjet:version 0.1 */
import("lib-json");
import("lib-list"); // Array.prototype.reduce
import("lib-jlp");
import("lib-text-converter");
convertText(function(text) {
var sentence = text || ' ';
var separator = "@?./+*- ";
var maService = new JLP.MAService();
var words = maService.parse(sentence);
var converted = words.map(function(word) {
return word[Math.random() > 0.5 ? 'surface' : 'reading'];
}).join('').split('').reduce(function(memo, c) {
return memo + separator[Math.floor(Math.random() * separator.length)] + c;
}, '').replace(/\b /g, '');
return converted;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment