def value_for_text(self, t, rp=default_rp, ignore_pos=False):
     _and = rp.pos_tagger().tagset.AND
     occurrences = [
         count_occurrences(sent, _and, 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 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)
 def value_for_text(self, t, rp=default_rp, ignore_pos=False):
     _and = rp.pos_tagger().tagset.AND
     occurrences = [count_occurrences(sent, _and, 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