How to use the markovify.split_into_sentences function in markovify

To help you get started, we’ve selected a few markovify examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dasu / syrup-sopel-modules / wafflebot.py View on Github external
def sentence_split(self, text):
    lines = text.splitlines()
    text = " ".join([self._prepare_text(line) for line in lines if line.strip()])

    return markovify.split_into_sentences(text)
github Deimos / SubredditSimulator / subreddit_simulator / models.py View on Github external
def sentence_split(self, text):
        # split everything up by newlines, prepare them, and join back together
        lines = text.splitlines()
        text = " ".join([self._prepare_text(line)
            for line in lines if line.strip()])

        return markovify.split_into_sentences(text)
github trambelus / UserSim / usim.py View on Github external
comments = get_comments(r, source, limit)
		if comments == None:
			return (None, None, None)
		c_finished = False
		while not c_finished:
			body = []
			total_sentences = 0
			recursion_testing = True
			try:
				for c in comments:
					if ('+/u/%s' % USER.lower()) not in c.body.lower():
						recursion_testing = False
					if (not c.distinguished) and ((not subreddit) or c.subreddit.display_name == subreddit):
						body.append(c.body)
						try:
							total_sentences += len(markovify.split_into_sentences(c.body))
						except Exception:
							# Ain't no way I'm letting a little feature like this screw up my processing, no matter what happens
							total_sentences += 1
				c_finished = True
			except praw.exceptions.PRAWException as ex:
				log(str(ex))
				pass
		num_comments = len(body)
		if num_comments >= MIN_COMMENTS and recursion_testing:
			return (0, 0, 0)
		sentence_avg = total_sentences / num_comments if num_comments > 0 else 0
		body = ' '.join(body)
		return (body, num_comments, sentence_avg)

	except praw.exceptions.PRAWException as ex:
		log(str(ex))