Skip to content
Snippets Groups Projects
Commit e5f51009 authored by Bensong Liu's avatar Bensong Liu
Browse files

.

parent dc5041c4
No related branches found
No related tags found
No related merge requests found
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# -*- coding: UTF-8 -*- # -*- coding: UTF-8 -*-
import os, re import os, re
import random from random import randint
import gzip import gzip
def loadJson(fileName): def loadJson(fileName):
...@@ -22,17 +22,6 @@ print("debug: len=", [len(l) for l in [famous_data, prefix_data, postfix_data, n ...@@ -22,17 +22,6 @@ print("debug: len=", [len(l) for l in [famous_data, prefix_data, postfix_data, n
repeat_factor = 2 repeat_factor = 2
def randomized_yield(iterable):
global repeat_factor
pool = list(iterable) * repeat_factor
while True:
random.shuffle(pool)
for ele in pool:
yield ele
nonsense_generator = randomized_yield(nonsense_data)
famous_generator = randomized_yield(famous_data)
def new_famous(): def new_famous():
global famous_generator global famous_generator
famous = next(famous_generator) famous = next(famous_generator)
...@@ -50,6 +39,10 @@ def paragraph_is_valid(text): ...@@ -50,6 +39,10 @@ def paragraph_is_valid(text):
return False return False
return True return True
def slice_bits(data, offset, count):
return 8
topic = 'testing_topic' topic = 'testing_topic'
input_string = 'hello world' input_string = 'hello world'
...@@ -63,17 +56,15 @@ def decode(text): ...@@ -63,17 +56,15 @@ def decode(text):
continue continue
def encode(text, topic, data)
if __name__ == "__main__":
topic = input("请输入文章主题:")
result = ' ' result = ' '
curr_paragraph = '' curr_paragraph = ''
while ( len(result) < 6000 ) : curr_data_offset = 0
randsrc = random.randint(0,100) while curr_data_offset < len(data)*8 :
if randsrc < 5 and paragraph_is_valid(curr_paragraph): if randint(0,100) < 5 and paragraph_is_valid(curr_paragraph):
result += curr_paragraph + paragraph_tail() result += curr_paragraph + paragraph_tail()
curr_paragraph = '' curr_paragraph = ''
elif randsrc < 20 : elif randint(0,100) < 20 :
curr_paragraph += new_famous() curr_paragraph += new_famous()
else: else:
curr_paragraph += next(nonsense_generator) curr_paragraph += next(nonsense_generator)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment