예제 #1
0
파일: factory.py 프로젝트: ifrost/droopy
    def create_full_droopy(text, lang_bundle=None):
        """Creates droopy with all available bundles"""
        # all available bundles
        droopy = Droopy(text)
        for bundle in DroopyFactory.get_all_available_bundles():
            droopy.add_bundles(bundle)

        # add provided language bundle
        if lang_bundle:
            droopy.add_bundles(lang_bundle)

        return droopy
예제 #2
0
파일: improver.py 프로젝트: ifrost/droopy
 def __init__(self, *args, **kwargs):
     Droopy.__init__(self, *args, **kwargs)
     self.add_bundles(*DroopyFactory.get_all_available_bundles())
     self.add_bundles(English())
__author__ = 'MICH'
from droopy import Droopy
from droopy.static import Static
from droopy.lang.english import English

text = Droopy("Just a simple test")
text.add_bundles(Static(), English())

print text.nof_words # print number of words
print text.nof_syllables # print number of syllables
print text.
예제 #4
0
    @attr
    def without_whitespace_characters(self, d):
        return re.sub('\s', '', d.text)

    @attr
    def count_whitespace_characters(self, d):
        return len(re.findall(' ', d.text))

    @op
    def join_words(self, d, joiner):
        return joiner.join(d.words)

TEXT = """ Example text
    with        some
    whitespace characters
    """

d = Droopy(TEXT)
d.add_bundles(Static(), WhiteBundle())

print "Original text:", d.text
print "---"
print "Text without whitespace characters:", d.without_whitespace_characters
print "---"
print "There are %s whitespce characters in text" % (d.count_whitespace_characters,)
print "---"
print "Orignal text does not change:", d.text
print "---"
print "Join words with space:", d.join_words(' ')

예제 #5
0
파일: full.py 프로젝트: ifrost/droopy
 def __init__(self, text):
     Droopy.__init__(self, text)
     self.add_processors(Static())
     self.add_processors(TextFilter())
     self.add_processors(Readability())