def value_for_text(self, t, rp=default_rp, ignore_pos=False): logic_operators = rp.pos_tagger().tagset.LOGIC_OPERATORS occurrences = [count_occurrences_for_all(sent, logic_operators, ignore_pos) for sent in rp.tagged_sentences(t)] return sum(occurrences) / (len(rp.all_words(t)) / 1000) \ if len(rp.all_words(t)) else 0
def value_for_text(self, t, rp=default_rp, ignore_pos=False): negations = rp.pos_tagger().tagset.NEGATIONS occurrences = [count_occurrences_for_all(sent, negations, ignore_pos) for sent in rp.tagged_sentences(t)] return sum(occurrences) / (len(rp.all_words(t)) / 1000) \ if len(rp.all_words(t)) else 0
def value_for_text(self, t, rp=default_rp, ignore_pos=False): logic_operators = rp.pos_tagger().tagset.LOGIC_OPERATORS occurrences = [ count_occurrences_for_all(sent, logic_operators, ignore_pos) for sent in rp.tagged_sentences(t) ] return sum(occurrences) / (len(rp.all_words(t)) / 1000) \ if len(rp.all_words(t)) else 0
def value_for_text(self, t, rp=default_rp, ignore_pos=False): negations = rp.pos_tagger().tagset.NEGATIONS occurrences = [ count_occurrences_for_all(sent, negations, ignore_pos) for sent in rp.tagged_sentences(t) ] return sum(occurrences) / (len(rp.all_words(t)) / 1000) \ if len(rp.all_words(t)) else 0
def value_for_text(self, t, rp=default_rp): connectives = get_log_neg_conn(rp) occurrences = [ count_occurrences_for_all(sent, connectives, ignore_pos=True) for sent in rp.tagged_sentences(t) ] return sum(occurrences) / (len(rp.all_words(t)) / 1000) \ if len(rp.all_words(t)) else 0
def test(): logic_operators = default_rp.pos_tagger().tagset.LOGIC_OPERATORS print(count_occurrences([('O', 'ART'), ('gato', 'N'), ('correu', 'V'), ('e', 'KC'), ('sumiu', 'V'), ('.', 'PU')], logic_operators[0])) print(count_occurrences([('Ele', 'PROPESS'), ('entra', 'V'), (',', 'PU'), ('contanto', 'KS'), ('que', 'KS'), ('saia', 'V'), ('.', 'PU')], logic_operators[12])) print(count_occurrences_for_all([('Ele', 'PROPESS'), ('entra', 'V'), (',', 'PU'), ('contanto', 'KS'), ('que', 'KS'), ('saia', 'V'), ('e', 'KC'), ('feche', 'V'), ('a', 'ART'), ('porta', 'N'), ('.', 'PU')], logic_operators)) lo = LogicOperators() t = base.Text(base_path + '/corpora/folha/folha0.txt') results = lo.values_for_text(t) print(results)
def test(): logic_operators = default_rp.pos_tagger().tagset.LOGIC_OPERATORS print( count_occurrences([('O', 'ART'), ('gato', 'N'), ('correu', 'V'), ('e', 'KC'), ('sumiu', 'V'), ('.', 'PU')], logic_operators[0])) print( count_occurrences([('Ele', 'PROPESS'), ('entra', 'V'), (',', 'PU'), ('contanto', 'KS'), ('que', 'KS'), ('saia', 'V'), ('.', 'PU')], logic_operators[12])) print( count_occurrences_for_all([('Ele', 'PROPESS'), ('entra', 'V'), (',', 'PU'), ('contanto', 'KS'), ('que', 'KS'), ('saia', 'V'), ('e', 'KC'), ('feche', 'V'), ('a', 'ART'), ('porta', 'N'), ('.', 'PU')], logic_operators)) lo = LogicOperators() t = base.Text(base_path + '/corpora/folha/folha0.txt') results = lo.values_for_text(t) print(results)