this should do the trick to change the font sizes of a characters, words and lines ...
for a sentence based interpolation you have to parse the content of the text frame according to '.' ... and then iterate in a second step over the individual groups of characters for each sentence. sadly indesign doesn't have a built-in collection for sentences.
hope that helps.
#includepath "~/Documents/;%USERPROFILE%Documents";
#include "basiljs/bundle/basil.js";
function draw() {
var lorem = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam pellentesque ultrices dolor, vitae venenatis erat.";
var tf = b.text(lorem, 0, 0, 300, b.height);
// replace words with characters/words/lines/
for (var i = 0; i < tf.words.length; i++) {
tf.words[i].pointSize = b.map(i, 0,tf.words.length, 5,30);
};
}
b.go();
see also the typography related basil.js examples: https://github.com/basiljs/basil.js/tree/master/examples/typography