def text_meme(sub): # showerthoughts or quotes r = get_text(sub, 100) requsted = random.choice(r) return jsonify({ 'Title': requsted["Title"], 'Selftext': requsted["text"], 'Upvotes': requsted["Upvotes"], 'Downvotes': requsted["Downvotes"], 'Redditurl': requsted["Redditurl"], 'Subreddit': requsted["Subreddit"] })
def text_count_meme(sub, count): if count >= 50: return jsonify({ 'status_code': 400, 'message': 'Please ensure the count is less than 50' }) requested = get_text(sub, 100) random.shuffle(requested) textmeme = [] for post in requested: if len(textmeme) != count: t = { 'Title': post["Title"], 'Selftext': post["text"], 'Upvotes': post["Upvotes"], 'Downvotes': post["Downvotes"], 'Redditurl': post["Redditurl"], 'Subreddit': post["Subreddit"] } textmeme.append(t) return jsonify({'sub': textmeme, 'count': len(textmeme)})
def test_simple_pdf(self): text = "this is a simple test" content = open('tests/simplepdf1.pdf', 'r').read() self.assertEqual(main.get_text(content), text)
def test_plain_text(self): text = 'this is plain text' self.assertEqual(main.get_text(text), text)
def test_change2(self): self.assertEqual(main.get_word_stats(main.get_text('abc;dyfinitely ghjoolies \n jkl3 foo bar'), main.get_text('abc;definitely ghioolies foo bar')), (6, 3))
def test_change(self): self.assertEqual(main.get_word_stats(main.get_text('abc;def ghi \n jkl3 foo bar'), main.get_text('abc;def ghi foo bar')), (6, 1))
def test_blank(self): self.assertEqual(main.get_word_stats(main.get_text('abc;def ghi \n jkl3 ')), (4, 0))
def get_sender_name(): return main.get_text()[1:].rsplit('!', 1)[0]
def get_text(): main.get_text()
def test(): s = Summarizer() text = get_text( 'http://www.techtimes.com/articles/60808/20150616/xbox-one-backward-compatibility-heres-an-initial-list-of-xbox-360-games-you-can-play.htm' ) return "\n".join(s.summarize())
disp.display() width = disp.width height = disp.height image1 = Image.new('1', (width, height)) draw = ImageDraw.Draw(image1) draw.rectangle((0, 0, width, height), outline=0, fill=0) padding = -2 top = padding bottom = height - padding x = 0 font = ImageFont.load_default() while True: [keys, ent] = m.get_text() phrases = keys[1] print('key phrases: ', phrases) draw.rectangle((0, 0, width, height), outline=0, fill=255) # Write two lines of text. disp.clear() disp.display() draw.text((x, top + 16), phrases, font=font, fill=0) '''draw.text((x, top+8), "Circuit Digest", font=font, fill=255) draw.text((x, top+16), "For more Videos", font=font, fill=255) draw.text((x, top+25), "Visit at", font=font, fill=255) draw.text((x, top+34), "www.circuitdigest.com", font=font, fill=255)''' # Display image. disp.image(image1)