(texts_in_secs, min_num_texts)
return merged_secs
Merge sections that are too small, i.e. have too few "content" which means that their number
    of texts is lower than or equal <min_num_texts>.
    
    Return merged sections.
Merge sections that are too small, i.e. have too few "content" which means that their number
    of texts is lower than or equal <min_num_texts>.
    
    Return merged sections.
Merge sections that are too small i . e . have too few content which means that their number of texts is lower than or equal <min_num_texts > . Return merged sections .
def merge_small_sections_of_texts(texts_in_secs, min_num_texts):
    """
    Merge sections that are too small, i.e. have too few "content" which means that their number
    of texts is lower than or equal <min_num_texts>.
    
    Return merged sections.
    """
    merged_secs = []
    prev_sec = None
    for cur_sec in texts_in_secs:
        if prev_sec:
            if len(cur_sec) <= min_num_texts:  # number of texts is too low
                sec = cur_sec + prev_sec       # merge this section with the previous section
                if len(merged_secs) > 0:       # remove the prev. section from the final list
                    merged_secs.pop()          # in order to add the merged section later
            else:
                sec = cur_sec
        else:
            sec = cur_sec
        
        merged_secs.append(sec)   # add the (possibly merged) section
        prev_sec = sec

    assert len(flatten_list(texts_in_secs)) == len(flatten_list(merged_secs))

    return merged_secs
def merge_small_sections_of_texts ( texts_in_secs , min_num_texts ) : merged_secs = [ ] prev_sec = None for cur_sec in texts_in_secs : if prev_sec : if len ( cur_sec ) <= min_num_texts : # number of texts is too low sec = cur_sec + prev_sec # merge this section with the previous section if len ( merged_secs ) > 0 : # remove the prev. section from the final list merged_secs . pop ( ) # in order to add the merged section later else : sec = cur_sec else : sec = cur_sec merged_secs . append ( sec ) # add the (possibly merged) section prev_sec = sec assert len ( flatten_list ( texts_in_secs ) ) == len ( flatten_list ( merged_secs ) ) return merged_secs