sample_of_chars_gen = function* (array_of_paras, start, count) {
count = count || Infinity;
let read_chars = [];
let returned_chars = [];
let read_char_count = 0;
let returned_char_count = 0;
let current_para__array_of_sent;
let current_para__index=0;
while (returned_char_count < count
&& (current_para__array_of_sent=array_of_paras[current_para__index])
&& ++current_para__index){
let is_para_opened = false;
let current_sent__array_of_word;
let current_sent__index=0;
while (returned_char_count < count
&& (current_sent__array_of_word=current_para__array_of_sent[current_sent__index])
&& ++current_sent__index){
let current_word__array_of_chars;
let current_word__index=0;
while (returned_char_count < count
//-----------------------------------------------------------------------v
// splitting to convert string to array, so can shift it
&& (current_word__array_of_chars=current_sent__array_of_word[current_word__index])
&& ++current_word__index){ //.shift().split(''))){
let no_space_prefix = new Set([',','.',`''`])
let no_space_suffix = new Set(['``']);//, '"', `''`])
// if (current_word__array_of_chars[0]!='.'){
// if (current_word__array_of_chars==='deserves'){
// yield current_sent__array_of_word[current_word__index-1];
// }
if (current_sent__index>0
//Certain chars shouldnt be preceded by spaces
&& ! no_space_prefix.has(current_word__array_of_chars)
&& ! no_space_suffix.has(current_sent__array_of_word[current_word__index-2])){
// (current_char in !='"'
// && current_char!='.'){
//read_char_count >= start){
if (read_char_count >= start){
yield ' ';
returned_char_count++;
}
read_char_count++;
}
// }
//Fix things about the brown corpus and/or my nltk tagging process which I dont understand
//
current_word__array_of_chars = current_word__array_of_chars
.replace('``','"')
.replace(`''`,'"');
let current_char__index=0;
let current_char;//=current_word__array_of_chars[current_char__index];
while (returned_char_count < count
//&& returned_char_count < count
&& (current_char=current_word__array_of_chars[current_char__index])
&& ++current_char__index ){ //.shift())){
read_char_count++;
if (read_char_count >= start){
if (!is_para_opened){
//read_char_count >= start){
yield `<p>`;
is_para_opened = true;
}
returned_char_count++;
//console.log(current_char, returned_char_count, count, current_char__index);
yield current_char;
//returned_chars.push(current_char);
}
}
}
}
//a space might close
if (returned_char_count==count){
// ${returned_char_count}
yield `<span class="blinker" style="display:inline-block; height:24px; min-width:15px; margin-left:2px; line-height:1.5em" > </span>`;
}
//console.log('para');
if (is_para_opened){ //returned_chars>0){
//read_char_count > start){
yield `</p`;
}
}
}