brenorb commited on
Commit
a9bbb13
·
verified ·
1 Parent(s): eb4dc80

Front end v1.1: y reads as i, 131 new respellings

Browse files

Same weights, ONNX and config as v1. Details: docs/v1.md (v1.1) at https://github.com/brenorb/tiny-broca

Files changed (1) hide show
  1. text.py +143 -1
text.py CHANGED
@@ -906,7 +906,6 @@ vegan végan
906
  peeling pílin
907
  piercing pírcin
908
  tattoo tatu
909
- yoga ióga
910
  spa ispá
911
  legging léguin
912
  blush blâxe
@@ -1207,6 +1206,137 @@ deliveries delíveris
1207
  barmen bármen
1208
  hobby róbi
1209
  hobbies róbis
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1210
  """
1211
 
1212
  # Acronyms, matched case-sensitively in upper case (a lower-case "s" plural is
@@ -1338,6 +1468,8 @@ DJ didjêi
1338
  MP3 eme pê três
1339
  MP4 eme pê quatro
1340
  OFF ófe
 
 
1341
  """
1342
 
1343
  _ABBREVIATIONS = (
@@ -1585,6 +1717,10 @@ _LONE_CONSONANT = re.compile(r"(?<![\w'.])([B-DF-HJ-NP-TV-Z])(?![\w'])")
1585
  _LONE_VOWEL = re.compile(r"\b(plano|vitamina|letra|classe|tipo|grupo|nota|série|opção|item|bloco|setor|ala|portão|"
1586
  r"fila|turma|seção|categoria|modelo|versão|lado|prédio|torre|sala)\s+([AEIOU])(?![\w'])",
1587
  re.IGNORECASE)
 
 
 
 
1588
  _LETTER_HYPHEN_DIGIT = re.compile(r"(?<=[A-Za-zÀ-ú])-(?=\d)")
1589
  _LONE_HASH = re.compile(r"(?<!\S)#(?!\S)")
1590
  _LONE_STAR = re.compile(r"(?<!\d )(?<!\S)\*(?!\S)(?! \d)")
@@ -2417,9 +2553,15 @@ def spoken_form(text):
2417
  text = _LOANWORD.sub(_loanword, text)
2418
  text = _SLANG_RE.sub(_slang, text)
2419
  text = _LONE_VOWEL.sub(lambda m: m.group(1) + " " + _LETTER_NAMES[m.group(2).lower()], text)
 
 
2420
  text = _LONE_CONSONANT.sub(lambda m: " " + _LETTER_NAMES[m.group(1).lower()] + " ", text)
2421
  text = _CONSONANTS_ONLY.sub(lambda m: " " + _spell_letters(m.group(0)) + " ", text)
2422
  text = _cleanup(text)
 
 
 
 
2423
  text = _REPEATED_PUNCT.sub(lambda m: m.group(1) or m.group(2), text)
2424
  text = re.sub(r"\s+", " ", text)
2425
  text = _SPACE_BEFORE_PUNCT.sub(r"\1", text)
 
906
  peeling pílin
907
  piercing pírcin
908
  tattoo tatu
 
909
  spa ispá
910
  legging léguin
911
  blush blâxe
 
1206
  barmen bármen
1207
  hobby róbi
1208
  hobbies róbis
1209
+ exchange equistchêindje
1210
+ seed síde
1211
+ seed phrase síde frêize
1212
+ private key práivete quí
1213
+ public key páblique quí
1214
+ hash réxe
1215
+ hashrate réxe rêite
1216
+ halving rálvin
1217
+ node nôude
1218
+ lightning láitnin
1219
+ network nétuórque
1220
+ lightning network láitnin nétuórque
1221
+ satoshi satôxi
1222
+ hodler rôdler
1223
+ tether téder
1224
+ ether éter
1225
+ ripple rípou
1226
+ polygon póligon
1227
+ memecoin mímecóin
1228
+ defi difái
1229
+ web3 uébe três
1230
+ smart contract ismarte cóntrecte
1231
+ fee fí
1232
+ airdrop érdrópe
1233
+ long lóngue
1234
+ market márquete
1235
+ bull market búl márquete
1236
+ bear market bér márquete
1237
+ pump pâmpe
1238
+ dump dâmpe
1239
+ rug pull râgue púl
1240
+ binance binânce
1241
+ coinbase cóinbêise
1242
+ bybit báibite
1243
+ ledger léjer
1244
+ coldcard côulde cárde
1245
+ cold wallet côulde uólete
1246
+ hot wallet róte uólete
1247
+ blockstream blóquistrím
1248
+ taproot téprúte
1249
+ segwit ségue uíte
1250
+ multisig multissígue
1251
+ mempool mêmpúl
1252
+ testnet testenéte
1253
+ mainnet mêinenéte
1254
+ nostr nóster
1255
+ cashu cachú
1256
+ ecash iquéxe
1257
+ strike istráique
1258
+ peer-to-peer pír tu pír
1259
+ proof of work prúfe óve uórque
1260
+ proof of stake prúfe óve istêique
1261
+ bitcoiner bitecóiner
1262
+ shitcoin xitecóin
1263
+ orange pill órendje pil
1264
+ sound money sáunde mâni
1265
+ bitdevs bitedévis
1266
+ whitepaper uáitepêiper
1267
+ on-chain ontchêin
1268
+ off-chain ófe tchêin
1269
+ layer lêier
1270
+ sidechain sáidetchêin
1271
+ bitcoin core bitecóin córe
1272
+ llama lhama
1273
+ grok gróque
1274
+ perplexity perpléksiti
1275
+ runway ranuêi
1276
+ whisper uísper
1277
+ lovable lâvabou
1278
+ replit réplite
1279
+ vercel vércel
1280
+ supabase supabêize
1281
+ zapier zápier
1282
+ fine-tune fáine tiúne
1283
+ fine tune fáine tiúne
1284
+ engineering endjiníring
1285
+ prompt engineering prômpite endjiníring
1286
+ pytorch páitórtche
1287
+ tensorflow ténsorflôu
1288
+ jupyter júpiter
1289
+ open source ôupen sórce
1290
+ label lêibou
1291
+ batch bétche
1292
+ checkpoint tchéquipóinte
1293
+ deepfake dípefêique
1294
+ coding côudin
1295
+ vibe coding váibe côudin
1296
+ reasoning rízonin
1297
+ hugging face râguin fêice
1298
+ stable diffusion istêibou difiúzon
1299
+ follow fólou
1300
+ unfollow anfólou
1301
+ push púxe
1302
+ edge édje
1303
+ excel écsel
1304
+ dropbox drópebóx
1305
+ icloud aicláude
1306
+ onedrive uândráive
1307
+ airpods érpódis
1308
+ bluesky blusscái
1309
+ substack sâbstéque
1310
+ medium mídium
1311
+ patreon pêitreon
1312
+ tyson táisson
1313
+ mike máique
1314
+ ryan ráian
1315
+ taylor têilor
1316
+ kyle cáiou
1317
+ byron báiron
1318
+ cyber sáiber
1319
+ cyberbullying sáiberbúlin
1320
+ freestyle fristáile
1321
+ lifestyle laifistáile
1322
+ style istáile
1323
+ dry fit drái fíte
1324
+ sky iscái
1325
+ fly flái
1326
+ daisy dêizi
1327
+ clayton clêiton
1328
+ wayne uêine
1329
+ haley rêili
1330
+ amy êimi
1331
+ bryan bráian
1332
+ mary méri
1333
+ sandy sêndi
1334
+ nancy nênsi
1335
+ harry réri
1336
+ wendy uêndi
1337
+ on chain ontchêin
1338
+ off chain ófe tchêin
1339
+ peer to peer pír tu pír
1340
  """
1341
 
1342
  # Acronyms, matched case-sensitively in upper case (a lower-case "s" plural is
 
1468
  MP3 eme pê três
1469
  MP4 eme pê quatro
1470
  OFF ófe
1471
+ HODL rôdou
1472
+ FUD fâde
1473
  """
1474
 
1475
  _ABBREVIATIONS = (
 
1717
  _LONE_VOWEL = re.compile(r"\b(plano|vitamina|letra|classe|tipo|grupo|nota|série|opção|item|bloco|setor|ala|portão|"
1718
  r"fila|turma|seção|categoria|modelo|versão|lado|prédio|torre|sala)\s+([AEIOU])(?![\w'])",
1719
  re.IGNORECASE)
1720
+ # A lone y is the letter (eixo y, f(x, y), a letra 'y'), except a lower-case y between
1721
+ # capitalised words, which is the Spanish conjunction and reads as i (Ortega y Gasset).
1722
+ _SPANISH_Y = re.compile(r"(\b[A-ZÀ-Ú][^\W\d_]*)(\s+)y(\s+)(?=[A-ZÀ-Ú])")
1723
+ _LONE_Y = re.compile(r"(?<!\w)(?<!\w')y(?!\w)(?!'\w)", re.IGNORECASE)
1724
  _LETTER_HYPHEN_DIGIT = re.compile(r"(?<=[A-Za-zÀ-ú])-(?=\d)")
1725
  _LONE_HASH = re.compile(r"(?<!\S)#(?!\S)")
1726
  _LONE_STAR = re.compile(r"(?<!\d )(?<!\S)\*(?!\S)(?! \d)")
 
2553
  text = _LOANWORD.sub(_loanword, text)
2554
  text = _SLANG_RE.sub(_slang, text)
2555
  text = _LONE_VOWEL.sub(lambda m: m.group(1) + " " + _LETTER_NAMES[m.group(2).lower()], text)
2556
+ text = _SPANISH_Y.sub(r"\1\2i\3", text)
2557
+ text = _LONE_Y.sub("ípsilon", text)
2558
  text = _LONE_CONSONANT.sub(lambda m: " " + _LETTER_NAMES[m.group(1).lower()] + " ", text)
2559
  text = _CONSONANTS_ONLY.sub(lambda m: " " + _spell_letters(m.group(0)) + " ", text)
2560
  text = _cleanup(text)
2561
+ # Portuguese spelling reads y as i (Paraty, Ypiranga, Stefany, Yuri). English words that
2562
+ # say it otherwise (byte, Tyson, Taylor) are respelled by the loanword table, which has run.
2563
+ # After _cleanup, which folds ý, ÿ, ỹ... into y.
2564
+ text = text.replace("y", "i").replace("Y", "I")
2565
  text = _REPEATED_PUNCT.sub(lambda m: m.group(1) or m.group(2), text)
2566
  text = re.sub(r"\s+", " ", text)
2567
  text = _SPACE_BEFORE_PUNCT.sub(r"\1", text)