Baseline: main branch state prior to Top-10 films expansion
This commit is contained in:
commit
6b15603e56
139 files changed
+329420
No files matched your search
+654
@@ -0,0 +1,654 @@
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// src/index.ts
|
||||
var index_exports = {};
|
||||
__export(index_exports, {
|
||||
KNOWN_INITIALISMS: () => KNOWN_INITIALISMS,
|
||||
LETTER_PHONEMES: () => LETTER_PHONEMES,
|
||||
diagnoseUnknown: () => diagnoseUnknown,
|
||||
isInitialism: () => isInitialism,
|
||||
matchBritish: () => matchBritish,
|
||||
parseInitialismWithSuffix: () => parseInitialismWithSuffix,
|
||||
translateAsAcronym: () => translateAsAcronym,
|
||||
translateUnknown: () => translateUnknown
|
||||
});
|
||||
module.exports = __toCommonJS(index_exports);
|
||||
var import_dictionary4 = require("@ingglish/dictionary");
|
||||
var import_g2p = require("@ingglish/g2p");
|
||||
var import_phonemes5 = require("@ingglish/phonemes");
|
||||
|
||||
// src/acronyms.ts
|
||||
var import_phonemes = require("@ingglish/phonemes");
|
||||
var INITIALISM_EXPANSIONS = {
|
||||
ac: ["alternating", "current"],
|
||||
ad: ["anno", "domini"],
|
||||
afk: ["away", "from", "keyboard"],
|
||||
// AI / ML
|
||||
ai: ["artificial", "intelligence"],
|
||||
aka: ["also", "known", "as"],
|
||||
am: ["ante", "meridiem"],
|
||||
api: ["application", "programming", "interface"],
|
||||
asap: ["as", "soon", "as", "possible"],
|
||||
atm: ["automated", "teller", "machine"],
|
||||
aws: ["amazon", "web", "services"],
|
||||
b2b: ["business", "to", "business"],
|
||||
b2c: ["business", "to", "consumer"],
|
||||
bc: ["before", "christ"],
|
||||
bdd: ["behavior", "driven", "development"],
|
||||
brb: ["be", "right", "back"],
|
||||
btw: ["by", "the", "way"],
|
||||
byob: ["bring", "your", "own", "bottle"],
|
||||
cd: ["continuous", "deployment"],
|
||||
cdn: ["content", "delivery", "network"],
|
||||
// Business / titles
|
||||
ceo: ["chief", "executive", "officer"],
|
||||
cfo: ["chief", "financial", "officer"],
|
||||
ci: ["continuous", "integration"],
|
||||
cia: ["central", "intelligence", "agency"],
|
||||
cio: ["chief", "information", "officer"],
|
||||
cli: ["command", "line", "interface"],
|
||||
cmo: ["chief", "marketing", "officer"],
|
||||
cms: ["content", "management", "system"],
|
||||
cnn: ["convolutional", "neural", "network"],
|
||||
coo: ["chief", "operating", "officer"],
|
||||
cors: ["cross", "origin", "resource", "sharing"],
|
||||
cpr: ["cardiopulmonary", "resuscitation"],
|
||||
cpu: ["central", "processing", "unit"],
|
||||
crm: ["customer", "relationship", "management"],
|
||||
crud: ["create", "read", "update", "delete"],
|
||||
cso: ["chief", "security", "officer"],
|
||||
css: ["cascading", "style", "sheets"],
|
||||
csv: ["comma", "separated", "values"],
|
||||
cto: ["chief", "technology", "officer"],
|
||||
dc: ["direct", "current"],
|
||||
ddos: ["distributed", "denial", "of", "service"],
|
||||
dea: ["drug", "enforcement", "administration"],
|
||||
diy: ["do", "it", "yourself"],
|
||||
dj: ["disc", "jockey"],
|
||||
dmv: ["department", "of", "motor", "vehicles"],
|
||||
// Medical / science
|
||||
dna: ["deoxyribonucleic", "acid"],
|
||||
dns: ["domain", "name", "system"],
|
||||
eod: ["end", "of", "day"],
|
||||
epa: ["environmental", "protection", "agency"],
|
||||
er: ["emergency", "room"],
|
||||
erp: ["enterprise", "resource", "planning"],
|
||||
eta: ["estimated", "time", "of", "arrival"],
|
||||
etl: ["extract", "transform", "load"],
|
||||
eu: ["european", "union"],
|
||||
faq: ["frequently", "asked", "questions"],
|
||||
// Government / organizations
|
||||
fbi: ["federal", "bureau", "of", "investigation"],
|
||||
fda: ["food", "and", "drug", "administration"],
|
||||
ftp: ["file", "transfer", "protocol"],
|
||||
fyi: ["for", "your", "information"],
|
||||
gan: ["generative", "adversarial", "network"],
|
||||
gcp: ["google", "cloud", "platform"],
|
||||
gif: ["graphics", "interchange", "format"],
|
||||
gps: ["global", "positioning", "system"],
|
||||
gpt: ["generative", "pre-trained", "transformer"],
|
||||
gpu: ["graphics", "processing", "unit"],
|
||||
gui: ["graphical", "user", "interface"],
|
||||
hdd: ["hard", "disk", "drive"],
|
||||
hiv: ["human", "immunodeficiency", "virus"],
|
||||
hr: ["human", "resources"],
|
||||
html: ["hypertext", "markup", "language"],
|
||||
http: ["hypertext", "transfer", "protocol"],
|
||||
https: ["hypertext", "transfer", "protocol", "secure"],
|
||||
iaas: ["infrastructure", "as", "a", "service"],
|
||||
icu: ["intensive", "care", "unit"],
|
||||
// General / common
|
||||
id: ["identification"],
|
||||
ide: ["integrated", "development", "environment"],
|
||||
idk: ["i", "don't", "know"],
|
||||
imo: ["in", "my", "opinion"],
|
||||
io: ["input", "output"],
|
||||
ip: ["internet", "protocol"],
|
||||
iq: ["intelligence", "quotient"],
|
||||
irs: ["internal", "revenue", "service"],
|
||||
isp: ["internet", "service", "provider"],
|
||||
it: ["information", "technology"],
|
||||
jpeg: ["joint", "photographic", "experts", "group"],
|
||||
// Media
|
||||
jpg: ["joint", "photographic", "experts", "group"],
|
||||
json: ["javascript", "object", "notation"],
|
||||
jwt: ["json", "web", "token"],
|
||||
kpi: ["key", "performance", "indicator"],
|
||||
// Networking
|
||||
lan: ["local", "area", "network"],
|
||||
lcd: ["liquid", "crystal", "display"],
|
||||
led: ["light", "emitting", "diode"],
|
||||
llm: ["large", "language", "model"],
|
||||
mc: ["master", "of", "ceremonies"],
|
||||
// Security
|
||||
mfa: ["multi", "factor", "authentication"],
|
||||
ml: ["machine", "learning"],
|
||||
mp3: ["moving", "picture", "experts", "group", "audio", "layer"],
|
||||
mp4: ["moving", "picture", "experts", "group"],
|
||||
mph: ["miles", "per", "hour"],
|
||||
mri: ["magnetic", "resonance", "imaging"],
|
||||
mvp: ["minimum", "viable", "product"],
|
||||
nasa: ["national", "aeronautics", "space", "administration"],
|
||||
// Acronyms pronounced as words (pass through unchanged like initialisms)
|
||||
nato: ["north", "atlantic", "treaty", "organization"],
|
||||
nda: ["non", "disclosure", "agreement"],
|
||||
nic: ["network", "interface", "card"],
|
||||
nlp: ["natural", "language", "processing"],
|
||||
nosql: ["not", "only", "sql"],
|
||||
nsa: ["national", "security", "agency"],
|
||||
nsfw: ["not", "safe", "for", "work"],
|
||||
nyc: ["new", "york", "city"],
|
||||
omg: ["oh", "my", "god"],
|
||||
ooo: ["out", "of", "office"],
|
||||
// Development
|
||||
oop: ["object", "oriented", "programming"],
|
||||
orm: ["object", "relational", "mapping"],
|
||||
os: ["operating", "system"],
|
||||
otp: ["one", "time", "password"],
|
||||
paas: ["platform", "as", "a", "service"],
|
||||
pc: ["personal", "computer"],
|
||||
pdf: ["portable", "document", "format"],
|
||||
php: ["hypertext", "preprocessor"],
|
||||
pm: ["post", "meridiem"],
|
||||
png: ["portable", "network", "graphics"],
|
||||
pov: ["point", "of", "view"],
|
||||
pr: ["public", "relations"],
|
||||
pto: ["paid", "time", "off"],
|
||||
qa: ["quality", "assurance"],
|
||||
rag: ["retrieval", "augmented", "generation"],
|
||||
ram: ["random", "access", "memory"],
|
||||
rfp: ["request", "for", "proposal"],
|
||||
rip: ["rest", "in", "peace"],
|
||||
rna: ["ribonucleic", "acid"],
|
||||
rnn: ["recurrent", "neural", "network"],
|
||||
roi: ["return", "on", "investment"],
|
||||
rom: ["read", "only", "memory"],
|
||||
rpm: ["revolutions", "per", "minute"],
|
||||
rsvp: ["please", "respond"],
|
||||
rv: ["recreational", "vehicle"],
|
||||
// Cloud / services
|
||||
saas: ["software", "as", "a", "service"],
|
||||
sdk: ["software", "development", "kit"],
|
||||
sftp: ["secure", "file", "transfer", "protocol"],
|
||||
sla: ["service", "level", "agreement"],
|
||||
// Database
|
||||
sql: ["structured", "query", "language"],
|
||||
ssd: ["solid", "state", "drive"],
|
||||
ssh: ["secure", "shell"],
|
||||
ssl: ["secure", "sockets", "layer"],
|
||||
suv: ["sport", "utility", "vehicle"],
|
||||
svg: ["scalable", "vector", "graphics"],
|
||||
tba: ["to", "be", "announced"],
|
||||
tbd: ["to", "be", "determined"],
|
||||
tcp: ["transmission", "control", "protocol"],
|
||||
tdd: ["test", "driven", "development"],
|
||||
tldr: ["too", "long", "didn't", "read"],
|
||||
tls: ["transport", "layer", "security"],
|
||||
tv: ["television"],
|
||||
uat: ["user", "acceptance", "testing"],
|
||||
udp: ["user", "datagram", "protocol"],
|
||||
// User interface / experience
|
||||
ui: ["user", "interface"],
|
||||
uk: ["united", "kingdom"],
|
||||
un: ["united", "nations"],
|
||||
uri: ["uniform", "resource", "identifier"],
|
||||
// Tech / web
|
||||
url: ["uniform", "resource", "locator"],
|
||||
us: ["united", "states"],
|
||||
usa: ["united", "states", "of", "america"],
|
||||
// Hardware
|
||||
usb: ["universal", "serial", "bus"],
|
||||
uv: ["ultraviolet"],
|
||||
ux: ["user", "experience"],
|
||||
vp: ["vice", "president"],
|
||||
vpn: ["virtual", "private", "network"],
|
||||
wan: ["wide", "area", "network"],
|
||||
xml: ["extensible", "markup", "language"],
|
||||
xss: ["cross", "site", "scripting"]
|
||||
};
|
||||
var MAX_INITIALISM_LENGTH = 5;
|
||||
var LETTER_PHONEMES = {
|
||||
a: ["EY1"],
|
||||
b: ["B", "IY1"],
|
||||
c: ["S", "IY1"],
|
||||
d: ["D", "IY1"],
|
||||
e: ["IY1"],
|
||||
f: ["EH1", "F"],
|
||||
g: ["JH", "IY1"],
|
||||
h: ["EY1", "CH"],
|
||||
i: ["AY1"],
|
||||
j: ["JH", "EY1"],
|
||||
k: ["K", "EY1"],
|
||||
l: ["EH1", "L"],
|
||||
m: ["EH1", "M"],
|
||||
n: ["EH1", "N"],
|
||||
o: ["OW1"],
|
||||
p: ["P", "IY1"],
|
||||
q: ["K", "Y", "UW1"],
|
||||
r: ["AA1", "R"],
|
||||
s: ["EH1", "S"],
|
||||
t: ["T", "IY1"],
|
||||
u: ["Y", "UW1"],
|
||||
v: ["V", "IY1"],
|
||||
w: ["D", "AH1", "B", "AH0", "L", "Y", "UW0"],
|
||||
x: ["EH1", "K", "S"],
|
||||
y: ["W", "AY1"],
|
||||
z: ["Z", "IY1"]
|
||||
};
|
||||
var KNOWN_INITIALISMS = new Set(Object.keys(INITIALISM_EXPANSIONS));
|
||||
function isInitialism(word) {
|
||||
if (word.length > MAX_INITIALISM_LENGTH) {
|
||||
return false;
|
||||
}
|
||||
return KNOWN_INITIALISMS.has(word.toLowerCase());
|
||||
}
|
||||
var INITIALISM_SUFFIXES = ["'s", "s"];
|
||||
function parseInitialismWithSuffix(word) {
|
||||
for (const suffix of INITIALISM_SUFFIXES) {
|
||||
if (word.length > suffix.length && word.endsWith(suffix)) {
|
||||
const base = word.slice(0, -suffix.length);
|
||||
if (isInitialism(base)) {
|
||||
return { base, suffix };
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
function translateAsAcronym(word, format = "ingglish") {
|
||||
const arpabet = [];
|
||||
for (const char of word.toLowerCase()) {
|
||||
const letterArpabet = LETTER_PHONEMES[char];
|
||||
if (letterArpabet !== void 0) {
|
||||
arpabet.push(...letterArpabet);
|
||||
}
|
||||
}
|
||||
return (0, import_phonemes.arpabetToFormat)(arpabet, format);
|
||||
}
|
||||
|
||||
// src/british.ts
|
||||
var import_dictionary = require("@ingglish/dictionary");
|
||||
var import_phonemes2 = require("@ingglish/phonemes");
|
||||
var BRITISH_TO_AMERICAN = [
|
||||
// -isation → -ization (must come before -ise)
|
||||
{ pattern: /isation$/, replacement: "ization" },
|
||||
// -ise → -ize (realise→realize, organise→organize)
|
||||
{ pattern: /ise$/, replacement: "ize" },
|
||||
// -our → -or (colour→color, favour→favor)
|
||||
{ pattern: /our$/, replacement: "or" },
|
||||
// -oured → -ored (coloured→colored, favoured→favored)
|
||||
{ pattern: /oured$/, replacement: "ored" },
|
||||
// -ouring → -oring (colouring→coloring)
|
||||
{ pattern: /ouring$/, replacement: "oring" },
|
||||
// -ourable → -orable (favourable→favorable)
|
||||
{ pattern: /ourable$/, replacement: "orable" },
|
||||
// -re → -er (centre→center, theatre→theater)
|
||||
// Only after consonants to avoid matching normal -re words
|
||||
{ pattern: /([a-z])re$/, replacement: "$1er" },
|
||||
// -lled → -led (travelled→traveled, cancelled→canceled)
|
||||
{ pattern: /lled$/, replacement: "led" },
|
||||
// -lling → -ling (travelling→traveling, cancelling→canceling)
|
||||
{ pattern: /lling$/, replacement: "ling" },
|
||||
// -ller → -ler (traveller→traveler)
|
||||
{ pattern: /ller$/, replacement: "ler" },
|
||||
// -ence → -ense (defence→defense, offence→offense)
|
||||
{ pattern: /ence$/, replacement: "ense" },
|
||||
// -ogue → -og (catalogue→catalog, dialogue→dialog)
|
||||
{ pattern: /ogue$/, replacement: "og" },
|
||||
// -ae- → -e- (anaesthetic→anesthetic, paediatric→pediatric)
|
||||
{ pattern: /ae/, replacement: "e" },
|
||||
// -oe- → -e- (foetus→fetus, oestrogen→estrogen)
|
||||
{ pattern: /oe/, replacement: "e" },
|
||||
// -ey → -y (curtsey→curtsy)
|
||||
{ pattern: /ey$/, replacement: "y" },
|
||||
// grey → gray
|
||||
{ pattern: /grey/, replacement: "gray" }
|
||||
];
|
||||
function matchBritish(word) {
|
||||
const lower = word.toLowerCase();
|
||||
for (const { pattern, replacement } of BRITISH_TO_AMERICAN) {
|
||||
if (pattern.test(lower)) {
|
||||
const american = lower.replace(pattern, replacement);
|
||||
if (american !== lower) {
|
||||
const phonemes = (0, import_dictionary.lookupPronunciation)(american);
|
||||
if (phonemes) {
|
||||
return { american, phonemes };
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
function translateAsBritish(word, format = "ingglish") {
|
||||
const match = matchBritish(word);
|
||||
if (match === null) {
|
||||
return null;
|
||||
}
|
||||
return (0, import_phonemes2.arpabetToFormat)(match.phonemes, format);
|
||||
}
|
||||
|
||||
// src/compounds.ts
|
||||
var import_dictionary2 = require("@ingglish/dictionary");
|
||||
var import_phonemes3 = require("@ingglish/phonemes");
|
||||
function capitalize(str) {
|
||||
if (str.length === 0) {
|
||||
return str;
|
||||
}
|
||||
return str.charAt(0).toUpperCase() + str.slice(1);
|
||||
}
|
||||
function isUpperCase(char) {
|
||||
return char === char.toUpperCase() && char !== char.toLowerCase();
|
||||
}
|
||||
var MIN_PART_LENGTH = 3;
|
||||
var MIN_PART_FREQUENCY = 500;
|
||||
var MAX_PART_LENGTH = 15;
|
||||
function dpDecompose(word) {
|
||||
const n = word.length;
|
||||
const dp = Array.from({
|
||||
length: n + 1
|
||||
});
|
||||
dp[0] = { parts: [], score: 0 };
|
||||
for (let i = MIN_PART_LENGTH; i <= n; i++) {
|
||||
for (let j = Math.max(0, i - MAX_PART_LENGTH); j <= i - MIN_PART_LENGTH; j++) {
|
||||
if (j === 0 && i === n) {
|
||||
continue;
|
||||
}
|
||||
const prev = dp[j];
|
||||
if (prev === void 0) {
|
||||
continue;
|
||||
}
|
||||
const chunk = word.slice(j, i);
|
||||
const phonemes = lookupWord(chunk);
|
||||
if (!phonemes) {
|
||||
continue;
|
||||
}
|
||||
const freq = (0, import_dictionary2.getWordFrequency)(chunk);
|
||||
if (freq === void 0 || freq < MIN_PART_FREQUENCY) {
|
||||
continue;
|
||||
}
|
||||
const newScore = prev.score + freq;
|
||||
const newParts = prev.parts.length + 1;
|
||||
const current = dp[i];
|
||||
if (current === void 0 || newParts < current.parts.length || newParts === current.parts.length && newScore > current.score) {
|
||||
dp[i] = { parts: [...prev.parts, chunk], score: newScore };
|
||||
}
|
||||
}
|
||||
}
|
||||
const result = dp[n];
|
||||
if (result === void 0 || result.parts.length < 2) {
|
||||
return null;
|
||||
}
|
||||
return result.parts;
|
||||
}
|
||||
function translateAsCompound(word, format = "ingglish") {
|
||||
const lowerWord = word.toLowerCase();
|
||||
if (lowerWord.length < 6) {
|
||||
return null;
|
||||
}
|
||||
const parts = dpDecompose(lowerWord);
|
||||
if (!parts) {
|
||||
return null;
|
||||
}
|
||||
const translations = [];
|
||||
let pos = 0;
|
||||
for (const part of parts) {
|
||||
const phonemes = lookupWord(part);
|
||||
if (!phonemes) {
|
||||
return null;
|
||||
}
|
||||
let translated = (0, import_phonemes3.arpabetToFormat)(phonemes, format);
|
||||
if ((0, import_phonemes3.getFormatPreservesCase)(format)) {
|
||||
const originalPart = word.slice(pos, pos + part.length);
|
||||
if (originalPart.length > 0 && isUpperCase(originalPart[0])) {
|
||||
translated = capitalize(translated);
|
||||
}
|
||||
}
|
||||
translations.push(translated);
|
||||
pos += part.length;
|
||||
}
|
||||
return translations.join((0, import_phonemes3.getFormatJoinSeparator)(format));
|
||||
}
|
||||
function lookupWord(word) {
|
||||
return (0, import_dictionary2.lookupPronunciation)(word);
|
||||
}
|
||||
|
||||
// src/stemming.ts
|
||||
var import_dictionary3 = require("@ingglish/dictionary");
|
||||
var import_phonemes4 = require("@ingglish/phonemes");
|
||||
var VOICELESS = /* @__PURE__ */ new Set(["CH", "F", "HH", "K", "P", "S", "SH", "T", "TH"]);
|
||||
var SIBILANTS = /* @__PURE__ */ new Set(["CH", "JH", "S", "SH", "Z", "ZH"]);
|
||||
function selectEdPhonemes(lastPhoneme) {
|
||||
const base = (0, import_phonemes4.stripStress)(lastPhoneme);
|
||||
if (base === "T" || base === "D") {
|
||||
return ["IH0", "D"];
|
||||
}
|
||||
if (VOICELESS.has(base)) {
|
||||
return ["T"];
|
||||
}
|
||||
return ["D"];
|
||||
}
|
||||
function selectSPhonemes(lastPhoneme) {
|
||||
const base = (0, import_phonemes4.stripStress)(lastPhoneme);
|
||||
if (SIBILANTS.has(base)) {
|
||||
return ["IH0", "Z"];
|
||||
}
|
||||
if (VOICELESS.has(base)) {
|
||||
return ["S"];
|
||||
}
|
||||
return ["Z"];
|
||||
}
|
||||
var INFLECTIONAL_SUFFIXES = /* @__PURE__ */ new Set([
|
||||
"ed",
|
||||
"er",
|
||||
"es",
|
||||
"est",
|
||||
"ification",
|
||||
"ify",
|
||||
"ifying",
|
||||
"ing",
|
||||
"or",
|
||||
"s"
|
||||
]);
|
||||
var SUFFIX_PHONEMES = [
|
||||
// Long suffixes first (must come before shorter matches: -ification before -tion, -ifying before -ing)
|
||||
{ phonemes: ["IH0", "F", "IH0", "K", "EY1", "SH", "AH0", "N"], suffix: "ification" },
|
||||
{ phonemes: ["IH0", "F", "AY1", "IH0", "NG"], suffix: "ifying" },
|
||||
{ phonemes: ["IH0", "F", "AY1"], suffix: "ify" },
|
||||
// Verb suffixes
|
||||
{ phonemes: ["IH0", "NG"], suffix: "ing" },
|
||||
{ phonemes: null, suffix: "ed" },
|
||||
// allomorph: T/D/IH0 D (selected dynamically)
|
||||
{ phonemes: null, suffix: "es" },
|
||||
// allomorph: same as -s (S/Z/IH0 Z based on stem)
|
||||
{ phonemes: null, suffix: "s" },
|
||||
// allomorph: S/Z/IH0 Z (selected dynamically)
|
||||
// Noun suffixes
|
||||
{ phonemes: ["SH", "AH0", "N"], suffix: "tion" },
|
||||
{ phonemes: ["ZH", "AH0", "N"], suffix: "sion" },
|
||||
{ phonemes: ["N", "AH0", "S"], suffix: "ness" },
|
||||
{ phonemes: ["M", "AH0", "N", "T"], suffix: "ment" },
|
||||
{ phonemes: ["IH0", "T", "IY0"], suffix: "ity" },
|
||||
{ phonemes: ["ER0"], suffix: "er" },
|
||||
{ phonemes: ["ER0"], suffix: "or" },
|
||||
{ phonemes: ["IH0", "S", "T"], suffix: "ist" },
|
||||
{ phonemes: ["IH0", "Z", "AH0", "M"], suffix: "ism" },
|
||||
// Adjective suffixes
|
||||
{ phonemes: ["L", "IY0"], suffix: "ly" },
|
||||
{ phonemes: ["F", "AH0", "L"], suffix: "ful" },
|
||||
{ phonemes: ["L", "AH0", "S"], suffix: "less" },
|
||||
{ phonemes: ["AH0", "B", "AH0", "L"], suffix: "able" },
|
||||
{ phonemes: ["AH0", "B", "AH0", "L"], suffix: "ible" },
|
||||
{ phonemes: ["AH0", "S"], suffix: "ous" },
|
||||
{ phonemes: ["IH0", "V"], suffix: "ive" },
|
||||
{ phonemes: ["AH0", "L"], suffix: "al" },
|
||||
{ phonemes: ["IH0", "K"], suffix: "ic" },
|
||||
// Comparative/superlative
|
||||
{ phonemes: ["AH0", "S", "T"], suffix: "est" },
|
||||
// Additional suffixes
|
||||
{ phonemes: ["AH0", "L", "IY0"], suffix: "ally" },
|
||||
{ phonemes: ["AA1", "L", "AH0", "JH", "IY0"], suffix: "ology" },
|
||||
{ phonemes: ["AY1", "Z"], suffix: "ize" },
|
||||
{ phonemes: ["AY1", "Z"], suffix: "ise" }
|
||||
];
|
||||
var PREFIX_PHONEMES = [
|
||||
{ phonemes: ["AH0", "N"], prefix: "un" },
|
||||
{ phonemes: ["R", "IY0"], prefix: "re" },
|
||||
{ phonemes: ["P", "R", "IY0"], prefix: "pre" },
|
||||
{ phonemes: ["D", "IH0", "S"], prefix: "dis" },
|
||||
{ phonemes: ["M", "IH0", "S"], prefix: "mis" },
|
||||
{ phonemes: ["OW1", "V", "ER0"], prefix: "over" },
|
||||
{ phonemes: ["AH1", "N", "D", "ER0"], prefix: "under" },
|
||||
{ phonemes: ["AW1", "T"], prefix: "out" },
|
||||
{ phonemes: ["AE1", "N", "T", "IY0"], prefix: "anti" },
|
||||
{ phonemes: ["S", "UW1", "P", "ER0"], prefix: "super" }
|
||||
];
|
||||
function matchStemming(word) {
|
||||
const lowerWord = word.toLowerCase();
|
||||
for (const { phonemes: suffixArpabet, suffix } of SUFFIX_PHONEMES) {
|
||||
if (lowerWord.endsWith(suffix) && lowerWord.length > suffix.length + 2) {
|
||||
const stem = lowerWord.slice(0, -suffix.length);
|
||||
for (const variant of getStemVariants(stem, suffix)) {
|
||||
const baseArpabet = (0, import_dictionary3.lookupPronunciation)(variant);
|
||||
if (baseArpabet) {
|
||||
const resolvedSuffix = resolveSuffixPhonemes(suffix, suffixArpabet, baseArpabet);
|
||||
return {
|
||||
phonemes: [...baseArpabet, ...resolvedSuffix],
|
||||
stem: variant,
|
||||
suffix
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (const { phonemes: prefixArpabet, prefix } of PREFIX_PHONEMES) {
|
||||
if (lowerWord.startsWith(prefix) && lowerWord.length > prefix.length + 2) {
|
||||
const stem = lowerWord.slice(prefix.length);
|
||||
const baseArpabet = (0, import_dictionary3.lookupPronunciation)(stem);
|
||||
if (baseArpabet) {
|
||||
return {
|
||||
phonemes: [...prefixArpabet, ...baseArpabet],
|
||||
prefix,
|
||||
stem
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
function translateWithStemming(word, format = "ingglish") {
|
||||
const match = matchStemming(word);
|
||||
if (match === null) {
|
||||
return null;
|
||||
}
|
||||
return (0, import_phonemes4.arpabetToFormat)(match.phonemes, format);
|
||||
}
|
||||
function getStemVariants(stem, suffix) {
|
||||
const variants = [stem];
|
||||
if (INFLECTIONAL_SUFFIXES.has(suffix)) {
|
||||
variants.push(
|
||||
stem + "e",
|
||||
// hoping -> hope
|
||||
stem.length > 1 ? stem.slice(0, -1) : stem,
|
||||
// running -> run (double consonant)
|
||||
stem.length > 0 ? stem + stem.at(-1) : stem
|
||||
// big -> bigg (for adding -er)
|
||||
);
|
||||
}
|
||||
if (stem.endsWith("i")) {
|
||||
variants.push(stem.slice(0, -1) + "y");
|
||||
}
|
||||
variants.push(stem + "y");
|
||||
return variants;
|
||||
}
|
||||
function resolveSuffixPhonemes(suffix, suffixArpabet, baseArpabet) {
|
||||
if (suffixArpabet !== null) {
|
||||
return suffixArpabet;
|
||||
}
|
||||
const lastPhoneme = baseArpabet.at(-1);
|
||||
if (suffix === "ed") {
|
||||
return selectEdPhonemes(lastPhoneme);
|
||||
}
|
||||
return selectSPhonemes(lastPhoneme);
|
||||
}
|
||||
|
||||
// src/index.ts
|
||||
function diagnoseUnknown(word) {
|
||||
if (/(.)\1\1/.test(word) || !/[aeiouy]/i.test(word)) {
|
||||
return null;
|
||||
}
|
||||
const { strategy } = translateUnknownCore(word, "ingglish");
|
||||
switch (strategy) {
|
||||
case "british": {
|
||||
const m = matchBritish(word);
|
||||
return { americanSpelling: m.american, phonemes: m.phonemes, strategy: "british" };
|
||||
}
|
||||
case "compound": {
|
||||
return { parts: dpDecompose(word.toLowerCase()), strategy: "compound" };
|
||||
}
|
||||
case "custom": {
|
||||
return { phonemes: (0, import_dictionary4.getCustomPronunciation)(word), strategy: "custom" };
|
||||
}
|
||||
case "g2p": {
|
||||
return { strategy: "g2p", trace: (0, import_g2p.wordToArpabetTraced)(word) };
|
||||
}
|
||||
case "initialism": {
|
||||
return { strategy: "initialism" };
|
||||
}
|
||||
case "stemming": {
|
||||
const m = matchStemming(word);
|
||||
return { prefix: m.prefix, stem: m.stem, strategy: "stemming", suffix: m.suffix };
|
||||
}
|
||||
}
|
||||
}
|
||||
function translateUnknown(word, format = "ingglish") {
|
||||
return translateUnknownCore(word, format).translated;
|
||||
}
|
||||
function translateUnknownCore(word, format) {
|
||||
const customPhonemes = (0, import_dictionary4.getCustomPronunciation)(word);
|
||||
if (customPhonemes !== void 0) {
|
||||
return { strategy: "custom", translated: (0, import_phonemes5.arpabetToFormat)(customPhonemes, format) };
|
||||
}
|
||||
if (isInitialism(word)) {
|
||||
return { strategy: "initialism", translated: translateAsAcronym(word, format) };
|
||||
}
|
||||
const britishResult = translateAsBritish(word, format);
|
||||
if (britishResult !== null && britishResult.length > 0) {
|
||||
return { strategy: "british", translated: britishResult };
|
||||
}
|
||||
const compoundResult = translateAsCompound(word, format);
|
||||
if (compoundResult !== null && compoundResult.length > 0) {
|
||||
return { strategy: "compound", translated: compoundResult };
|
||||
}
|
||||
const stemmedResult = translateWithStemming(word, format);
|
||||
if (stemmedResult !== null && stemmedResult.length > 0) {
|
||||
return { strategy: "stemming", translated: stemmedResult };
|
||||
}
|
||||
return { strategy: "g2p", translated: (0, import_g2p.wordToPhonetic)(word, format) };
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
KNOWN_INITIALISMS,
|
||||
LETTER_PHONEMES,
|
||||
diagnoseUnknown,
|
||||
isInitialism,
|
||||
matchBritish,
|
||||
parseInitialismWithSuffix,
|
||||
translateAsAcronym,
|
||||
translateUnknown
|
||||
});
|
||||
+119
@@ -0,0 +1,119 @@
|
||||
import { G2PTrace } from '@ingglish/g2p';
|
||||
import { OutputFormat } from '@ingglish/phonemes';
|
||||
|
||||
/**
|
||||
* Acronym and initialism handling.
|
||||
*
|
||||
* Handles words that should be spelled out letter-by-letter
|
||||
* (e.g., URL -> "you-are-ell") vs acronyms pronounced as words
|
||||
* (e.g., NASA -> "nasa").
|
||||
*/
|
||||
|
||||
/**
|
||||
* Phonemes for individual letters (for spelling out acronyms).
|
||||
* Based on how native English speakers pronounce alphabet letters.
|
||||
*/
|
||||
declare const LETTER_PHONEMES: Record<string, string[]>;
|
||||
/**
|
||||
* Known initialisms - derived from INITIALISM_EXPANSIONS for consistency.
|
||||
* These are pronounced as individual letters, NOT as words.
|
||||
*
|
||||
* Excludes acronyms pronounced as words like:
|
||||
* - RAM (ram), ROM (rom), GIF (gif/jif), JPEG (jay-peg)
|
||||
* - JSON (jason), SQL (sequel), NASA, NATO, SCUBA, LASER
|
||||
*/
|
||||
declare const KNOWN_INITIALISMS: Set<string>;
|
||||
/**
|
||||
* Checks if a word should be spelled out as individual letters (initialism).
|
||||
* Only returns true for known initialisms - unknown uppercase words are NOT
|
||||
* automatically treated as initialisms since they might be acronyms pronounced
|
||||
* as words (like NASA, GIF, etc).
|
||||
*/
|
||||
declare function isInitialism(word: string): boolean;
|
||||
/**
|
||||
* Checks if a word is an initialism with a suffix (e.g., "IDs", "TVs", "URLs", "API's").
|
||||
* Returns the base initialism and suffix if matched, null otherwise.
|
||||
*/
|
||||
declare function parseInitialismWithSuffix(word: string): null | {
|
||||
base: string;
|
||||
suffix: string;
|
||||
};
|
||||
/**
|
||||
* Translates a word by spelling out each letter.
|
||||
* Used for acronyms like URL, HTML, API.
|
||||
*/
|
||||
declare function translateAsAcronym(word: string, format?: OutputFormat): string;
|
||||
|
||||
/**
|
||||
* British-to-American spelling conversion.
|
||||
*
|
||||
* Converts common British English spellings to their American
|
||||
* equivalents and looks them up in the CMU dictionary.
|
||||
* Used as a fallback when the British spelling isn't found.
|
||||
*/
|
||||
|
||||
interface BritishMatch {
|
||||
american: string;
|
||||
phonemes: string[];
|
||||
}
|
||||
/**
|
||||
* Matches a word against British-to-American spelling rules.
|
||||
* Returns the American spelling and its phonemes, or null if no match.
|
||||
*/
|
||||
declare function matchBritish(word: string): BritishMatch | null;
|
||||
|
||||
/**
|
||||
* Fallback strategies for translating unknown words.
|
||||
*
|
||||
* Called when a word isn't in the dictionary. Each strategy ultimately
|
||||
* produces ARPAbet `string[]` (the pipeline IR), which is then passed
|
||||
* through `arpabetToFormat()` for final output.
|
||||
*
|
||||
* Strategy order:
|
||||
* 1. Custom pronunciations (tech terms, brand names)
|
||||
* 2. Initialisms (spell out letters: URL -> you-are-ell)
|
||||
* 3. British spelling normalization (colour -> color)
|
||||
* 4. Compound word splitting (github -> git + hub)
|
||||
* 5. Stemming (find known base word + known suffix)
|
||||
* 6. Rule-based grapheme-to-phoneme
|
||||
*/
|
||||
|
||||
type WordDiagnosis = {
|
||||
americanSpelling: string;
|
||||
phonemes: string[];
|
||||
strategy: 'british';
|
||||
} | {
|
||||
parts: string[];
|
||||
strategy: 'compound';
|
||||
} | {
|
||||
phonemes: string[];
|
||||
strategy: 'custom';
|
||||
} | {
|
||||
prefix?: string;
|
||||
stem: string;
|
||||
strategy: 'stemming';
|
||||
suffix?: string;
|
||||
} | {
|
||||
strategy: 'g2p';
|
||||
trace: G2PTrace;
|
||||
} | {
|
||||
strategy: 'initialism';
|
||||
};
|
||||
|
||||
/**
|
||||
* Diagnoses an unknown word by determining which fallback strategy handles it
|
||||
* and collecting diagnostic data for display.
|
||||
*
|
||||
* Returns null for obvious non-words (3+ repeated chars, no vowels).
|
||||
*/
|
||||
declare function diagnoseUnknown(word: string): null | WordDiagnosis;
|
||||
/**
|
||||
* Attempts all strategies to translate an unknown word.
|
||||
*
|
||||
* @param word The unknown word
|
||||
* @param format The output format
|
||||
* @returns The translated word
|
||||
*/
|
||||
declare function translateUnknown(word: string, format?: OutputFormat): string;
|
||||
|
||||
export { KNOWN_INITIALISMS, LETTER_PHONEMES, type WordDiagnosis, diagnoseUnknown, isInitialism, matchBritish, parseInitialismWithSuffix, translateAsAcronym, translateUnknown };
|
||||
+119
@@ -0,0 +1,119 @@
|
||||
import { G2PTrace } from '@ingglish/g2p';
|
||||
import { OutputFormat } from '@ingglish/phonemes';
|
||||
|
||||
/**
|
||||
* Acronym and initialism handling.
|
||||
*
|
||||
* Handles words that should be spelled out letter-by-letter
|
||||
* (e.g., URL -> "you-are-ell") vs acronyms pronounced as words
|
||||
* (e.g., NASA -> "nasa").
|
||||
*/
|
||||
|
||||
/**
|
||||
* Phonemes for individual letters (for spelling out acronyms).
|
||||
* Based on how native English speakers pronounce alphabet letters.
|
||||
*/
|
||||
declare const LETTER_PHONEMES: Record<string, string[]>;
|
||||
/**
|
||||
* Known initialisms - derived from INITIALISM_EXPANSIONS for consistency.
|
||||
* These are pronounced as individual letters, NOT as words.
|
||||
*
|
||||
* Excludes acronyms pronounced as words like:
|
||||
* - RAM (ram), ROM (rom), GIF (gif/jif), JPEG (jay-peg)
|
||||
* - JSON (jason), SQL (sequel), NASA, NATO, SCUBA, LASER
|
||||
*/
|
||||
declare const KNOWN_INITIALISMS: Set<string>;
|
||||
/**
|
||||
* Checks if a word should be spelled out as individual letters (initialism).
|
||||
* Only returns true for known initialisms - unknown uppercase words are NOT
|
||||
* automatically treated as initialisms since they might be acronyms pronounced
|
||||
* as words (like NASA, GIF, etc).
|
||||
*/
|
||||
declare function isInitialism(word: string): boolean;
|
||||
/**
|
||||
* Checks if a word is an initialism with a suffix (e.g., "IDs", "TVs", "URLs", "API's").
|
||||
* Returns the base initialism and suffix if matched, null otherwise.
|
||||
*/
|
||||
declare function parseInitialismWithSuffix(word: string): null | {
|
||||
base: string;
|
||||
suffix: string;
|
||||
};
|
||||
/**
|
||||
* Translates a word by spelling out each letter.
|
||||
* Used for acronyms like URL, HTML, API.
|
||||
*/
|
||||
declare function translateAsAcronym(word: string, format?: OutputFormat): string;
|
||||
|
||||
/**
|
||||
* British-to-American spelling conversion.
|
||||
*
|
||||
* Converts common British English spellings to their American
|
||||
* equivalents and looks them up in the CMU dictionary.
|
||||
* Used as a fallback when the British spelling isn't found.
|
||||
*/
|
||||
|
||||
interface BritishMatch {
|
||||
american: string;
|
||||
phonemes: string[];
|
||||
}
|
||||
/**
|
||||
* Matches a word against British-to-American spelling rules.
|
||||
* Returns the American spelling and its phonemes, or null if no match.
|
||||
*/
|
||||
declare function matchBritish(word: string): BritishMatch | null;
|
||||
|
||||
/**
|
||||
* Fallback strategies for translating unknown words.
|
||||
*
|
||||
* Called when a word isn't in the dictionary. Each strategy ultimately
|
||||
* produces ARPAbet `string[]` (the pipeline IR), which is then passed
|
||||
* through `arpabetToFormat()` for final output.
|
||||
*
|
||||
* Strategy order:
|
||||
* 1. Custom pronunciations (tech terms, brand names)
|
||||
* 2. Initialisms (spell out letters: URL -> you-are-ell)
|
||||
* 3. British spelling normalization (colour -> color)
|
||||
* 4. Compound word splitting (github -> git + hub)
|
||||
* 5. Stemming (find known base word + known suffix)
|
||||
* 6. Rule-based grapheme-to-phoneme
|
||||
*/
|
||||
|
||||
type WordDiagnosis = {
|
||||
americanSpelling: string;
|
||||
phonemes: string[];
|
||||
strategy: 'british';
|
||||
} | {
|
||||
parts: string[];
|
||||
strategy: 'compound';
|
||||
} | {
|
||||
phonemes: string[];
|
||||
strategy: 'custom';
|
||||
} | {
|
||||
prefix?: string;
|
||||
stem: string;
|
||||
strategy: 'stemming';
|
||||
suffix?: string;
|
||||
} | {
|
||||
strategy: 'g2p';
|
||||
trace: G2PTrace;
|
||||
} | {
|
||||
strategy: 'initialism';
|
||||
};
|
||||
|
||||
/**
|
||||
* Diagnoses an unknown word by determining which fallback strategy handles it
|
||||
* and collecting diagnostic data for display.
|
||||
*
|
||||
* Returns null for obvious non-words (3+ repeated chars, no vowels).
|
||||
*/
|
||||
declare function diagnoseUnknown(word: string): null | WordDiagnosis;
|
||||
/**
|
||||
* Attempts all strategies to translate an unknown word.
|
||||
*
|
||||
* @param word The unknown word
|
||||
* @param format The output format
|
||||
* @returns The translated word
|
||||
*/
|
||||
declare function translateUnknown(word: string, format?: OutputFormat): string;
|
||||
|
||||
export { KNOWN_INITIALISMS, LETTER_PHONEMES, type WordDiagnosis, diagnoseUnknown, isInitialism, matchBritish, parseInitialismWithSuffix, translateAsAcronym, translateUnknown };
|
||||
+626
@@ -0,0 +1,626 @@
|
||||
// src/index.ts
|
||||
import { getCustomPronunciation } from "@ingglish/dictionary";
|
||||
import { wordToArpabetTraced, wordToPhonetic } from "@ingglish/g2p";
|
||||
import { arpabetToFormat as arpabetToFormat5 } from "@ingglish/phonemes";
|
||||
|
||||
// src/acronyms.ts
|
||||
import { arpabetToFormat } from "@ingglish/phonemes";
|
||||
var INITIALISM_EXPANSIONS = {
|
||||
ac: ["alternating", "current"],
|
||||
ad: ["anno", "domini"],
|
||||
afk: ["away", "from", "keyboard"],
|
||||
// AI / ML
|
||||
ai: ["artificial", "intelligence"],
|
||||
aka: ["also", "known", "as"],
|
||||
am: ["ante", "meridiem"],
|
||||
api: ["application", "programming", "interface"],
|
||||
asap: ["as", "soon", "as", "possible"],
|
||||
atm: ["automated", "teller", "machine"],
|
||||
aws: ["amazon", "web", "services"],
|
||||
b2b: ["business", "to", "business"],
|
||||
b2c: ["business", "to", "consumer"],
|
||||
bc: ["before", "christ"],
|
||||
bdd: ["behavior", "driven", "development"],
|
||||
brb: ["be", "right", "back"],
|
||||
btw: ["by", "the", "way"],
|
||||
byob: ["bring", "your", "own", "bottle"],
|
||||
cd: ["continuous", "deployment"],
|
||||
cdn: ["content", "delivery", "network"],
|
||||
// Business / titles
|
||||
ceo: ["chief", "executive", "officer"],
|
||||
cfo: ["chief", "financial", "officer"],
|
||||
ci: ["continuous", "integration"],
|
||||
cia: ["central", "intelligence", "agency"],
|
||||
cio: ["chief", "information", "officer"],
|
||||
cli: ["command", "line", "interface"],
|
||||
cmo: ["chief", "marketing", "officer"],
|
||||
cms: ["content", "management", "system"],
|
||||
cnn: ["convolutional", "neural", "network"],
|
||||
coo: ["chief", "operating", "officer"],
|
||||
cors: ["cross", "origin", "resource", "sharing"],
|
||||
cpr: ["cardiopulmonary", "resuscitation"],
|
||||
cpu: ["central", "processing", "unit"],
|
||||
crm: ["customer", "relationship", "management"],
|
||||
crud: ["create", "read", "update", "delete"],
|
||||
cso: ["chief", "security", "officer"],
|
||||
css: ["cascading", "style", "sheets"],
|
||||
csv: ["comma", "separated", "values"],
|
||||
cto: ["chief", "technology", "officer"],
|
||||
dc: ["direct", "current"],
|
||||
ddos: ["distributed", "denial", "of", "service"],
|
||||
dea: ["drug", "enforcement", "administration"],
|
||||
diy: ["do", "it", "yourself"],
|
||||
dj: ["disc", "jockey"],
|
||||
dmv: ["department", "of", "motor", "vehicles"],
|
||||
// Medical / science
|
||||
dna: ["deoxyribonucleic", "acid"],
|
||||
dns: ["domain", "name", "system"],
|
||||
eod: ["end", "of", "day"],
|
||||
epa: ["environmental", "protection", "agency"],
|
||||
er: ["emergency", "room"],
|
||||
erp: ["enterprise", "resource", "planning"],
|
||||
eta: ["estimated", "time", "of", "arrival"],
|
||||
etl: ["extract", "transform", "load"],
|
||||
eu: ["european", "union"],
|
||||
faq: ["frequently", "asked", "questions"],
|
||||
// Government / organizations
|
||||
fbi: ["federal", "bureau", "of", "investigation"],
|
||||
fda: ["food", "and", "drug", "administration"],
|
||||
ftp: ["file", "transfer", "protocol"],
|
||||
fyi: ["for", "your", "information"],
|
||||
gan: ["generative", "adversarial", "network"],
|
||||
gcp: ["google", "cloud", "platform"],
|
||||
gif: ["graphics", "interchange", "format"],
|
||||
gps: ["global", "positioning", "system"],
|
||||
gpt: ["generative", "pre-trained", "transformer"],
|
||||
gpu: ["graphics", "processing", "unit"],
|
||||
gui: ["graphical", "user", "interface"],
|
||||
hdd: ["hard", "disk", "drive"],
|
||||
hiv: ["human", "immunodeficiency", "virus"],
|
||||
hr: ["human", "resources"],
|
||||
html: ["hypertext", "markup", "language"],
|
||||
http: ["hypertext", "transfer", "protocol"],
|
||||
https: ["hypertext", "transfer", "protocol", "secure"],
|
||||
iaas: ["infrastructure", "as", "a", "service"],
|
||||
icu: ["intensive", "care", "unit"],
|
||||
// General / common
|
||||
id: ["identification"],
|
||||
ide: ["integrated", "development", "environment"],
|
||||
idk: ["i", "don't", "know"],
|
||||
imo: ["in", "my", "opinion"],
|
||||
io: ["input", "output"],
|
||||
ip: ["internet", "protocol"],
|
||||
iq: ["intelligence", "quotient"],
|
||||
irs: ["internal", "revenue", "service"],
|
||||
isp: ["internet", "service", "provider"],
|
||||
it: ["information", "technology"],
|
||||
jpeg: ["joint", "photographic", "experts", "group"],
|
||||
// Media
|
||||
jpg: ["joint", "photographic", "experts", "group"],
|
||||
json: ["javascript", "object", "notation"],
|
||||
jwt: ["json", "web", "token"],
|
||||
kpi: ["key", "performance", "indicator"],
|
||||
// Networking
|
||||
lan: ["local", "area", "network"],
|
||||
lcd: ["liquid", "crystal", "display"],
|
||||
led: ["light", "emitting", "diode"],
|
||||
llm: ["large", "language", "model"],
|
||||
mc: ["master", "of", "ceremonies"],
|
||||
// Security
|
||||
mfa: ["multi", "factor", "authentication"],
|
||||
ml: ["machine", "learning"],
|
||||
mp3: ["moving", "picture", "experts", "group", "audio", "layer"],
|
||||
mp4: ["moving", "picture", "experts", "group"],
|
||||
mph: ["miles", "per", "hour"],
|
||||
mri: ["magnetic", "resonance", "imaging"],
|
||||
mvp: ["minimum", "viable", "product"],
|
||||
nasa: ["national", "aeronautics", "space", "administration"],
|
||||
// Acronyms pronounced as words (pass through unchanged like initialisms)
|
||||
nato: ["north", "atlantic", "treaty", "organization"],
|
||||
nda: ["non", "disclosure", "agreement"],
|
||||
nic: ["network", "interface", "card"],
|
||||
nlp: ["natural", "language", "processing"],
|
||||
nosql: ["not", "only", "sql"],
|
||||
nsa: ["national", "security", "agency"],
|
||||
nsfw: ["not", "safe", "for", "work"],
|
||||
nyc: ["new", "york", "city"],
|
||||
omg: ["oh", "my", "god"],
|
||||
ooo: ["out", "of", "office"],
|
||||
// Development
|
||||
oop: ["object", "oriented", "programming"],
|
||||
orm: ["object", "relational", "mapping"],
|
||||
os: ["operating", "system"],
|
||||
otp: ["one", "time", "password"],
|
||||
paas: ["platform", "as", "a", "service"],
|
||||
pc: ["personal", "computer"],
|
||||
pdf: ["portable", "document", "format"],
|
||||
php: ["hypertext", "preprocessor"],
|
||||
pm: ["post", "meridiem"],
|
||||
png: ["portable", "network", "graphics"],
|
||||
pov: ["point", "of", "view"],
|
||||
pr: ["public", "relations"],
|
||||
pto: ["paid", "time", "off"],
|
||||
qa: ["quality", "assurance"],
|
||||
rag: ["retrieval", "augmented", "generation"],
|
||||
ram: ["random", "access", "memory"],
|
||||
rfp: ["request", "for", "proposal"],
|
||||
rip: ["rest", "in", "peace"],
|
||||
rna: ["ribonucleic", "acid"],
|
||||
rnn: ["recurrent", "neural", "network"],
|
||||
roi: ["return", "on", "investment"],
|
||||
rom: ["read", "only", "memory"],
|
||||
rpm: ["revolutions", "per", "minute"],
|
||||
rsvp: ["please", "respond"],
|
||||
rv: ["recreational", "vehicle"],
|
||||
// Cloud / services
|
||||
saas: ["software", "as", "a", "service"],
|
||||
sdk: ["software", "development", "kit"],
|
||||
sftp: ["secure", "file", "transfer", "protocol"],
|
||||
sla: ["service", "level", "agreement"],
|
||||
// Database
|
||||
sql: ["structured", "query", "language"],
|
||||
ssd: ["solid", "state", "drive"],
|
||||
ssh: ["secure", "shell"],
|
||||
ssl: ["secure", "sockets", "layer"],
|
||||
suv: ["sport", "utility", "vehicle"],
|
||||
svg: ["scalable", "vector", "graphics"],
|
||||
tba: ["to", "be", "announced"],
|
||||
tbd: ["to", "be", "determined"],
|
||||
tcp: ["transmission", "control", "protocol"],
|
||||
tdd: ["test", "driven", "development"],
|
||||
tldr: ["too", "long", "didn't", "read"],
|
||||
tls: ["transport", "layer", "security"],
|
||||
tv: ["television"],
|
||||
uat: ["user", "acceptance", "testing"],
|
||||
udp: ["user", "datagram", "protocol"],
|
||||
// User interface / experience
|
||||
ui: ["user", "interface"],
|
||||
uk: ["united", "kingdom"],
|
||||
un: ["united", "nations"],
|
||||
uri: ["uniform", "resource", "identifier"],
|
||||
// Tech / web
|
||||
url: ["uniform", "resource", "locator"],
|
||||
us: ["united", "states"],
|
||||
usa: ["united", "states", "of", "america"],
|
||||
// Hardware
|
||||
usb: ["universal", "serial", "bus"],
|
||||
uv: ["ultraviolet"],
|
||||
ux: ["user", "experience"],
|
||||
vp: ["vice", "president"],
|
||||
vpn: ["virtual", "private", "network"],
|
||||
wan: ["wide", "area", "network"],
|
||||
xml: ["extensible", "markup", "language"],
|
||||
xss: ["cross", "site", "scripting"]
|
||||
};
|
||||
var MAX_INITIALISM_LENGTH = 5;
|
||||
var LETTER_PHONEMES = {
|
||||
a: ["EY1"],
|
||||
b: ["B", "IY1"],
|
||||
c: ["S", "IY1"],
|
||||
d: ["D", "IY1"],
|
||||
e: ["IY1"],
|
||||
f: ["EH1", "F"],
|
||||
g: ["JH", "IY1"],
|
||||
h: ["EY1", "CH"],
|
||||
i: ["AY1"],
|
||||
j: ["JH", "EY1"],
|
||||
k: ["K", "EY1"],
|
||||
l: ["EH1", "L"],
|
||||
m: ["EH1", "M"],
|
||||
n: ["EH1", "N"],
|
||||
o: ["OW1"],
|
||||
p: ["P", "IY1"],
|
||||
q: ["K", "Y", "UW1"],
|
||||
r: ["AA1", "R"],
|
||||
s: ["EH1", "S"],
|
||||
t: ["T", "IY1"],
|
||||
u: ["Y", "UW1"],
|
||||
v: ["V", "IY1"],
|
||||
w: ["D", "AH1", "B", "AH0", "L", "Y", "UW0"],
|
||||
x: ["EH1", "K", "S"],
|
||||
y: ["W", "AY1"],
|
||||
z: ["Z", "IY1"]
|
||||
};
|
||||
var KNOWN_INITIALISMS = new Set(Object.keys(INITIALISM_EXPANSIONS));
|
||||
function isInitialism(word) {
|
||||
if (word.length > MAX_INITIALISM_LENGTH) {
|
||||
return false;
|
||||
}
|
||||
return KNOWN_INITIALISMS.has(word.toLowerCase());
|
||||
}
|
||||
var INITIALISM_SUFFIXES = ["'s", "s"];
|
||||
function parseInitialismWithSuffix(word) {
|
||||
for (const suffix of INITIALISM_SUFFIXES) {
|
||||
if (word.length > suffix.length && word.endsWith(suffix)) {
|
||||
const base = word.slice(0, -suffix.length);
|
||||
if (isInitialism(base)) {
|
||||
return { base, suffix };
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
function translateAsAcronym(word, format = "ingglish") {
|
||||
const arpabet = [];
|
||||
for (const char of word.toLowerCase()) {
|
||||
const letterArpabet = LETTER_PHONEMES[char];
|
||||
if (letterArpabet !== void 0) {
|
||||
arpabet.push(...letterArpabet);
|
||||
}
|
||||
}
|
||||
return arpabetToFormat(arpabet, format);
|
||||
}
|
||||
|
||||
// src/british.ts
|
||||
import { lookupPronunciation } from "@ingglish/dictionary";
|
||||
import { arpabetToFormat as arpabetToFormat2 } from "@ingglish/phonemes";
|
||||
var BRITISH_TO_AMERICAN = [
|
||||
// -isation → -ization (must come before -ise)
|
||||
{ pattern: /isation$/, replacement: "ization" },
|
||||
// -ise → -ize (realise→realize, organise→organize)
|
||||
{ pattern: /ise$/, replacement: "ize" },
|
||||
// -our → -or (colour→color, favour→favor)
|
||||
{ pattern: /our$/, replacement: "or" },
|
||||
// -oured → -ored (coloured→colored, favoured→favored)
|
||||
{ pattern: /oured$/, replacement: "ored" },
|
||||
// -ouring → -oring (colouring→coloring)
|
||||
{ pattern: /ouring$/, replacement: "oring" },
|
||||
// -ourable → -orable (favourable→favorable)
|
||||
{ pattern: /ourable$/, replacement: "orable" },
|
||||
// -re → -er (centre→center, theatre→theater)
|
||||
// Only after consonants to avoid matching normal -re words
|
||||
{ pattern: /([a-z])re$/, replacement: "$1er" },
|
||||
// -lled → -led (travelled→traveled, cancelled→canceled)
|
||||
{ pattern: /lled$/, replacement: "led" },
|
||||
// -lling → -ling (travelling→traveling, cancelling→canceling)
|
||||
{ pattern: /lling$/, replacement: "ling" },
|
||||
// -ller → -ler (traveller→traveler)
|
||||
{ pattern: /ller$/, replacement: "ler" },
|
||||
// -ence → -ense (defence→defense, offence→offense)
|
||||
{ pattern: /ence$/, replacement: "ense" },
|
||||
// -ogue → -og (catalogue→catalog, dialogue→dialog)
|
||||
{ pattern: /ogue$/, replacement: "og" },
|
||||
// -ae- → -e- (anaesthetic→anesthetic, paediatric→pediatric)
|
||||
{ pattern: /ae/, replacement: "e" },
|
||||
// -oe- → -e- (foetus→fetus, oestrogen→estrogen)
|
||||
{ pattern: /oe/, replacement: "e" },
|
||||
// -ey → -y (curtsey→curtsy)
|
||||
{ pattern: /ey$/, replacement: "y" },
|
||||
// grey → gray
|
||||
{ pattern: /grey/, replacement: "gray" }
|
||||
];
|
||||
function matchBritish(word) {
|
||||
const lower = word.toLowerCase();
|
||||
for (const { pattern, replacement } of BRITISH_TO_AMERICAN) {
|
||||
if (pattern.test(lower)) {
|
||||
const american = lower.replace(pattern, replacement);
|
||||
if (american !== lower) {
|
||||
const phonemes = lookupPronunciation(american);
|
||||
if (phonemes) {
|
||||
return { american, phonemes };
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
function translateAsBritish(word, format = "ingglish") {
|
||||
const match = matchBritish(word);
|
||||
if (match === null) {
|
||||
return null;
|
||||
}
|
||||
return arpabetToFormat2(match.phonemes, format);
|
||||
}
|
||||
|
||||
// src/compounds.ts
|
||||
import { lookupPronunciation as lookupPronunciation2, getWordFrequency } from "@ingglish/dictionary";
|
||||
import {
|
||||
arpabetToFormat as arpabetToFormat3,
|
||||
getFormatJoinSeparator,
|
||||
getFormatPreservesCase
|
||||
} from "@ingglish/phonemes";
|
||||
function capitalize(str) {
|
||||
if (str.length === 0) {
|
||||
return str;
|
||||
}
|
||||
return str.charAt(0).toUpperCase() + str.slice(1);
|
||||
}
|
||||
function isUpperCase(char) {
|
||||
return char === char.toUpperCase() && char !== char.toLowerCase();
|
||||
}
|
||||
var MIN_PART_LENGTH = 3;
|
||||
var MIN_PART_FREQUENCY = 500;
|
||||
var MAX_PART_LENGTH = 15;
|
||||
function dpDecompose(word) {
|
||||
const n = word.length;
|
||||
const dp = Array.from({
|
||||
length: n + 1
|
||||
});
|
||||
dp[0] = { parts: [], score: 0 };
|
||||
for (let i = MIN_PART_LENGTH; i <= n; i++) {
|
||||
for (let j = Math.max(0, i - MAX_PART_LENGTH); j <= i - MIN_PART_LENGTH; j++) {
|
||||
if (j === 0 && i === n) {
|
||||
continue;
|
||||
}
|
||||
const prev = dp[j];
|
||||
if (prev === void 0) {
|
||||
continue;
|
||||
}
|
||||
const chunk = word.slice(j, i);
|
||||
const phonemes = lookupWord(chunk);
|
||||
if (!phonemes) {
|
||||
continue;
|
||||
}
|
||||
const freq = getWordFrequency(chunk);
|
||||
if (freq === void 0 || freq < MIN_PART_FREQUENCY) {
|
||||
continue;
|
||||
}
|
||||
const newScore = prev.score + freq;
|
||||
const newParts = prev.parts.length + 1;
|
||||
const current = dp[i];
|
||||
if (current === void 0 || newParts < current.parts.length || newParts === current.parts.length && newScore > current.score) {
|
||||
dp[i] = { parts: [...prev.parts, chunk], score: newScore };
|
||||
}
|
||||
}
|
||||
}
|
||||
const result = dp[n];
|
||||
if (result === void 0 || result.parts.length < 2) {
|
||||
return null;
|
||||
}
|
||||
return result.parts;
|
||||
}
|
||||
function translateAsCompound(word, format = "ingglish") {
|
||||
const lowerWord = word.toLowerCase();
|
||||
if (lowerWord.length < 6) {
|
||||
return null;
|
||||
}
|
||||
const parts = dpDecompose(lowerWord);
|
||||
if (!parts) {
|
||||
return null;
|
||||
}
|
||||
const translations = [];
|
||||
let pos = 0;
|
||||
for (const part of parts) {
|
||||
const phonemes = lookupWord(part);
|
||||
if (!phonemes) {
|
||||
return null;
|
||||
}
|
||||
let translated = arpabetToFormat3(phonemes, format);
|
||||
if (getFormatPreservesCase(format)) {
|
||||
const originalPart = word.slice(pos, pos + part.length);
|
||||
if (originalPart.length > 0 && isUpperCase(originalPart[0])) {
|
||||
translated = capitalize(translated);
|
||||
}
|
||||
}
|
||||
translations.push(translated);
|
||||
pos += part.length;
|
||||
}
|
||||
return translations.join(getFormatJoinSeparator(format));
|
||||
}
|
||||
function lookupWord(word) {
|
||||
return lookupPronunciation2(word);
|
||||
}
|
||||
|
||||
// src/stemming.ts
|
||||
import { lookupPronunciation as lookupPronunciation3 } from "@ingglish/dictionary";
|
||||
import { arpabetToFormat as arpabetToFormat4, stripStress } from "@ingglish/phonemes";
|
||||
var VOICELESS = /* @__PURE__ */ new Set(["CH", "F", "HH", "K", "P", "S", "SH", "T", "TH"]);
|
||||
var SIBILANTS = /* @__PURE__ */ new Set(["CH", "JH", "S", "SH", "Z", "ZH"]);
|
||||
function selectEdPhonemes(lastPhoneme) {
|
||||
const base = stripStress(lastPhoneme);
|
||||
if (base === "T" || base === "D") {
|
||||
return ["IH0", "D"];
|
||||
}
|
||||
if (VOICELESS.has(base)) {
|
||||
return ["T"];
|
||||
}
|
||||
return ["D"];
|
||||
}
|
||||
function selectSPhonemes(lastPhoneme) {
|
||||
const base = stripStress(lastPhoneme);
|
||||
if (SIBILANTS.has(base)) {
|
||||
return ["IH0", "Z"];
|
||||
}
|
||||
if (VOICELESS.has(base)) {
|
||||
return ["S"];
|
||||
}
|
||||
return ["Z"];
|
||||
}
|
||||
var INFLECTIONAL_SUFFIXES = /* @__PURE__ */ new Set([
|
||||
"ed",
|
||||
"er",
|
||||
"es",
|
||||
"est",
|
||||
"ification",
|
||||
"ify",
|
||||
"ifying",
|
||||
"ing",
|
||||
"or",
|
||||
"s"
|
||||
]);
|
||||
var SUFFIX_PHONEMES = [
|
||||
// Long suffixes first (must come before shorter matches: -ification before -tion, -ifying before -ing)
|
||||
{ phonemes: ["IH0", "F", "IH0", "K", "EY1", "SH", "AH0", "N"], suffix: "ification" },
|
||||
{ phonemes: ["IH0", "F", "AY1", "IH0", "NG"], suffix: "ifying" },
|
||||
{ phonemes: ["IH0", "F", "AY1"], suffix: "ify" },
|
||||
// Verb suffixes
|
||||
{ phonemes: ["IH0", "NG"], suffix: "ing" },
|
||||
{ phonemes: null, suffix: "ed" },
|
||||
// allomorph: T/D/IH0 D (selected dynamically)
|
||||
{ phonemes: null, suffix: "es" },
|
||||
// allomorph: same as -s (S/Z/IH0 Z based on stem)
|
||||
{ phonemes: null, suffix: "s" },
|
||||
// allomorph: S/Z/IH0 Z (selected dynamically)
|
||||
// Noun suffixes
|
||||
{ phonemes: ["SH", "AH0", "N"], suffix: "tion" },
|
||||
{ phonemes: ["ZH", "AH0", "N"], suffix: "sion" },
|
||||
{ phonemes: ["N", "AH0", "S"], suffix: "ness" },
|
||||
{ phonemes: ["M", "AH0", "N", "T"], suffix: "ment" },
|
||||
{ phonemes: ["IH0", "T", "IY0"], suffix: "ity" },
|
||||
{ phonemes: ["ER0"], suffix: "er" },
|
||||
{ phonemes: ["ER0"], suffix: "or" },
|
||||
{ phonemes: ["IH0", "S", "T"], suffix: "ist" },
|
||||
{ phonemes: ["IH0", "Z", "AH0", "M"], suffix: "ism" },
|
||||
// Adjective suffixes
|
||||
{ phonemes: ["L", "IY0"], suffix: "ly" },
|
||||
{ phonemes: ["F", "AH0", "L"], suffix: "ful" },
|
||||
{ phonemes: ["L", "AH0", "S"], suffix: "less" },
|
||||
{ phonemes: ["AH0", "B", "AH0", "L"], suffix: "able" },
|
||||
{ phonemes: ["AH0", "B", "AH0", "L"], suffix: "ible" },
|
||||
{ phonemes: ["AH0", "S"], suffix: "ous" },
|
||||
{ phonemes: ["IH0", "V"], suffix: "ive" },
|
||||
{ phonemes: ["AH0", "L"], suffix: "al" },
|
||||
{ phonemes: ["IH0", "K"], suffix: "ic" },
|
||||
// Comparative/superlative
|
||||
{ phonemes: ["AH0", "S", "T"], suffix: "est" },
|
||||
// Additional suffixes
|
||||
{ phonemes: ["AH0", "L", "IY0"], suffix: "ally" },
|
||||
{ phonemes: ["AA1", "L", "AH0", "JH", "IY0"], suffix: "ology" },
|
||||
{ phonemes: ["AY1", "Z"], suffix: "ize" },
|
||||
{ phonemes: ["AY1", "Z"], suffix: "ise" }
|
||||
];
|
||||
var PREFIX_PHONEMES = [
|
||||
{ phonemes: ["AH0", "N"], prefix: "un" },
|
||||
{ phonemes: ["R", "IY0"], prefix: "re" },
|
||||
{ phonemes: ["P", "R", "IY0"], prefix: "pre" },
|
||||
{ phonemes: ["D", "IH0", "S"], prefix: "dis" },
|
||||
{ phonemes: ["M", "IH0", "S"], prefix: "mis" },
|
||||
{ phonemes: ["OW1", "V", "ER0"], prefix: "over" },
|
||||
{ phonemes: ["AH1", "N", "D", "ER0"], prefix: "under" },
|
||||
{ phonemes: ["AW1", "T"], prefix: "out" },
|
||||
{ phonemes: ["AE1", "N", "T", "IY0"], prefix: "anti" },
|
||||
{ phonemes: ["S", "UW1", "P", "ER0"], prefix: "super" }
|
||||
];
|
||||
function matchStemming(word) {
|
||||
const lowerWord = word.toLowerCase();
|
||||
for (const { phonemes: suffixArpabet, suffix } of SUFFIX_PHONEMES) {
|
||||
if (lowerWord.endsWith(suffix) && lowerWord.length > suffix.length + 2) {
|
||||
const stem = lowerWord.slice(0, -suffix.length);
|
||||
for (const variant of getStemVariants(stem, suffix)) {
|
||||
const baseArpabet = lookupPronunciation3(variant);
|
||||
if (baseArpabet) {
|
||||
const resolvedSuffix = resolveSuffixPhonemes(suffix, suffixArpabet, baseArpabet);
|
||||
return {
|
||||
phonemes: [...baseArpabet, ...resolvedSuffix],
|
||||
stem: variant,
|
||||
suffix
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (const { phonemes: prefixArpabet, prefix } of PREFIX_PHONEMES) {
|
||||
if (lowerWord.startsWith(prefix) && lowerWord.length > prefix.length + 2) {
|
||||
const stem = lowerWord.slice(prefix.length);
|
||||
const baseArpabet = lookupPronunciation3(stem);
|
||||
if (baseArpabet) {
|
||||
return {
|
||||
phonemes: [...prefixArpabet, ...baseArpabet],
|
||||
prefix,
|
||||
stem
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
function translateWithStemming(word, format = "ingglish") {
|
||||
const match = matchStemming(word);
|
||||
if (match === null) {
|
||||
return null;
|
||||
}
|
||||
return arpabetToFormat4(match.phonemes, format);
|
||||
}
|
||||
function getStemVariants(stem, suffix) {
|
||||
const variants = [stem];
|
||||
if (INFLECTIONAL_SUFFIXES.has(suffix)) {
|
||||
variants.push(
|
||||
stem + "e",
|
||||
// hoping -> hope
|
||||
stem.length > 1 ? stem.slice(0, -1) : stem,
|
||||
// running -> run (double consonant)
|
||||
stem.length > 0 ? stem + stem.at(-1) : stem
|
||||
// big -> bigg (for adding -er)
|
||||
);
|
||||
}
|
||||
if (stem.endsWith("i")) {
|
||||
variants.push(stem.slice(0, -1) + "y");
|
||||
}
|
||||
variants.push(stem + "y");
|
||||
return variants;
|
||||
}
|
||||
function resolveSuffixPhonemes(suffix, suffixArpabet, baseArpabet) {
|
||||
if (suffixArpabet !== null) {
|
||||
return suffixArpabet;
|
||||
}
|
||||
const lastPhoneme = baseArpabet.at(-1);
|
||||
if (suffix === "ed") {
|
||||
return selectEdPhonemes(lastPhoneme);
|
||||
}
|
||||
return selectSPhonemes(lastPhoneme);
|
||||
}
|
||||
|
||||
// src/index.ts
|
||||
function diagnoseUnknown(word) {
|
||||
if (/(.)\1\1/.test(word) || !/[aeiouy]/i.test(word)) {
|
||||
return null;
|
||||
}
|
||||
const { strategy } = translateUnknownCore(word, "ingglish");
|
||||
switch (strategy) {
|
||||
case "british": {
|
||||
const m = matchBritish(word);
|
||||
return { americanSpelling: m.american, phonemes: m.phonemes, strategy: "british" };
|
||||
}
|
||||
case "compound": {
|
||||
return { parts: dpDecompose(word.toLowerCase()), strategy: "compound" };
|
||||
}
|
||||
case "custom": {
|
||||
return { phonemes: getCustomPronunciation(word), strategy: "custom" };
|
||||
}
|
||||
case "g2p": {
|
||||
return { strategy: "g2p", trace: wordToArpabetTraced(word) };
|
||||
}
|
||||
case "initialism": {
|
||||
return { strategy: "initialism" };
|
||||
}
|
||||
case "stemming": {
|
||||
const m = matchStemming(word);
|
||||
return { prefix: m.prefix, stem: m.stem, strategy: "stemming", suffix: m.suffix };
|
||||
}
|
||||
}
|
||||
}
|
||||
function translateUnknown(word, format = "ingglish") {
|
||||
return translateUnknownCore(word, format).translated;
|
||||
}
|
||||
function translateUnknownCore(word, format) {
|
||||
const customPhonemes = getCustomPronunciation(word);
|
||||
if (customPhonemes !== void 0) {
|
||||
return { strategy: "custom", translated: arpabetToFormat5(customPhonemes, format) };
|
||||
}
|
||||
if (isInitialism(word)) {
|
||||
return { strategy: "initialism", translated: translateAsAcronym(word, format) };
|
||||
}
|
||||
const britishResult = translateAsBritish(word, format);
|
||||
if (britishResult !== null && britishResult.length > 0) {
|
||||
return { strategy: "british", translated: britishResult };
|
||||
}
|
||||
const compoundResult = translateAsCompound(word, format);
|
||||
if (compoundResult !== null && compoundResult.length > 0) {
|
||||
return { strategy: "compound", translated: compoundResult };
|
||||
}
|
||||
const stemmedResult = translateWithStemming(word, format);
|
||||
if (stemmedResult !== null && stemmedResult.length > 0) {
|
||||
return { strategy: "stemming", translated: stemmedResult };
|
||||
}
|
||||
return { strategy: "g2p", translated: wordToPhonetic(word, format) };
|
||||
}
|
||||
export {
|
||||
KNOWN_INITIALISMS,
|
||||
LETTER_PHONEMES,
|
||||
diagnoseUnknown,
|
||||
isInitialism,
|
||||
matchBritish,
|
||||
parseInitialismWithSuffix,
|
||||
translateAsAcronym,
|
||||
translateUnknown
|
||||
};
|
||||
Reference in new issue
Block a user