def volt_throttler(c):
    (part, attr) = c
    if same_table((part, attr)):
        return is_horz_aligned((part, attr)) or is_vert_aligned((part, attr))
    if LF_part_miss_match((part, attr)) < 0:
        return False
    return True
Beispiel #2
0
def stg_temp_filter(c):
    (part, attr) = c
    if same_table((part, attr)):
        return is_horz_aligned((part, attr)) or is_vert_aligned((part, attr))

    # Filter if not inside of a table
    return part.context.sentence.is_tabular()
Beispiel #3
0
def LF_ce_keywords_not_part_in_row_col_prefix(c):
    ngrams_part = set(list(get_col_ngrams(c[1], n_max=3, lower=False)))
    ngrams_part = _filter_non_parts(
        ngrams_part.union(set(list(get_row_ngrams(c[1], n_max=3,
                                                  lower=False)))))

    return (TRUE if not same_table(c) and overlap(
        _CE_KEYWORDS.union(_CE_ABBREVS), get_row_ngrams(c[1], n_max=3))
            and len(ngrams_part) == 0
            and not overlap(_NON_CEV_KEYWORDS, get_row_ngrams(c.part, n_max=3))
            and not overlap(_NON_CEV_KEYWORDS, get_row_ngrams(c[1], n_max=3))
            and not LF_current_in_row(c) else ABSTAIN)
Beispiel #4
0
def LF_part_ce_keywords_in_row_prefix_same_table(c):
    ngrams_part = _filter_non_parts(get_row_ngrams(c[1], n_max=3))

    return (TRUE if same_table(c) and is_horz_aligned(c) and overlap(
        _CE_KEYWORDS.union(_CE_ABBREVS), get_row_ngrams(c[1], n_max=3))
            and overlap(_CE_KEYWORDS.union(_CE_ABBREVS),
                        get_row_ngrams(c.part, n_max=3)) and any([
                            c.part.context.get_span().lower().startswith(_)
                            for _ in ngrams_part
                        ])
            and not overlap(_NON_CEV_KEYWORDS, get_row_ngrams(c.part, n_max=3))
            and not overlap(_NON_CEV_KEYWORDS, get_row_ngrams(c[1], n_max=3))
            and not LF_current_in_row(c) else ABSTAIN)
Beispiel #5
0
def polarity_filter(c):
    (part, attr) = c

    # Check if the polarities are not matched with the part
    ngrams_part = set(x for x in get_row_ngrams(part, n_max=1, lower=False)
                      if (x and polarity_pattern.match(x)))
    if len(ngrams_part) != 0 and all(
            not attr.context.get_span().lower().startswith(_.lower())
            for _ in ngrams_part):
        logger.debug(
            f"ngrams_part: {ngrams_part}\nattr: {attr.context.get_span().lower()}"
        )
        return False

    if same_table(c):
        return is_horz_aligned(c) or is_vert_aligned(c)

    return True
Beispiel #6
0
def ce_v_max_filter(c):
    (part, attr) = c
    if same_table(c):
        return is_horz_aligned(c) or is_vert_aligned(c)

    # Check if the ce_v_max's are not matched with the part
    ngrams_part = _filter_non_parts(
        set(x for x in get_vert_ngrams(attr, n_max=1)))
    ngrams_part = _filter_non_parts(
        ngrams_part.union(set(x for x in get_horz_ngrams(attr, n_max=1))))

    if len(ngrams_part) != 0 and all(
            not part.context.get_span().lower().startswith(_.lower())
            for _ in ngrams_part):
        logger.debug(
            f"ngrams_part: {ngrams_part}\npart: {part.context.get_span().lower()}"
        )
        return False

    return True
Beispiel #7
0
def LF_part_ce_keywords_in_col_prefix_same_table(c):
    return (TRUE if same_table(c) and is_vert_aligned(c) and overlap(
        _CE_KEYWORDS.union(_CE_ABBREVS), get_row_ngrams(c[1], n_max=3))
            and not overlap(_NON_CEV_KEYWORDS, get_row_ngrams(c[1], n_max=3))
            and not LF_current_in_row(c) else ABSTAIN)
Beispiel #8
0
def LF_same_table_must_align(c):
    return (FALSE if
            (same_table(c)
             and not (is_horz_aligned(c) or is_vert_aligned(c))) else ABSTAIN)
Beispiel #9
0
def temp_throttler(c):
    """Temperature throttler."""
    (part, attr) = c
    if same_table((part, attr)):
        return is_horz_aligned((part, attr)) or is_vert_aligned((part, attr))
    return True