def validate(self,tweet): clean = wordtools.clean(tweet) syllableCount = wordtools.syllableCount(clean) if syllableCount==7 or syllableCount==5: return [syllableCount, tweet] else: return None
def validate(self,tweet): clean = wordtools.clean(tweet) syllableCount = wordtools.syllableCount(clean) if syllableCount==7 or syllableCount==5: return {self.syllables:syllableCount, self.text:tweet} else: return None
def validate(self,tweet): cleaned = wordtools.clean(tweet) meter = wordtools.getMeter(cleaned) if meter!=None and self.isIambicPentameter(meter): return tweet else: return None
def readTweet(self, tweet): cleaned = wordtools.clean(tweet) syllableCount = wordtools.syllableCount(cleaned) if syllableCount > 0 and syllableCount < 20: rhyme = wordtools.getRhyme(cleaned[-1]) if rhyme == self.testRhyme: self.data = tweet
def validate(self, tweet): clean = wordtools.clean(tweet) syllableCount = wordtools.syllableCount(clean) if syllableCount == 7 or syllableCount == 5: return [syllableCount, tweet] else: return None
def validate(self, tweet): clean = wordtools.clean(tweet) syllableCount = wordtools.syllableCount(clean) if syllableCount == 7 or syllableCount == 5: return {self.syllables: syllableCount, self.text: tweet} else: return None
def validate(self,tweet): clean = wordtools.clean(tweet) syl = wordtools.syllableCount(clean) if syl>0: rhyme = wordtools.getRhyme(clean[-1]) if rhyme!= None: return [rhyme,syl,clean,tweet] return None
def validate(self,tweet): clean = wordtools.clean(tweet) syllableCount = wordtools.syllableCount(clean) if syllableCount==9 or syllableCount==6: rhyme = wordtools.getRhyme(clean[-1]) if rhyme!=None: return (syllableCount, rhyme, clean, tweet) return None
def validate(self,tweet): clean = wordtools.clean(tweet) syl = wordtools.syllableCount(clean) if syl>0: rhyme = wordtools.getRhyme(clean[-1]) if rhyme!= None: return {self.rhyme:rhyme,self.syllables:syl,self.clean:clean,self.text:tweet} return None
def validate(self, tweet): clean = wordtools.clean(tweet) syl = wordtools.syllableCount(clean) if syl > 0: rhyme = wordtools.getRhyme(clean[-1]) if rhyme != None: return [rhyme, syl, clean, tweet] return None
def validate(self, tweet): cleaned = wordtools.clean(tweet) if wordtools.validate(cleaned) and len(cleaned) > 0: return [ ''.join(c for c in self.letters if c in tweet.upper()), tweet ] else: return None
def validate(self,tweet): cleaned = wordtools.clean(tweet) meter = wordtools.getMeter(cleaned) if meter!=None and self.isIambicPentameter(meter): rhyme = wordtools.getRhyme(cleaned[-1]) if rhyme!=None: return {self.rhyme:rhyme,self.clean:cleaned,self.text:tweet} else: return None
def readTweet(self, tweet): cleaned = wordtools.clean(tweet) if not wordtools.validate(cleaned) or not len(cleaned) > 0: return if cleaned[0] in self.data[0]: self.data[0][cleaned[0]].append(tweet) else: self.data[0][cleaned[0]] = [tweet] if len(self.data[0][cleaned[0]]) == 4: self.data[1] = self.data[0][cleaned[0]] self.data[0][cleaned[0]] = []
def readTweet(self, tweet): cleaned = wordtools.clean(tweet) if not wordtools.validate(cleaned) or not len(cleaned)>0: return if cleaned[0] in self.data[0]: self.data[0][cleaned[0]].append(tweet) else: self.data[0][cleaned[0]]=[tweet] if len(self.data[0][cleaned[0]])==4: self.data[1] = self.data[0][cleaned[0]] self.data[0][cleaned[0]]=[]
def validate(self, tweet): clean = wordtools.clean(tweet) syl = wordtools.syllableCount(clean) if syl > 3 and syl < 20: rhyme = wordtools.getRhyme(clean[-1]) if rhyme != None: return { self.rhyme: rhyme, self.syllables: syl, self.clean: clean, self.text: tweet } return None
def validate(self, tweet): cleaned = wordtools.clean(tweet) if wordtools.validate(cleaned): sounds = [] for word in cleaned: sounds += wordtools.getPronunciationNoStress(word) + [" "] if len(sounds) > 4: sounds.pop() #remove the last space return sounds else: return None else: return None
def validate(self, tweet): cleaned = wordtools.clean(tweet) meter = wordtools.getMeter(cleaned) if meter != None and self.isIambicPentameter(meter): rhyme = wordtools.getRhyme(cleaned[-1]) if rhyme != None: return { self.rhyme: rhyme, self.clean: cleaned, self.text: tweet } else: return None
def validate(self, tweet): cleaned = wordtools.clean(tweet) if wordtools.validate(cleaned): sounds = [] for word in cleaned: sounds += wordtools.getPronunciationNoStress(word) + [" "] if len(sounds) > 4: sounds.pop() # remove the last space return sounds else: return None else: return None
def validate(self, tweet): clean = wordtools.clean(tweet) if not wordtools.validate(clean): return None initials = {} for i in range(len(clean)): initial = wordtools.getInitialSound(clean[i]) if initial in initials: initials[initial][0] += 1 else: initials[initial] = [1, False, False] if i < len(clean) / 2: initials[initial][1] = True else: initials[initial][2] = True if len(initials) == 0: return None if self.existsUsableSound(initials, len(clean) * self.ALLITERATIVE_FACTOR): return tweet else: return None
def validate(self, tweet): clean = wordtools.clean(tweet) syl = wordtools.syllableCount(clean) if syl > 0: return tweet return None
import wordtools import random if __name__ == "__main__": try: symbols = wordtools.abc + wordtools.marks + ' ' * 10 text = '' for i in range(300): text += symbols[random.randrange(len(symbols))] print('Random text:\n\t' + text + '\n') print('clean:\n\t{}\n\nwords:\n\t{}\n\nword_count:\n\t{}\n\n\ longest_word:\n\t{}\n\nchar_stats:\n\t{}'.format(wordtools.clean(text), wordtools.words(text), wordtools.word_count(text), wordtools.longest_word(text), wordtools.char_stats(text))) except Exception as err: print('Error occured during execution:', err) print('Type:', type(err))
def validate(self,tweet): cleaned = wordtools.clean(tweet) if wordtools.validate(cleaned): return [cleaned,tweet]
def validate(self,tweet): cleaned = wordtools.clean(tweet) if wordtools.validate(cleaned) and len(cleaned)>=2: return cleaned else: return None
def readTweet(self, tweet): clean = wordtools.clean(tweet) syl = wordtools.syllableCount(clean) if syl>0: self.data = tweet
def readTweet(self, tweet): cleaned = wordtools.clean(tweet) if cleaned[:len(self.testString)] == self.testString: self.data = tweet
def validate(self, tweet): cleaned = wordtools.clean(tweet) if wordtools.validate(cleaned) and len(cleaned) >= 2: return cleaned else: return None
def validate(self, tweet): cleaned = wordtools.clean(tweet) if wordtools.validate(cleaned): return [cleaned, tweet]
def validate(self,tweet): cleaned = wordtools.clean(tweet) if wordtools.validate(cleaned) and len(cleaned)>0: return [''.join(c for c in self.letters if c in tweet.upper()),tweet] else: return None