예제 #1
0
def rule_5(dep_rel, text):
    """Extract term if rule 5 applies.

    Args:
        dep_rel (DepRelation): Dependency relation.
        text (str): Sentence text.
    """
    candidate = None
    if is_subj_obj_or_mod(dep_rel) and dep_rel.dep.norm_pos == POS.ADJ:
        return CandidateTerm(dep_rel.dep, dep_rel.gov, text, Polarity.UNK)
    return candidate
예제 #2
0
def rule_3(dep_rel, relation_list, text):
    """Extract term if rule 3 applies.

    Args:
        dep_rel (DepRelation): Dependency relation.
        relation_list (list of DepRelation): Generic relations between all tokens.
        text (str): Sentence text.
    """
    candidate = None
    if dep_rel.gov.norm_pos == POS.NN and is_subj_obj_or_mod(dep_rel):
        aspect = expand_aspect(dep_rel.gov, relation_list)
        candidate = CandidateTerm(aspect, dep_rel.dep, text, Polarity.UNK)
    return candidate
예제 #3
0
def rule_6(dep_rel, relation_list, text):
    """Extract term if rule 6 applies.

    Args:
        dep_rel (DepRelation): Dependency relation.
        relation_list (list of DepRelation): Generic relations between all tokens.
        text (str): Sentence text.
    """
    candidate = None
    if dep_rel.rel in ('conj_and', 'conj_but'):
        aspect = expand_aspect(dep_rel.dep, relation_list)
        candidate = CandidateTerm(aspect, dep_rel.gov, text, Polarity.UNK)
    return candidate
예제 #4
0
def rule_2(dep_rel, relation_list, dep_entry, text):
    """Extract term if rule 2 applies.

    Args:
        dep_rel (DepRelation): Dependency relation.
        relation_list (list of DepRelation): Generic relations between all tokens.
        dep_entry (OpinionTerm): Dependent token.
        text (str): Sentence text.
    """
    candidate = None
    for curr_rt in relation_list:
        if (curr_rt.gov, curr_rt.rel, curr_rt.dep.norm_pos) == \
                (dep_rel.gov, dep_rel.rel, POS.ADJ) and curr_rt.dep != dep_rel.dep:
            candidate = CandidateTerm(curr_rt.dep, dep_rel.dep, text, dep_entry.polarity)
    return candidate
예제 #5
0
def rule_4(dep_rel, relation_list, text):
    """Extract term if rule 4 applies.

    Args:
        dep_rel (DepRelation): Dependency relation.
        relation_list (list of DepRelation): Generic relations between all tokens.
        relation between tokens
        text (str): Sentence text.
    """
    candidate = None
    for curr_rt in relation_list:
        if curr_rt.gov == dep_rel.gov and curr_rt.dep != dep_rel.dep and \
                curr_rt.dep.norm_pos == POS.NN and is_subj_obj_or_mod(curr_rt) and \
                is_subj_obj_or_mod(dep_rel):
            aspect = expand_aspect(curr_rt.dep, relation_list)
            candidate = CandidateTerm(aspect, dep_rel.dep, text, Polarity.UNK)
    return candidate
예제 #6
0
def rule_1(dep_rel, gov_entry, dep_entry, text):
    """Extract term if rule 1 applies.

    Args:
        dep_rel (DepRelation): Dependency relation.
        gov_entry (DicEntrySentiment): Governor opinion entry.
        dep_entry (DicEntrySentiment): Dependant opinion entry.
        text (str): Sentence text.
    """
    candidate = None
    (anchor_entry, anchor, related) = (gov_entry, dep_rel.gov, dep_rel.dep) \
        if gov_entry else (dep_entry, dep_rel.dep, dep_rel.gov)

    if related.norm_pos == POS.ADJ and dep_rel.rel.startswith('conj'):
        polarity = anchor_entry.polarity
        candidate = CandidateTerm(related, anchor, text, polarity)
    return candidate
예제 #7
0
def rule_6(dep_rel, relation_list, text):
    """Extract term if rule 6 applies.

    Args:
        dep_rel (DepRelation): Dependency relation.
        relation_list (list of DepRelation): Generic relations between all tokens.
        text (str): Sentence text.
    """
    candidate = None
    if dep_rel.rel.startswith("conj") and dep_rel.dep.norm_pos in {
            POS.ADJ,
            POS.ADV,
            POS.NN,
            POS.VB,
    }:
        aspect = expand_aspect(dep_rel.dep, relation_list)
        candidate = CandidateTerm(aspect, dep_rel.gov, text, Polarity.UNK)
    return candidate