ShynBui commited on
Commit
6191d4c
·
1 Parent(s): 7b19804

add base 10 for logarit

Browse files
Files changed (2) hide show
  1. __pycache__/utils.cpython-310.pyc +0 -0
  2. utils.py +6 -5
__pycache__/utils.cpython-310.pyc CHANGED
Binary files a/__pycache__/utils.cpython-310.pyc and b/__pycache__/utils.cpython-310.pyc differ
 
utils.py CHANGED
@@ -32,7 +32,7 @@ def character_replacement(text, error_rate=0.03, C=0.01):
32
  '''
33
 
34
  # Tính toán xác suất thay thế ký tự dựa trên error_rate sử dụng hàm logarit
35
- augmentation_probability = C / math.log(error_rate + 1)
36
 
37
  # Bàn phím QWERTY tiếng Việt
38
  keyboard = {
@@ -178,7 +178,7 @@ def character_insertion(text, error_rate=0.03, C=0.01):
178
  num_errors = 1 if random.random() > 0.5 else 0
179
 
180
  # Tính toán xác suất chèn ký tự dựa trên error_rate sử dụng hàm logarit
181
- augmentation_probability = C / math.log(error_rate + 1)
182
 
183
  # Thực hiện thêm ký tự tại các vị trí ngẫu nhiên
184
  for _ in range(num_errors):
@@ -220,7 +220,7 @@ def character_deletion(text, error_rate=0.03, C=0.01):
220
 
221
 
222
  # Tính toán xác suất xóa ký tự dựa trên error_rate sử dụng hàm logarit
223
- augmentation_probability = C / math.log(error_rate + 1)
224
 
225
  # Thực hiện xóa ký tự tại các vị trí ngẫu nhiên
226
  for _ in range(num_errors):
@@ -259,7 +259,7 @@ def character_transposition(text, error_rate=0.03, C=0.01):
259
  num_errors = 1 if random.random() > 0.5 else 0
260
 
261
  # Tính toán xác suất hoán đổi ký tự dựa trên error_rate sử dụng hàm logarit
262
- augmentation_probability = C / math.log(error_rate + 1)
263
 
264
  # Thực hiện hoán đổi ký tự tại các vị trí ngẫu nhiên
265
  for _ in range(num_errors):
@@ -318,7 +318,7 @@ def homophone_replacement(text, error_rate=0.03, C=0.01):
318
  break
319
 
320
  # Tính toán xác suất thay thế từ dựa trên error_rate sử dụng hàm logarit
321
- augmentation_probability = C / math.log(error_rate + 1)
322
 
323
  # Thực hiện thay thế từ tại các vị trí ngẫu nhiên
324
  num_errors = int(len(text) * error_rate)
@@ -451,3 +451,4 @@ def similar_character_replacement(text, error_rate=0.03, C=0.01):
451
 
452
  # Ghép các ký tự lại thành chuỗi văn bản
453
  return ''.join(characters)
 
 
32
  '''
33
 
34
  # Tính toán xác suất thay thế ký tự dựa trên error_rate sử dụng hàm logarit
35
+ augmentation_probability = C / math.log(error_rate + 1, 10)
36
 
37
  # Bàn phím QWERTY tiếng Việt
38
  keyboard = {
 
178
  num_errors = 1 if random.random() > 0.5 else 0
179
 
180
  # Tính toán xác suất chèn ký tự dựa trên error_rate sử dụng hàm logarit
181
+ augmentation_probability = C / math.log(error_rate + 1, 10)
182
 
183
  # Thực hiện thêm ký tự tại các vị trí ngẫu nhiên
184
  for _ in range(num_errors):
 
220
 
221
 
222
  # Tính toán xác suất xóa ký tự dựa trên error_rate sử dụng hàm logarit
223
+ augmentation_probability = C / math.log(error_rate + 1, 10)
224
 
225
  # Thực hiện xóa ký tự tại các vị trí ngẫu nhiên
226
  for _ in range(num_errors):
 
259
  num_errors = 1 if random.random() > 0.5 else 0
260
 
261
  # Tính toán xác suất hoán đổi ký tự dựa trên error_rate sử dụng hàm logarit
262
+ augmentation_probability = C / math.log(error_rate + 1, 10)
263
 
264
  # Thực hiện hoán đổi ký tự tại các vị trí ngẫu nhiên
265
  for _ in range(num_errors):
 
318
  break
319
 
320
  # Tính toán xác suất thay thế từ dựa trên error_rate sử dụng hàm logarit
321
+ augmentation_probability = C / math.log(error_rate + 1, 10)
322
 
323
  # Thực hiện thay thế từ tại các vị trí ngẫu nhiên
324
  num_errors = int(len(text) * error_rate)
 
451
 
452
  # Ghép các ký tự lại thành chuỗi văn bản
453
  return ''.join(characters)
454
+