예제 #1
0
    def _compute_char_type(self, s, r):
        for ch in s:
            if True == sp.is_non_printable(ord(ch)):
                r['non_printable'] += 1
            else:
                r['printable'] += 1

                if True == sp.is_digit(ord(ch)):
                    r['numbers'] += 1
                elif True == sp.is_letter(ord(ch)):
                    r['letters'] += 1
                else:
                    r['symbols'] += 1

        if True == DEBUG:
            print "type: {0}".format(r)
        return r
예제 #2
0
    def _compute_char_type(self, s, r):
        for ch in s:
            if True == sp.is_non_printable(ord(ch)):
                r["non_printable"] += 1
            else:
                r["printable"] += 1

                if True == sp.is_digit(ord(ch)):
                    r["numbers"] += 1
                elif True == sp.is_letter(ord(ch)):
                    r["letters"] += 1
                else:
                    r["symbols"] += 1

        if True == DEBUG:
            print "type: {0}".format(r)
        return r
예제 #3
0
    def _compute_grammar_components(self, s, r):
        ch_prev = "\x04"
        for ch in s:
            r["chars"] += 1

            if True == sp.is_word_end_char(ch) and True == sp.is_letter(ord(ch_prev)):
                r["words"] += 1

            if True == sp.is_sentence_end_char(ch_prev):
                if " " == ch:
                    r["sentences"] += 1
                elif True == sp.is_paragraph_end_char(ch):
                    r["sentences"] += 1
                    r["paragraphs"] += 1

            ch_prev = ch

        if True == DEBUG:
            print "grammar: {0}".format(r)
        return r
예제 #4
0
    def _compute_grammar_components(self, s, r):
        ch_prev = '\x04'
        for ch in s:
            r['chars'] += 1

            if True == sp.is_word_end_char(ch) and \
                True == sp.is_letter(ord(ch_prev)):
                r['words'] += 1

            if True == sp.is_sentence_end_char(ch_prev):
                if ' ' == ch:
                    r['sentences'] += 1
                elif True == sp.is_paragraph_end_char(ch):
                    r['sentences'] += 1
                    r['paragraphs'] += 1

            ch_prev = ch

        if True == DEBUG:
            print "grammar: {0}".format(r)
        return r