Chiennd commited on
Commit
9b50e44
·
verified ·
1 Parent(s): c158c6a

Upload 2 files

Browse files
Files changed (2) hide show
  1. gen_string.py +109 -0
  2. text_renderer.zip +3 -0
gen_string.py ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import string
2
+ import random
3
+ from datetime import datetime, timedelta
4
+
5
+
6
+ def generate_string():
7
+ """Generates a string with VQRQ, 4 random numbers with emphasis on 0 and 1,
8
+ and 6 random characters with emphasis on O, l, and I."""
9
+ # Characters with emphasis on 0 and 1
10
+ emphasized_digits = "0011" * 2 + string.digits[2:] # Double 0 and 1, then add remaining digits
11
+
12
+ numbers = ''.join(random.choice(emphasized_digits) for _ in range(4))
13
+
14
+ # Characters with emphasis on O, l, and I
15
+ emphasized_letters = string.ascii_lowercase + "q8gezsrtrnyvlI" + string.digits
16
+
17
+ letters = ''.join(random.choice(emphasized_letters) for _ in range(6))
18
+ return f"VQRQ{numbers}{letters}"
19
+
20
+ def format_number():
21
+ """Formats a number by adding a comma (","), period ("."), or no separator
22
+ for every three digits (thousands) in the integer part, and removes the decimal
23
+ part.
24
+
25
+ Args:
26
+ number: The number to format (int or float).
27
+ separator (optional): The separator to use (",", ".", or None for no split).
28
+
29
+ Returns:
30
+ The formatted string representation of the number (integer part only).
31
+ """
32
+
33
+ number = random.randint(100000, 999999999999)
34
+ # Convert the number to a string and handle negative numbers
35
+ number_str = str(abs(number)) # Get absolute value to handle negatives
36
+
37
+ # Split the integer and decimal parts (if any) and discard the decimal part
38
+ integer_part = number_str.split(".")[0]
39
+
40
+ # Add commas or periods to the integer part
41
+ if len(integer_part) > 3:
42
+ formatted_integer = ",".join(integer_part[::-1][i:i+3] for i in range(0, len(integer_part), 3))[::-1]
43
+ else:
44
+ formatted_integer = integer_part
45
+
46
+ # Combine formatted integer with negative sign (if negative)
47
+ formatted_number = ("-" if number < 0 else "") + formatted_integer
48
+
49
+ separator = random.choice(['.', ',', ''])
50
+
51
+ formatted_number = formatted_number.replace(",", separator)
52
+
53
+ return formatted_number
54
+
55
+ def generate_random_hour():
56
+ """Generates a random hour in the format HH:MM (or HH:MM:SS) with a random date
57
+ (day, month, year), a random date separator ("/" or "-"), and optional seconds.
58
+
59
+ Returns:
60
+ The formatted string representation of the random hour with the specified details.
61
+ """
62
+
63
+ # Get a random date within the past year
64
+ max_delta_days = 365 # Adjust for desired date range (e.g., 30 for past month)
65
+ random_delta_days = random.randint(0, max_delta_days)
66
+ random_date = datetime.now() - timedelta(days=random_delta_days)
67
+
68
+ # Extract day, month, and year from the random date
69
+ current_year = random_date.year
70
+ current_month = random_date.month
71
+ current_day = random_date.day
72
+
73
+ # Generate random hour (0-23) and minute (0-59)
74
+ hour = random.randint(0, 23)
75
+ minute = random.randint(0, 59)
76
+
77
+ # Include seconds randomly
78
+ include_seconds = random.choice([True, False]) # Randomly choose True or False
79
+
80
+ # Generate random second (optional)
81
+ if include_seconds:
82
+ second = random.randint(0, 59)
83
+ else:
84
+ second = None # Set to None if not including seconds
85
+
86
+ # Choose random date separator
87
+ date_separators = ["/", "-"]
88
+ date_separator = random.choice(date_separators)
89
+
90
+ # Format the time string
91
+ time_str = f"{hour:02d}:{minute:02d}"
92
+ if include_seconds:
93
+ time_str += f":{second:02d}"
94
+
95
+ # Format the date string with chosen separator
96
+ date_str = f"{current_day}{date_separator}{current_month}{date_separator}{current_year}"
97
+
98
+ # Combine time and date strings
99
+ return f"{time_str} {date_str}"
100
+
101
+
102
+ # Open the file in write mode
103
+ with open("val_strings.txt", "w") as file:
104
+ for i in range(50000):
105
+ selected_function = random.choice([generate_random_hour, generate_string, format_number])
106
+ strings = selected_function()
107
+ # Write each string to a new line
108
+ file.write(strings + '\n')
109
+
text_renderer.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7530306ec77826303ba882558eb2effeceaf3faa8ec2d6592a9eb920ac847129
3
+ size 42918493