def value_for_text(self, t, rp=default_rp):
        parse_trees = rp.parse_trees(t)
        tagged_sents = rp.tagged_sentences(t)

        sent_indices = []
        for i, tree in enumerate(parse_trees):
            nps = len(find_subtrees(tree, 'NP'))
            words = len([word for word in tagged_sents[i]
                         if not rp.pos_tagger().tagset.is_punctuation(word)])

            sent_indices.append(nps / (words / 1000))

        return sum(sent_indices) / len(sent_indices) if sent_indices else 0
示例#2
0
    def value_for_text(self, t, rp=default_rp):
        parse_trees = rp.parse_trees(t)

        sent_indices = []
        for i, tree in enumerate(parse_trees):
            nps = 0
            mods = 0

            for np in find_subtrees(tree, 'NP'):
                mods += len(
                    [tt for tt in np if tt.label() in ('ART', 'ADJ', 'ADV')])
                nps += 1

            sent_indices.append(mods / nps)

        return sum(sent_indices) / len(sent_indices) if sent_indices else 0
示例#3
0
    def value_for_text(self, t, rp=default_rp):
        parse_trees = rp.parse_trees(t)

        sent_indices = []
        for i, tree in enumerate(parse_trees):
            nps = 0
            prons = 0

            for np in find_subtrees(tree, 'NP'):
                prons += len([tt for tt in np if tt.label() in ('PRS')])
                nps += 1

            if nps != 0:
                sent_indices.append(prons / nps)

        return sum(sent_indices) / len(sent_indices) \
            if sent_indices else 0
示例#4
0
    def value_for_text(self, t, rp=default_rp):
        parse_trees = rp.parse_trees(t)

        sent_indices = []
        for i, tree in enumerate(parse_trees):
            nps = 0
            prons = 0

            for np in find_subtrees(tree, 'NP'):
                prons += len([tt for tt in np
                              if tt.label() in ('PRS')])
                nps += 1

            if nps != 0:
                sent_indices.append(prons / nps)

        return sum(sent_indices) / len(sent_indices) \
            if sent_indices else 0