Warning: session_start(): open(/var/lib/php/sessions/sess_vq0oet7hegdshikiv541a0nggq, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
// for stuff like #1000478
static class LIntersperse extends LearnerImpl {
static boolean debug;
ReversibleFunction preprocessor; // e.g. JavaTok
L outPrefix, outSuffix, filler;
*(ReversibleFunction *preprocessor) {}
public void processInOut(Object _in, Object _out) {
if (debug)
debug("i/o " + _in + " " + _out);
L in = cast preprocessor.process(_in);
L out = cast preprocessor.process(_out);
int i = out.indexOf(in.get(1));
outPrefix = out.subList(0, i);
int j = out.lastIndexOf(in.get(in.size()-2));
outSuffix = out.subList(j+1, out.size());
int newLength = j-i+1;
int realOldLength = (in.size()-1)/2;
/*int intersperse = 0;
if (realOldLength > 1)
intersperse = newLength-realOldLength*3-1;*/
int intersperse = 3; // just assume this for now
if (realOldLength > 1)
filler = out.subList(i+1, i+1+intersperse);
if (debug)
debug("oldLength= " + in.size() + ", newLength=" + newLength +", realOldLength=" + realOldLength + ", intersperse=" + intersperse + ", filler length=" + (filler == null ? 0 : filler.size()));
}
public Object processIn(Object _in) {
L l = cast preprocessor.process(_in);
if (debug)
debug("i " + structure(l));
new L list;
list.addAll(outPrefix);
if (debug)
debug("ranging from " + 1 + " to " + (l.size()-2));
for (int i = 1; i < l.size()-1; i += 2) {
list.add(l.get(i));
if (i < l.size()-2)
list.addAll(filler);
}
list.addAll(outSuffix);
Object out = preprocessor.unprocess(list);
if (debug)
debug("output: " + structure(list) + " = " + structure(out));
return out;
}
}