예제 #1
0
def fix_up(trait, text):
    """Fix problematic parses."""
    # Handle IDs
    start = max(0, trait.start - LOOK_BACK_FAR)
    if IS_ID.search(text, start, trait.start):
        return None

    # Handle traps, like: trap TL01
    start = max(0, trait.start - LOOK_BACK_NEAR)
    if IS_TRAP.search(text, start, trait.start):
        return None

    # Problem parses often happen with an ambiguous key
    if ambiguous_key_problem(trait, text):
        return None

    # Try to disambiguate doubles quotes from inches
    return fix_up_inches(trait, text)
예제 #2
0
def fix_up(trait, text):
    """Fix problematic parses."""
    # Check that this isn't a total length trait
    start = max(0, trait.start - LOOK_BACK_NEAR)
    if IS_TOTAL.search(text, start, trait.start):
        return None

    # Problem parses happen mostly with an ambiguous key
    if trait.ambiguous_key:

        # Make sure this isn't a testes measurement
        start = max(0, trait.start - LOOK_BACK_FAR)
        if (IS_TESTES.search(text, start, trait.start)
                or IS_ELEVATION.search(text, start, trait.start)
                or IS_ID.search(text, start, trait.start)):
            return None

        # Make sure this isn't a tag
        start = max(0, trait.start - LOOK_BACK_NEAR)
        if IS_TAG.search(text, start, trait.start):
            return None

    # Try to disambiguate doubles quotes from inches
    return fix_up_inches(trait, text)
def fix_up(trait, text):
    """Fix problematic parses."""
    # Try to disambiguate doubles quotes from inches
    return fix_up_inches(trait, text)