@@ -13,10 +13,8 @@ async function asyncMapStrict(arr, fn) {
1313
1414function sanitize ( text ) {
1515 return text
16- . replace (
17- / [ ^ \p{ L} \p{ M} ' p b t d ʈ ɖ c ɟ k ɡ q ɢ ʔ m ɱ n ɳ ɲ ŋ ɴ ʙ r ʀ ⱱ ɾ ɽ ɸ β f v θ ð s z ʃ ʒ ʂ ʐ ç ʝ x ɣ χ ʁ ħ ʕ h ɦ ɬ ɮ ʋ ɹ ɻ j ɰ l ɭ ʎ ʟ ʘ ǀ ǃ ǂ ǁ ɓ ɗ ʄ ɠ ʛ ʼ i y ɨ ʉ ɯ u ɪ ʏ ʊ e ø ɘ ɵ ɤ o ə ɛ œ ɜ ɞ ʌ ɔ æ ɐ a ɶ ɑ ɒ ʍ w ɥ ʜ ʢ ʡ ɕ ʑ ɺ ɧ ͡ ͜ ˈ ˌ ː ˑ ̆ | ‖ . ‿ ̥ ̬ ʰ ̹ ̜ ̟ ̠ ̈ ̽ ̩ ̯ ˞ ̤ ̰ ̼ ʷ ʲ ˠ ˤ ̴ ̝ ̞ ̘ ̙ ̪ ̺ ̻ ̃ ⁿ ˡ ̚ ̋ ˥ ̌ ˩ ́ ˦ ̂ ̄ ˧ ᷄ ̀ ˨ ᷅ ̏ ᷈ - ] / gu,
18- "" ,
19- )
16+ . replace ( / [ ^ \p{ L} \p{ M} ' ’ - ] / gu, "" )
17+ . replaceAll ( "’" , "'" )
2018 . normalize ( "NFKC" ) ;
2119}
2220
@@ -85,8 +83,8 @@ function clearStorage() {
8583}
8684
8785function get_ipa_no_cache ( text , args ) {
88- console . log ( "doing actual IPA" , text , args ) ;
8986 const cleanText = sanitize ( text ) ;
87+ console . log ( "doing actual IPA" , text , cleanText , args ) ;
9088
9189 const [ lang , langStyle , langForm ] = args . split ( ";" ) ;
9290 let command = "" ;
@@ -116,18 +114,20 @@ function get_ipa_no_cache(text, args) {
116114 break ;
117115 case "German" :
118116 if ( langForm === "Phonemic" ) {
119- let dictRecord = globalThis . lexicon . get (
120- cleanText . replace ( / [ ^ \p{ Letter} \p{ Mark} - ] + / gu, "" ) ,
121- ) ;
122- if ( ! dictRecord ) {
123- dictRecord = globalThis . lexicon . get (
124- cleanText . replace ( / [ ^ \p{ Letter} \p{ Mark} - ] + / gu, "" ) . toLowerCase ( ) ,
117+ if ( globalThis . lexicon ) {
118+ let dictRecord = globalThis . lexicon . get (
119+ cleanText . replace ( / [ ^ \p{ Letter} \p{ Mark} - ] + / gu, "" ) ,
125120 ) ;
126- }
127- console . log ( cleanText , dictRecord ) ;
128- if ( dictRecord ) {
129- command = 'ipa="' + dictRecord + '";' ;
130- break ;
121+ if ( ! dictRecord ) {
122+ dictRecord = globalThis . lexicon . get (
123+ cleanText . replace ( / [ ^ \p{ Letter} \p{ Mark} - ] + / gu, "" ) . toLowerCase ( ) ,
124+ ) ;
125+ }
126+ console . log ( cleanText , dictRecord ) ;
127+ if ( dictRecord ) {
128+ command = 'ipa="' + dictRecord + '";' ;
129+ break ;
130+ }
131131 }
132132 }
133133 command =
@@ -150,6 +150,21 @@ function get_ipa_no_cache(text, args) {
150150 break ;
151151 case "French" :
152152 if ( langForm === "Phonemic" ) {
153+ if ( globalThis . lexicon ) {
154+ let dictRecord = globalThis . lexicon . get (
155+ cleanText . replace ( / [ ^ \p{ Letter} \p{ Mark} - ] + / gu, "" ) ,
156+ ) ;
157+ if ( ! dictRecord ) {
158+ dictRecord = globalThis . lexicon . get (
159+ cleanText . replace ( / [ ^ \p{ Letter} \p{ Mark} - ] + / gu, "" ) . toLowerCase ( ) ,
160+ ) ;
161+ }
162+ console . log ( cleanText , dictRecord ) ;
163+ if ( dictRecord ) {
164+ command = 'ipa="' + dictRecord + '";' ;
165+ break ;
166+ }
167+ }
153168 command = `(window.fr_ipa.show("${ cleanText } ")[0])` ;
154169 }
155170
@@ -166,20 +181,21 @@ function get_ipa_no_cache(text, args) {
166181 break ;
167182 case "Czech" :
168183 if ( langForm === "Phonemic" ) {
169- let dictRecord = globalThis . lexicon . get (
170- cleanText . replace ( / [ ^ \p{ Letter} \p{ Mark} - ] + / gu, "" ) ,
171- ) ;
172- if ( ! dictRecord ) {
173- dictRecord = globalThis . lexicon . get (
174- cleanText . replace ( / [ ^ \p{ Letter} \p{ Mark} - ] + / gu, "" ) . toLowerCase ( ) ,
184+ if ( globalThis . lexicon ) {
185+ let dictRecord = globalThis . lexicon . get (
186+ cleanText . replace ( / [ ^ \p{ Letter} \p{ Mark} - ] + / gu, "" ) ,
175187 ) ;
188+ if ( ! dictRecord ) {
189+ dictRecord = globalThis . lexicon . get (
190+ cleanText . replace ( / [ ^ \p{ Letter} \p{ Mark} - ] + / gu, "" ) . toLowerCase ( ) ,
191+ ) ;
192+ }
193+ console . log ( cleanText , dictRecord ) ;
194+ if ( dictRecord ) {
195+ command = 'ipa="' + dictRecord + '";' ;
196+ break ;
197+ }
176198 }
177- console . log ( cleanText , dictRecord ) ;
178- if ( dictRecord ) {
179- command = 'ipa="' + dictRecord + '";' ;
180- break ;
181- }
182-
183199 command = `(window.cs_ipa.toIPA("${ cleanText } "))` ;
184200 }
185201 break ;
@@ -227,10 +243,11 @@ function get_ipa_no_cache(text, args) {
227243 if ( ! ipa ) {
228244 return { value : text , status : "error" } ;
229245 }
230-
246+ console . log ( "before replace ipa " , ipa ) ;
231247 if ( langStyle === "Parisian (experimental)" ) {
232248 ipa = ipa
233- . replace ( "ɔ̃̃̃̃̃" , "õ" )
249+ . replace ( "ɔ̃̃̃̃̃̃" , "õ" )
250+ . replace ( "ɔ̃" , "õ" )
234251 . replace ( "ɑ̃" , "ɔ̃" )
235252 . replace ( "œ̃" , "ɑ̃" )
236253 . replace ( "ɛ̃" , "ɑ̃" ) ;
0 commit comments