aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/numspell.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/numspell.py')
-rw-r--r--scripts/numspell.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/scripts/numspell.py b/scripts/numspell.py
index 2e416e3..9b5979e 100644
--- a/scripts/numspell.py
+++ b/scripts/numspell.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-"""Pasa los numeros de una transcripcion a palabras, para poder compararla
-con el guion (que escribe todo en letras)."""
+"""Turns the numbers in a transcription into words, so it can be compared
+with the script (which spells everything out)."""
import re
U = ["cero", "uno", "dos", "tres", "cuatro", "cinco", "seis", "siete", "ocho", "nueve",
@@ -30,11 +30,11 @@ def spell_int(n):
return _lt1000(n)
if n < 1000000:
m, r = divmod(n, 1000)
- pre = "mil" if m == 1 else _lt1000(m) + " mil"
- return pre + (" " + _lt1000(r) if r else "")
+ pre_frames = "mil" if m == 1 else _lt1000(m) + " mil"
+ return pre_frames + (" " + _lt1000(r) if r else "")
m, r = divmod(n, 1000000)
- pre = "un millon" if m == 1 else _lt1000(m) + " millones"
- return pre + (" " + spell_int(r) if r else "")
+ pre_frames = "un millon" if m == 1 else _lt1000(m) + " millones"
+ return pre_frames + (" " + spell_int(r) if r else "")
def _tok(m):
@@ -42,10 +42,10 @@ def _tok(m):
s = re.sub(r"\.(?=\d{3}\b)", "", s) # 384.000 -> 384000
if "," in s:
a, b = s.split(",", 1)
- ent = spell_int(int(a or 0))
+ whole = spell_int(int(a or 0))
dec = " ".join(U[int(c)] for c in b if c.isdigit())
- return f"{ent} coma {dec}"
- if "." in s: # 0.5 estilo ingles
+ return f"{whole} coma {dec}"
+ if "." in s: # 0.5 English style
a, b = s.split(".", 1)
return f"{spell_int(int(a or 0))} coma " + " ".join(U[int(c)] for c in b if c.isdigit())
return spell_int(int(s))