normalizer = EnglishTextNormalizer()
assert normalizer("I paid $20 million for 1,234 colour widgets.") == "i paid $20000000 for 1234 color widgets"
normalizer("I'm a little teapot, short and stout. Tip me over and pour me out!")
# A decimal that starts with 1 keeps its point, and numbers keep their value.
assert normalizer("1.5") == "1.5"
assert normalizer("2.5") == "2.5"
assert normalizer("he is 1") == "he is one"
assert normalizer("one thousand million") == "1000000000"
# "'s" is "is" after pronouns and wh-words, and possessive elsewhere.
for text, expected in [
("he's ready", "he is ready"),
("she's here", "she is here"),
("it's mine", "it is mine"),
("that's right", "that is right"),
("there's a problem", "there is a problem"),
("here's the thing", "here is the thing"),
("what's this", "what is this"),
("who's there", "who is there"),
("where's the station", "where is the station"),
("when's the party", "when is the party"),
("why's that", "why is that"),
("how's it going", "how is it going"),
# Indefinite pronouns: a predicate makes "'s" = "is",
# while a following noun makes it possessive.
("someone's at the door", "someone is at the door"),
("someone's going to the store", "someone is going to the store"),
("someone's tired", "someone is tired"),
("someone's tired of it", "someone is tired of it"),
("someone's used to it", "someone is used to it"),
("someone's married to him", "someone is married to him"),
("someone's here", "someone is here"),
("someone's back", "someone is back"),
("someone's the best", "someone is the best"),
("someone's mine", "someone is mine"),
("someone's good at math", "someone is good at math"),
("someone's past the deadline", "someone is past the deadline"),
("someone's after you", "someone is after you"),
("someone's happy to help", "someone is happy to help"),
("someone's pretty good", "someone is pretty good"),
("someone's only here", "someone is only here"),
("someone's building a house", "someone is building a house"),
("someone's meeting my friend", "someone is meeting my friend"),
("somebody's calling", "somebody is calling"),
("anyone's welcome", "anyone is welcome"),
("anybody's welcome", "anybody is welcome"),
("everyone's ready", "everyone is ready"),
("everyone's a winner", "everyone is a winner"),
("everybody's happy", "everybody is happy"),
("nobody's here", "nobody is here"),
("nobody's home", "nobody is home"),
("nobody's my boss", "nobody is my boss"),
("no one's home", "no one is home"),
("something's off", "something is off"),
("something's wrong with it", "something is wrong with it"),
("anything's possible", "anything is possible"),
("everything's fine", "everything is fine"),
("nothing's wrong", "nothing is wrong"),
("someone's car", "someones car"),
("someone's new car", "someones new car"),
("someone's red car", "someones red car"),
("someone's best friend", "someones best friend"),
("someone's birthday", "someones birthday"),
("someone's only child", "someones only child"),
("someone's last chance", "someones last chance"),
("someone's next move", "someones next move"),
("someone's own car", "someones own car"),
("someone's other car", "someones other car"),
("someone's back door", "someones back door"),
("someone's home address", "someones home address"),
("someone's past mistakes", "someones past mistakes"),
("someone's after party", "someones after party"),
("someone's down payment", "someones down payment"),
("someone's off day", "someones off day"),
("someone's building", "someones building"),
("someone's meeting is at noon", "someones meeting is at noon"),
("someone's wedding", "someones wedding"),
("someone's morning", "someones morning"),
("someone's clothing", "someones clothing"),
("someone's bed", "someones bed"),
("someone's loved ones", "someones loved ones"),
("someone's used car", "someones used car"),
("someone's married life", "someones married life"),
("everyone's favorite movie", "everyones favorite movie"),
("everyone's happy place", "everyones happy place"),
("nobody's fault", "nobodys fault"),
("John's car", "johns car"),
("the dog's bone", "the dogs bone"),
("Wittgenstein's quote", "wittgensteins quote"),
("the 1990's", "the 1990s"),
]:
assert normalizer(text) == expected, (text, normalizer(text), expected)
# Curly apostrophes normalize like straight ones.
assert normalizer("it’s John’s car") == "it is johns car"
assert normalizer("don’t stop") == "do not stop"