@ingglish/ipa 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,66 @@
1
+ import { OutputFormat, TranslatedToken } from '@ingglish/phonemes';
2
+
3
+ interface IpaDict {
4
+ entries: Record<string, string>;
5
+ lang: string;
6
+ }
7
+ interface Language {
8
+ code: string;
9
+ label: string;
10
+ }
11
+ /** Insert spaces between adjacent Khmer words that have no separator. */
12
+ declare function segmentKhmerText(text: string): string;
13
+ declare const LANGUAGES: Language[];
14
+ /**
15
+ * Converts an IPA transcription to Ingglish spelling.
16
+ * Strips slashes and syllable dots before conversion.
17
+ */
18
+ declare function ipaToIngglish(ipa: string): string;
19
+ declare function lookupIpa(dict: IpaDict, word: string): string | undefined;
20
+ /** Marker for words not found in the dictionary */
21
+ declare const NOT_FOUND_MARKER = "\uFFFD";
22
+ /**
23
+ * Translates foreign text to the specified output format.
24
+ * Words not found in the dictionary are returned with a marker prefix.
25
+ *
26
+ * For caseless scripts (Arabic, Japanese, Chinese, Korean), sentence-initial
27
+ * words are automatically capitalized in the output.
28
+ */
29
+ declare function translateForeign(text: string, dict: IpaDict, format?: OutputFormat): string;
30
+ /**
31
+ * Like {@link translateForeign}, but returns token-by-token mappings instead of a string.
32
+ * Each token includes the original text, translation, and whether it matched the dictionary.
33
+ */
34
+ declare function translateForeignWithMapping(text: string, dict: IpaDict, format?: OutputFormat): TranslatedToken[];
35
+
36
+ /**
37
+ * Converts IPA text to ARPAbet with stress digits stripped.
38
+ */
39
+ declare function ipaToArpabetClean(ipa: string): null | string[];
40
+
41
+ /**
42
+ * ARPAbet to IPA conversion.
43
+ *
44
+ * Converts CMU dictionary phoneme sequences to IPA notation,
45
+ * with proper stress marker placement at syllable boundaries.
46
+ */
47
+ /**
48
+ * Converts a single ARPAbet phoneme to IPA.
49
+ * Handles stress markers on vowels.
50
+ *
51
+ * @param phoneme ARPAbet phoneme (e.g., "AH0", "EY1", "B")
52
+ * @returns IPA symbol (e.g., "ə", "ˈeɪ", "b")
53
+ */
54
+ declare function arpabetPhonemeToIPA(phoneme: string): string;
55
+ /**
56
+ * Converts ARPAbet to IPA without surrounding slashes.
57
+ * Useful for combining with other text.
58
+ *
59
+ * @param arpabet Array of ARPAbet symbols
60
+ * @returns IPA transcription without surrounding slashes
61
+ */
62
+ declare function arpabetToIPARaw(arpabet: string[]): string;
63
+
64
+ declare function registerIPA(): void;
65
+
66
+ export { type IpaDict, LANGUAGES, type Language, NOT_FOUND_MARKER, arpabetPhonemeToIPA, arpabetToIPARaw, ipaToArpabetClean, ipaToIngglish, lookupIpa, registerIPA, segmentKhmerText, translateForeign, translateForeignWithMapping };
@@ -0,0 +1,66 @@
1
+ import { OutputFormat, TranslatedToken } from '@ingglish/phonemes';
2
+
3
+ interface IpaDict {
4
+ entries: Record<string, string>;
5
+ lang: string;
6
+ }
7
+ interface Language {
8
+ code: string;
9
+ label: string;
10
+ }
11
+ /** Insert spaces between adjacent Khmer words that have no separator. */
12
+ declare function segmentKhmerText(text: string): string;
13
+ declare const LANGUAGES: Language[];
14
+ /**
15
+ * Converts an IPA transcription to Ingglish spelling.
16
+ * Strips slashes and syllable dots before conversion.
17
+ */
18
+ declare function ipaToIngglish(ipa: string): string;
19
+ declare function lookupIpa(dict: IpaDict, word: string): string | undefined;
20
+ /** Marker for words not found in the dictionary */
21
+ declare const NOT_FOUND_MARKER = "\uFFFD";
22
+ /**
23
+ * Translates foreign text to the specified output format.
24
+ * Words not found in the dictionary are returned with a marker prefix.
25
+ *
26
+ * For caseless scripts (Arabic, Japanese, Chinese, Korean), sentence-initial
27
+ * words are automatically capitalized in the output.
28
+ */
29
+ declare function translateForeign(text: string, dict: IpaDict, format?: OutputFormat): string;
30
+ /**
31
+ * Like {@link translateForeign}, but returns token-by-token mappings instead of a string.
32
+ * Each token includes the original text, translation, and whether it matched the dictionary.
33
+ */
34
+ declare function translateForeignWithMapping(text: string, dict: IpaDict, format?: OutputFormat): TranslatedToken[];
35
+
36
+ /**
37
+ * Converts IPA text to ARPAbet with stress digits stripped.
38
+ */
39
+ declare function ipaToArpabetClean(ipa: string): null | string[];
40
+
41
+ /**
42
+ * ARPAbet to IPA conversion.
43
+ *
44
+ * Converts CMU dictionary phoneme sequences to IPA notation,
45
+ * with proper stress marker placement at syllable boundaries.
46
+ */
47
+ /**
48
+ * Converts a single ARPAbet phoneme to IPA.
49
+ * Handles stress markers on vowels.
50
+ *
51
+ * @param phoneme ARPAbet phoneme (e.g., "AH0", "EY1", "B")
52
+ * @returns IPA symbol (e.g., "ə", "ˈeɪ", "b")
53
+ */
54
+ declare function arpabetPhonemeToIPA(phoneme: string): string;
55
+ /**
56
+ * Converts ARPAbet to IPA without surrounding slashes.
57
+ * Useful for combining with other text.
58
+ *
59
+ * @param arpabet Array of ARPAbet symbols
60
+ * @returns IPA transcription without surrounding slashes
61
+ */
62
+ declare function arpabetToIPARaw(arpabet: string[]): string;
63
+
64
+ declare function registerIPA(): void;
65
+
66
+ export { type IpaDict, LANGUAGES, type Language, NOT_FOUND_MARKER, arpabetPhonemeToIPA, arpabetToIPARaw, ipaToArpabetClean, ipaToIngglish, lookupIpa, registerIPA, segmentKhmerText, translateForeign, translateForeignWithMapping };