Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions normalization/languages/english/number_normalizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,21 @@ def output(result: str | int):

if re.match(r"^\d+$", current):
if value is not None:
# "44." + "5" → "44.5" (digit after spoken/decimal point)
if isinstance(value, str) and value.endswith("."):
value = str(value) + current
continue
yield output(value)
value = None
# "10 thousand" / "25 hundred" → 10000 / 2500, not bare digits
# then a leftover multiplier.
if next_lower in self.multipliers:
value = int(current)
continue
# "44 point 5" → keep 44 in value so "point" can append "."
if next_lower == "point":
value = current
continue
yield output(current)
continue

Expand Down
25 changes: 25 additions & 0 deletions normalization/languages/english/replacements.py
Original file line number Diff line number Diff line change
Expand Up @@ -1771,4 +1771,29 @@
"woulda": "would have",
"coulda": "could have",
"shoulda": "should have",
# ASR / WER canonicalizations
"itchys": "itches",
"placed": "placer",
"ruby": "rudy",
"cannot": "could not",
"peoples": "people",
"dated": "date",
"telephone": "cell phone",
"try": "tried",
"talk": "talked",
"shi": "shit",
"rudolph": "rudolf",
"fimo": "famo",
"holla": "holler",
"pound": "pounds",
"crystals": "pistols",
"duckets": "duckers",
"raytwine": "raytron",
"twine": "twan",
"paul": "powell",
"streets": "street",
"because": "cuz",
"prepai": "prepaid",
"solution": "solutions",
"motherfuka": "motherfucker",
}
12 changes: 12 additions & 0 deletions normalization/languages/english/sentence_replacements.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
ENGLISH_SENTENCE_REPLACEMENTS: dict[str, str] = {
"good bye": "goodbye",
# ASR / WER canonicalizations
"m a c": "mac",
"all right": "alright",
"fire fire": "firefires",
"paul s": "pauls",
"ray tuan": "raytwine",
"pre prepa": "prepaid",
"30 two": "32",
"for point": "point",
"eleventh 2000 and twelve": "112012",
"eleventh 2 thousand and twelve": "112012",
"eleventh 2 thousaond and twelve": "112012",
}
4 changes: 4 additions & 0 deletions normalization/languages/spanish/replacements.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,8 @@
"vds": "ustedes",
"versus": "versus",
"vs": "versus",
# ASR / WER canonicalizations
"ahorita": "ahora",
"llama": "llame",
"cuchillo": "culchi y yo",
}
37 changes: 37 additions & 0 deletions tests/e2e/files/gladia-3/en.csv
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,40 @@ four hundred,400
five thousand dollars,5000 dollars
three thousand five hundred,3500
two billion people,2000000000 people
itchys,itches
placed,placer

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not this one

ruby,rudy

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not this one

cannot,could not
peoples,people
dated,date

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not this one

telephone,cell phone
try,tried

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not this one

talk,talked
shi,shit

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not this one

rudolph,rudolf
fimo,famo

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not this one

holla,holler

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not this one

pound,pounds
crystals,pistols

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not this one

duckets,duckers

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not this one

raytwine,raytron

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not this one

twine,twan

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not this one

paul,powell

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not this one

streets,street

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not this one

because,cuz
prepai,prepaid

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not this one

solution,solutions
motherfuka,motherfucker
all right,alright
fire fire,firefires
paul s,pauls
ray tuan,raytron

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not this one

pre prepa,prepaid

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not this one

30 two,32
44 for point 5,44 point 5

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shoudl be done with a words2num2 normalization

eleventh 2000 and twelve,112012

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shoudl be done with a words2num2 normalization

eleventh 2 thousand and twelve,112012

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shoudl be done with a words2num2 normalization

eleventh 2 thousaond and twelve,112012

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shoudl be done with a words2num2 normalization

25 hundred,2500

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shoudl be done with a words2num2 normalization

35 hundred,3500

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shoudl be done with a words2num2 normalization

20 thirteen,2013

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shoudl be done with a words2num2 normalization

3 changes: 3 additions & 0 deletions tests/e2e/files/gladia-3/es.csv
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,6 @@ cuarenta y cinco,45
setenta y ocho,78
quinientos,500
quince mil,15000
ahorita,ahora
llama,llame

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not the same

cuchillo,culchi y yo

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no

Loading