def _compress_markerless(marker_list): """Remove repeated MARKERLESS markers. This will speed up depth computations as these paragraphs are redundant for its purposes""" result = [] saw_markerless = False for marker in marker_list: if not Node.is_markerless_label([marker]): saw_markerless = False result.append(marker) elif not saw_markerless: saw_markerless = True result.append(marker) return result
def _decompress_markerless(assignment, marker_list): """Now that we have a specific solution, add back in the compressed MARKERLESS markers.""" result = {} saw_markerless = False a_idx = -1 # idx in the assignment dict for m_idx, marker in enumerate(marker_list): if not Node.is_markerless_label([marker]): saw_markerless = False a_idx += 1 elif not saw_markerless: saw_markerless = True a_idx += 1 result['type{}'.format(m_idx)] = assignment['type{}'.format(a_idx)] result['idx{}'.format(m_idx)] = assignment['idx{}'.format(a_idx)] result['depth{}'.format(m_idx)] = assignment['depth{}'.format(a_idx)] return result