Created
March 20, 2009 05:05
-
-
Save youpy/82224 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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