Refactoring: Move
Mode random helper functions
This commit is contained in:
parent
cc86a79ac7
commit
6728642a4f
@ -3,6 +3,26 @@ import random
|
||||
from loguru import logger
|
||||
|
||||
random_seed = random.randint(0, 2**32 - 1)
|
||||
# random_seed = 2973413116
|
||||
# random_seed = 2212357755
|
||||
|
||||
# random_seed = 2987558464 # light green
|
||||
|
||||
# random_seed = 1173898033 # strange bar plot
|
||||
|
||||
# 2467967671
|
||||
|
||||
logger.info(f"Random seed: {random_seed}")
|
||||
rnd = random.Random(random_seed)
|
||||
|
||||
|
||||
def maybe():
|
||||
return rnd.random() > 0.9
|
||||
|
||||
|
||||
def possibly():
|
||||
return rnd.random() > 0.5
|
||||
|
||||
|
||||
def probably():
|
||||
return rnd.random() > 0.4
|
||||
|
||||
14
test/fixtures/page_generation/page.py
vendored
14
test/fixtures/page_generation/page.py
vendored
@ -23,7 +23,7 @@ from cv_analysis.utils.merging import merge_related_rectangles
|
||||
from cv_analysis.utils.postprocessing import remove_overlapping, remove_included
|
||||
from cv_analysis.utils.spacial import area
|
||||
from synthesis.partitioner.two_column import TwoColumnPagePartitioner
|
||||
from synthesis.random import rnd
|
||||
from synthesis.random import rnd, maybe, possibly, probably
|
||||
from synthesis.segment.content_rectangle import ContentRectangle
|
||||
from synthesis.segment.random_content_rectangle import RandomContentRectangle
|
||||
from synthesis.segment.text_block.text_block import TextBlock
|
||||
@ -816,18 +816,6 @@ class RandomPlot(RandomContentRectangle):
|
||||
self.content = image if not self.content else superimpose(self.content, image)
|
||||
|
||||
|
||||
def maybe():
|
||||
return rnd.random() > 0.9
|
||||
|
||||
|
||||
def possibly():
|
||||
return rnd.random() > 0.5
|
||||
|
||||
|
||||
def probably():
|
||||
return rnd.random() > 0.4
|
||||
|
||||
|
||||
def generate_random_text_block(rectangle: Rectangle, n_sentences=3000) -> ContentRectangle:
|
||||
block = TextBlock(
|
||||
*rectangle.coords,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user