Ejemplo n.º 1
0
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
Ejemplo n.º 2
0
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
Ejemplo n.º 3
0
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
Ejemplo n.º 4
0
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