fix data generation: hidden data is local
otherwise, the first data generation emties the data and the second get none
This commit is contained in:
parent
e71e30ce86
commit
c6d2415271
11
generate.py
11
generate.py
|
@ -200,14 +200,10 @@ network = Network(
|
|||
),
|
||||
)
|
||||
|
||||
def pop_hidden_data():
|
||||
global hidden_data
|
||||
index = randint(0, len(hidden_data) - 1)
|
||||
return hidden_data.pop(index)
|
||||
|
||||
def generate_text(number_of_lines = 200, language = None):
|
||||
""" language can be None (both), "en" or "de".
|
||||
"""
|
||||
local_hidden_data = hidden_data[:]
|
||||
do_german = not language or language == "de"
|
||||
do_english = not language or language == "en"
|
||||
result = ""
|
||||
|
@ -225,8 +221,9 @@ def generate_text(number_of_lines = 200, language = None):
|
|||
english += both
|
||||
if do_german: result += german + "\n"
|
||||
if do_english: result += english + "\n"
|
||||
if random() < len(hidden_data) / (number_of_lines - i):
|
||||
hidden_line = pop_hidden_data()
|
||||
if random() < len(local_hidden_data) / (number_of_lines - i):
|
||||
index = randint(0, len(local_hidden_data) - 1)
|
||||
hidden_line = local_hidden_data.pop(index)
|
||||
german, english = hidden_line.split("\n")
|
||||
if do_german: result += german + "\n"
|
||||
if do_english: result += english + "\n"
|
||||
|
|
Loading…
Reference in a new issue