diff --git a/packages/preview/ascii-ipa/1.1.1/CHANGELOG.md b/packages/preview/ascii-ipa/1.1.1/CHANGELOG.md new file mode 100644 index 0000000000..6faa776aab --- /dev/null +++ b/packages/preview/ascii-ipa/1.1.1/CHANGELOG.md @@ -0,0 +1,22 @@ +# Changelog of `ascii-ipa` + +follows [semantic versioning][semver] + +## 1.1.1 + +- Fixed a bug in X-SAMPA where ``` ` ``` falsely took precedence over ``` @` ``` (https://github.com/imatpot/typst-packages/issues/1) + +## 1.1.0 + +- Translations will now return a [`string`][typst-string] if the font is not overridden +- The library now explicitly exposes functions via a "gateway" entrypoint +- Update internal project structure +- Update package metadata +- Update documentation + +## 1.0.0 + +- Initial release + +[semver]: https://semver.org +[typst-string]: https://typst.app/docs/reference/foundations/str/ diff --git a/packages/preview/ascii-ipa/1.1.1/LICENSE b/packages/preview/ascii-ipa/1.1.1/LICENSE new file mode 100644 index 0000000000..b944a7f027 --- /dev/null +++ b/packages/preview/ascii-ipa/1.1.1/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 imatpot + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/preview/ascii-ipa/1.1.1/README.md b/packages/preview/ascii-ipa/1.1.1/README.md new file mode 100644 index 0000000000..be6ff9b0bf --- /dev/null +++ b/packages/preview/ascii-ipa/1.1.1/README.md @@ -0,0 +1,93 @@ +# `ascii-ipa` + +🔄 ASCII / IPA conversion for Typst + +This package allows you to easily convert different ASCII representations of the International Phonetic Alphabet (IPA) to and from the IPA. +It also offers some minor utilities to make phonetic transcriptions easier to use overall. +The package is being maintained [here][repo]. + +Note: This is an extended port of the [`ipa-translate`][ipa-translate] Rust crate by [tirimid][tirimid]'s conversion features into native Typst. +Most conversions are implemented according to [this Wikipedia article][ipa-wikipedia] with the [following exceptions](#deviations-from-wikipedia). + +## Conversion + +The package supports multiple ASCII representations for the IPA with one function each: + +| Notation | Function name | +|----------|-----------------| +| Branner | `#branner(...)` | +| Praat | `#praat(...)` | +| SIL | `#sil(...)` | +| X-SAMPA | `#xsampa(...)` | + +They all return the converted value as either [`string`][typst-str] or [`content`][typst-content]* and accept the set of same parameters: + +| Parameter | Type | Positional / Named | Default | Description | +|--------------------|-------------------------|--------------------|---------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `value` | [`string`][typst-str] | positional | | Main input to the function. Usually the transcription in the corresponsing ASCII-based notation. | +| `reverse` | [`boolean`][typst-bool] | named | `false` | Reverses the conversion. Pass Unicode IPA into `value` to get the corresponsing ASCII-based notation back. | +| `override-font`\* | [`boolean`][typst-bool] | named | `false` | Overrides the active font and forces rendering in Linux Libertine. Use this if your font has lackluster support for Unicode IPA. If set to `true`, the function will return [`content`][typst-content]. | + +### Examples + +All examples use the Russian word ⟨привет⟩ [prʲɪvʲet] for the conversion. + +```typst +#import "@preview/ascii-ipa:1.1.1": * + +// Branner +#branner("prj^Ivj^et") // prʲɪvʲet +#branner("prʲɪvʲet", reverse: true) // prj^Ivj^et + +// Praat +#praat("pr\\^j\\icv\\^jet") // prʲɪvʲet +#praat("prʲɪvʲet", reverse: true) // pr\\^j\\icv\\^jet + +// SIL +#sil("prj^i=vj^et") // prʲɪvʲet +#sil("prʲɪvʲet", reverse: true) // prj^i=vj^et + +// X-SAMPA +#xsampa("pr_jIv_jet") // prʲɪvʲet +#xsampa("prʲɪvʲet", reverse: true) // pr_jIv_jet + +// Font override +#xsampa("prj^Ivj^et", override-font: true) // prʲɪvʲet, but as content rendered in Linux Libertine +``` + +### Deviations from [Wikipedia][ipa-wikipedia] + +Not everything could be implemented fully compliant with the information in the article. + +- Branner + - `ts))` is represented as `t))s` +- SIL + - The only supported superscript characters are: `h` (`ʰ`), `j` (`ʲ`), `l` (`ˡ`), `n` (`ⁿ`), `w` (`ʷ`), `ɣ` (`ˠ`), `ʕ` (`ˤ`) + +## Brackets & Braces + +You can easily mark your notation text as phonetic, phonemic, orthographic, or prosodic. + +```typst +#import "@preview/ascii-ipa:1.1.1": * + +#phonetic("prʲɪˈvʲet") // [prʲɪˈvʲet] +#phnt("prʲɪˈvʲet") // [prʲɪˈvʲet] + +#phonemic("prɪvet") // /prɪvet/ +#phnm("prɪvet") // /prɪvet/ + +#orthographic("привет") // ⟨привет⟩ +#orth("привет") // ⟨привет⟩ + +#prosodic("prʲɪˈvʲet") // {prʲɪˈvʲet} +#prsd("prʲɪˈvʲet") // {prʲɪˈvʲet} +``` + +[repo]: https://github.com/imatpot/typst-packages +[ipa-translate]: https://github.com/tirimid/ipa-translate +[tirimid]: https://github.com/tirimid +[ipa-wikipedia]: https://en.wikipedia.org/wiki/Comparison_of_ASCII_encodings_of_the_International_Phonetic_Alphabet +[typst-content]: https://typst.app/docs/reference/foundations/content/ +[typst-str]: https://typst.app/docs/reference/foundations/str/ +[typst-bool]: https://typst.app/docs/reference/foundations/bool/ diff --git a/packages/preview/ascii-ipa/1.1.1/ascii-ipa.typ b/packages/preview/ascii-ipa/1.1.1/ascii-ipa.typ new file mode 100644 index 0000000000..712c3ad4e0 --- /dev/null +++ b/packages/preview/ascii-ipa/1.1.1/ascii-ipa.typ @@ -0,0 +1 @@ +#import "src/lib.typ": branner, praat, sil, xsampa, phonetic, phnt, phonemic, phnm, orthographic, orth, prosodic, prsd diff --git a/packages/preview/ascii-ipa/1.1.1/src/lib.typ b/packages/preview/ascii-ipa/1.1.1/src/lib.typ new file mode 100644 index 0000000000..3df1ae13b3 --- /dev/null +++ b/packages/preview/ascii-ipa/1.1.1/src/lib.typ @@ -0,0 +1,40 @@ +#import "translations/branner.typ": * +#import "translations/praat.typ": * +#import "translations/sil.typ": * +#import "translations/xsampa.typ": * + +#let apply-translations(content, translations, reverse) = { + let (from, to) = if reverse {( 1, 0 )} else {( 0, 1 )} + + for translation in translations { + content = content.replace(translation.at(from), translation.at(to)) + } + + return content +} + +#let translate(content, translations, reverse, override-font) = { + let translation = apply-translations(content, translations, reverse) + + return if override-font { + set text(font: "Linux Libertine") + translation + } else { + translation + } +} + +#let branner(content, reverse: false, override-font: false) = translate(content, branner-translations, reverse, override-font) +#let praat(content, reverse: false, override-font: false) = translate(content, praat-translations, reverse, override-font) +#let sil(content, reverse: false, override-font: false) = translate(content, sil-translations, reverse, override-font) +#let xsampa(content, reverse: false, override-font: false) = translate(content, xsampa-translations, reverse, override-font) + +#let phonetic(content) = [[#content]] +#let phonemic(content) = [/#content/] +#let orthographic(content) = [⟨#content⟩] +#let prosodic(content) = [{#content}] + +#let phnt = phonetic +#let phnm = phonemic +#let orth = orthographic +#let prsd = prosodic diff --git a/packages/preview/ascii-ipa/1.1.1/src/translations/branner.typ b/packages/preview/ascii-ipa/1.1.1/src/translations/branner.typ new file mode 100644 index 0000000000..009d4a5f2a --- /dev/null +++ b/packages/preview/ascii-ipa/1.1.1/src/translations/branner.typ @@ -0,0 +1,182 @@ +// adaptation of https://github.com/tirimid/ipa-translate/blob/master/translations/branner.rs + +#let branner-translations = ( + // vowels part 1. + ("i-", "ɨ"), + ("e&", "ɘ"), + ("E&", "ɜ"), + ("E\"", "ɞ"), + ("a\"&", "ɒ"), + ("a\"", "ɑ"), + ("a&", "ɐ"), + ("ae)", "æ"), + ("c&", "ɔ"), + ("o/)", "ø"), + ("oe)", "œ"), + ("OE)", "ɶ"), + ("o-", "ɵ"), + ("u-", "ʉ"), + ("v&", "ʌ"), + ("U\"", "ɤ"), + ("m&", "ɯ"), + ("xr^", "ɚ"), + + // consonants part 1. + ("tr)", "ʈ"), + ("dr)", "ɖ"), + ("j-", "ɟ"), + ("m\"", "ɱ"), + ("nr)", "ɳ"), + ("nj)", "ɲ"), + ("ng)", "ŋ"), + ("r\"", "ɾ"), + ("rr)", "ɽ"), + ("P\"", "ɸ"), + ("B\"", "β"), + ("O-", "θ"), + ("d-", "ð"), + ("3\"", "ʒ"), + ("sr)", "ʂ"), + ("zr)", "ʐ"), + ("c\"", "ç"), + ("j\"", "ʝ"), + ("g\"", "ɣ"), + ("R%", "ʁ"), + ("h-", "ħ"), + ("?&", "ʕ"), + ("h\"", "ɦ"), + ("l-", "ɬ"), + ("l3\")", "ɮ"), + ("v\"", "ʋ"), + ("r&", "ɹ"), + ("jr)", "ɻ"), + ("m&\"", "ɰ"), + ("lr)", "ɭ"), + ("y&", "ʎ"), + ("b$", "ɓ"), + ("d$", "ɗ"), + ("j$", "ʄ"), + ("g$", "ɠ"), + ("G$", "ʛ"), + ("w&", "ʍ"), + ("h&", "ɥ"), + ("?-", "ʡ"), + ("?\"", "ʢ"), + ("Sx)", "ɧ"), + ("p!", "ʘ"), + ("t!", "ǀ"), + ("r!", "ǃ"), + ("c!", "ǂ"), + ("l!", "ǁ"), + ("l\"", "ɺ"), + ("ci)", "ɕ"), + ("zi)", "ʑ"), + ("l~)", "ɫ"), + + // diacritics. + ("`", "ʼ"), + ("V)", "̥"), + ("v)", "̬"), + ("h^", "ʰ"), + ("h\")", "̤"), + ("~^", "̃"), + ("~)", "̴"), + ("~", "̰"), + ("{", "̼"), + ("[]", "̻"), + ("[", "̪"), + ("]", "̺"), + ("u)", "̹"), + ("U)", "̜"), + ("+", "̟"), + ("_", "̠"), + ("\"^", "̈"), + ("x^", "̽"), + ("<", "̘"), + (">", "̙"), + ("r^", "˞"), + ("w^", "ʷ"), + ("j^", "ʲ"), + ("&g^", "ˤ"), + ("g^", "ˠ"), + ("n^", "ⁿ"), + ("l^", "ˡ"), + (".)", "̚"), + ("=\"", "̞"), + ("=)", "͜"), + ("=", "̝"), + (",)", "̩"), + ("(", "̯"), + + // not implemented according to description. + // branner describes this being placed after two segments: `ts))`. + // in this implementation, it is placed in the middle: `t))s`. + ("))", "͡"), + + ("'", "ˈ"), + (",", "ˌ"), + (":", "ː"), + (";", "ˑ"), + ("(^", "̆"), + (".", "."), + ("||", "‖"), + ("|", "|"), + ("/)", "ꜛ"), + ("\\)", "ꜜ"), + ("/", "↗"), + ("\\", "↘"), + ("15", "̌"), + ("51", "̂"), + ("35", "᷄"), + ("13", "᷅"), + ("342", "᷈"), + ("5", "̋"), + ("4", "́"), + ("3", "̄"), + ("2", "̀"), + ("1", "̏"), + + // vowels part 2. + ("i", "i"), + ("e", "e"), + ("E", "ɛ"), + ("a", "a"), + ("o", "o"), + ("u", "u"), + ("y", "y"), + ("I", "ɪ"), + ("Y", "ʏ"), + ("U", "ʊ"), + ("@", "ə"), + + // consonants part 2. + ("p", "p"), + ("b", "b"), + ("t", "t"), + ("d", "d"), + ("c", "c"), + ("k", "k"), + ("g", "ɡ"), + ("q", "q"), + ("G", "ɢ"), + ("?", "ʔ"), + ("m", "m"), + ("n", "n"), + ("N", "ɴ"), + ("B", "ʙ"), + ("r", "r"), + ("R", "ʀ"), + ("f", "f"), + ("v", "v"), + ("s", "s"), + ("z", "z"), + ("S", "ʃ"), + ("x", "x"), + ("X", "χ"), + ("h", "h"), + ("j", "j"), + ("l", "l"), + ("L", "ʟ"), + ("w", "w"), + ("H", "ʜ"), +) diff --git a/packages/preview/ascii-ipa/1.1.1/src/translations/praat.typ b/packages/preview/ascii-ipa/1.1.1/src/translations/praat.typ new file mode 100644 index 0000000000..a9dc8b0306 --- /dev/null +++ b/packages/preview/ascii-ipa/1.1.1/src/translations/praat.typ @@ -0,0 +1,189 @@ +// adaptation of https://github.com/tirimid/ipa-translate/blob/master/translations/praat.rs + +#let praat-translations = ( + // understrike diacritics. + ("\\|v", "̩"), + ("\\0v", "̥"), + ("\\Tv", "̞"), + ("\\T^", "̝"), + ("\\T(", "̘"), + ("\\T)", "̙"), + ("\\-v", "̱"), + ("\\+v", "̟"), + ("\\:v", "̤"), + ("\\~v", "̰"), + ("\\Nv", "̪"), + ("\\Uv", "̺"), + ("\\Dv", "̻"), + ("\\nv", "̯"), + ("\\3v", "̹"), + ("\\cv", "̜"), + + // overstrike diacritics. + ("\\0^", "̊"), + ("\\'^", "́"), + ("\\`^", "̀"), + ("\\-^", "̄"), + ("\\~^", "̃"), + ("\\v^", "̌"), + ("\\^^", "̂"), + ("\\:^", "̈"), + ("\\x^", "̽"), + ("\\N^", "̆"), + ("\\li", "͡"), + ("\\_u", "‿"), + + // inline diacritics. + ("\\:f", "ː"), + ("\\.f", "ˑ"), + ("\\'1", "ˈ"), + ("\\'2", "ˌ"), + ("\\|f", "|"), + ("\\cn", "̚"), + ("\\hr", "˞"), + ("\\ap", "ʼ"), + + // superscript diacritics. + ("\\^h", "ʰ"), + ("\\^H", "ʱ"), + ("\\^j", "ʲ"), + ("\\^g", "ˠ"), + ("\\^M", "ᵚ"), + ("\\^G", "ᶭ"), + ("\\^w", "ʷ"), + ("\\^Y", "ᶣ"), + ("\\^?", "ˀ"), + ("\\^9", "ˁ"), + ("\\^l", "ˡ"), + ("\\^n", "ⁿ"), + ("\\^m", "ᵐ"), + ("\\^N", "ᵑ"), + ("\\^s", "ˢ"), + ("\\^x", "ˣ"), + ("\\^f", "ᶠ"), + ("\\^y", "ʸ"), + + // digraphs. + ("\\ts", "ʦ"), + ("\\tS", "ʧ"), + + // consonants part 1. + ("t^l", "tˡ"), + ("\\t.", "ʈ"), + ("\\?-", "ʡ"), + ("\\?g", "ʔ"), + ("d^l", "dˡ"), + ("\\d.", "ɖ"), + ("\\j-", "ɟ"), + ("\\gs", "ɡ"), + ("\\gc", "ɢ"), + ("\\mj", "ɱ"), + ("\\n.", "ɳ"), + ("\\nj", "ɲ"), + ("\\ng", "ŋ"), + ("\\nc", "ɴ"), + ("\\ff", "ɸ"), + ("\\tf", "θ"), + ("\\l-", "ɬ"), + ("\\sh", "ʃ"), + ("\\s.", "ʂ"), + ("\\cc", "ɕ"), + ("\\c.", "ç"), + ("\\wt", "ʍ"), + ("\\cf", "χ"), + ("\\h-", "ħ"), + ("\\hc", "ʜ"), + ("\\bf", "β"), + ("\\dh", "ð"), + ("\\lz", "ɮ"), + ("\\zh", "ʒ"), + ("\\z.", "ʐ"), + ("\\zc", "ʑ"), + ("\\jc", "ʝ"), + ("\\gf", "ɣ"), + ("\\ri", "ʁ"), + ("\\9e", "ʕ"), + ("\\9-", "ʢ"), + ("\\h^", "ɦ"), + ("\\vs", "ʋ"), + ("\\rt", "ɹ"), + ("\\r.", "ɻ"), + ("\\ht", "ɥ"), + ("\\ml", "ɰ"), + ("\\bc", "ʙ"), + ("\\rc", "ʀ"), + ("\\fh", "ɾ"), + ("\\rl", "ɺ"), + ("\\f.", "ɽ"), + ("\\l.", "ɭ"), + ("\\yt", "ʎ"), + ("\\lc", "ʟ"), + ("\\b^", "ɓ"), + ("\\d^", "ɗ"), + ("\\j^", "ʄ"), + ("\\g^", "ɠ"), + ("\\G^", "ʛ"), + ("\\O.", "ʘ"), + ("\\|1", "ǀ"), + ("\\|2", "ǁ"), + ("\\|-", "ǂ"), + ("\\l~", "ɫ"), + ("\\hj", "ɧ"), + + // vowels part 1. + ("\\i-", "ɨ"), + ("\\u-", "ʉ"), + ("\\mt", "ɯ"), + ("\\ic", "ɪ"), + ("\\yc", "ʏ"), + ("\\hs", "ʊ"), + ("\\o/", "ø"), + ("\\e-", "ɘ"), + ("\\o-", "ɵ"), + ("\\rh", "ɤ"), + ("\\sw", "ə"), + ("\\ef", "ɛ"), + ("\\oe", "œ"), + ("\\er", "ɜ"), + ("\\kb", "ɞ"), + ("\\vt", "ʌ"), + ("\\ct", "ɔ"), + ("\\ae", "æ"), + ("\\at", "ɐ"), + ("\\Oe", "ɶ"), + ("\\as", "ɑ"), + ("\\ab", "ɒ"), + ("\\sr", "ɚ"), + ("\\id", "ɿ"), + ("\\ir", "ʅ"), + + // consonants part 2. + ("p", "p"), + ("t", "t"), + ("c", "c"), + ("k", "k"), + ("q", "q"), + ("b", "b"), + ("d", "d"), + ("m", "m"), + ("n", "n"), + ("f", "f"), + ("s", "s"), + ("x", "x"), + ("h", "h"), + ("v", "v"), + ("z", "z"), + ("l", "l"), + ("j", "j"), + ("w", "w"), + ("r", "r"), + ("!", "ǃ"), + + // vowels part 2. + ("i", "i"), + ("y", "y"), + ("u", "u"), + ("e", "e"), + ("o", "o"), + ("a", "a"), +) diff --git a/packages/preview/ascii-ipa/1.1.1/src/translations/sil.typ b/packages/preview/ascii-ipa/1.1.1/src/translations/sil.typ new file mode 100644 index 0000000000..53795b1b60 --- /dev/null +++ b/packages/preview/ascii-ipa/1.1.1/src/translations/sil.typ @@ -0,0 +1,226 @@ +// adaptation of https://github.com/tirimid/ipa-translate/blob/master/translations/sil.rs + +#let sil-translations = ( // suprasegmentals and diacritics. + ("}}}}", "᷂"), + ("}}}", "͈"), + ("}}", "ˌ"), + ("}", "ˈ"), + (":::", "ːː"), + ("::", "ˑ"), + (":", "ː"), + ("*****", "̐"), + ("****", "̇"), + ("***", "̆"), + ("**", "̽"), + ("*", "̈"), + (".<", "|"), + (".=", "‖"), + (".", "."), + ("#=", "͜"), + ("#04", "˩˥"), + ("#40", "˥˩"), + ("#24", "˧˥"), + ("#12", "˨˧"), + ("#141", "˨˥˨"), + ("#4", "˥"), + ("#3", "˦"), + ("#2", "˧"), + ("#1", "˨"), + ("#0", "˩"), + ("#<<", "↘"), + ("#>>", "↗"), + ("#<", "ꜜ"), + ("#>", "ꜛ"), + ("!^", "ꜝ"), + ("##!", "ꜟ"), + ("#!", "ꜞ"), + ("@131", "᷈"), + ("@13", "̌"), + ("@313", "᷉"), + ("@31", "̂"), + ("@23", "᷄"), + ("@12", "᷅"), + ("@21", "᷆"), + ("@32", "᷇"), + ("@0", "̏"), + ("@1", "̀"), + ("@2", "̄"), + ("@3", "́"), + ("@4", "̋"), + ("0^", "⁰"), + ("1^", "¹"), + ("2^", "²"), + ("3^", "³"), + ("4^", "⁴"), + ("5^", "⁵"), + ("6^", "⁶"), + ("7^", "⁷"), + ("8^", "⁸"), + ("9^", "⁹"), + ("-^", "⁻"), + + // note that the "symbol followed by ^" is not implemented here. + // anyway, its not really necessary, as these superscripts are the most + // commonly used ones. + ("h^", "ʰ"), + ("w^", "ʷ"), + ("j^", "ʲ"), + ("g=^", "ˠ"), + ("?<^", "ˤ"), + ("n^", "ⁿ"), + ("l^", "ˡ"), + + ("[[[", "˞"), + ("[[", "ʽ"), + ("]]]]", "ʻ"), + ("]]]", "̚"), + ("]]", "ʼ"), + ("$$$$", "̢"), + ("$$$", "̰"), + ("$$", "̯"), + ("$", "̩"), + ("%%%%", "̡"), + ("%%%", "̤"), + ("%%", "̬"), + ("%", "̥"), + ("#&", "͡"), + ("@&", "͜"), + ("@@", "̍"), + ("@", "̊"), + ("{{{{{", "̣"), + ("{{{{", "̼"), + ("{{{", "̻"), + ("{{", "̺"), + ("{", "̪"), + ("l~~", "ɫ"), + ("~~", "̴"), + ("~", "̃"), + ("_____", "̧"), + ("____", "̜"), + ("___", "̙"), + ("__", "̞"), + ("_", "̠"), + ("++++", "̹"), + ("+++", "̘"), + ("++", "̝"), + ("+", "̟"), + + // combining grapheme joiner is not implemented here. + ("=>", "→"), + ("s>", "σ"), + + // consonants part 1. + ("t<", "ʈ"), + ("d<", "ɖ"), + ("j=", "ɟ"), + ("g<", "ɡ"), + ("G=", "ɢ"), + ("?=", "ʔ"), + ("m>", "ɱ"), + ("n<", "ɳ"), + ("n=", "ɲ"), + ("n>", "ŋ"), + ("N=", "ɴ"), + ("B=", "ʙ"), + ("r>", "ɾ"), + ("r<", "ɽ"), + ("R=", "ʀ"), + ("v<", "ⱱ"), + ("f=", "ɸ"), + ("b=", "β"), + ("t=", "θ"), + ("d=", "ð"), + ("s=", "ʃ"), + ("z=", "ʒ"), + ("s<", "ʂ"), + ("z<", "ʐ"), + ("c=", "ç"), + ("j<", "ʝ"), + ("g=", "ɣ"), + ("x=", "χ"), + ("R>", "ʁ"), + ("h>", "ħ"), + ("?<", "ʕ"), + ("h<", "ɦ"), + ("l=", "ɬ"), + ("l>", "ɮ"), + ("v=", "ʋ"), + ("r=", "ɹ"), + ("R<", "ɻ"), + ("w>", "ɰ"), + ("l<", "ɭ"), + ("L<", "ʎ"), + ("L=", "ʟ"), + ("p=", "ʘ"), + ("!<", "ǀ"), + ("!=", "ǂ"), + ("!>", "ǁ"), + ("b>", "ɓ"), + ("d>", "ɗ"), + ("j>", "ʄ"), + ("g>", "ɠ"), + ("G>", "ʛ"), + ("w=", "ʍ"), + ("y<", "ɥ"), + ("h=", "ɥ"), + ("H=", "ʜ"), + ("Q<", "ʢ"), + ("Q=", "ʡ"), + ("c<", "ɕ"), + ("z>", "ʑ"), + ("L>", "ɺ"), + ("H>", "ɧ"), + + // vowels part 1. + ("I=", "ɨ"), + ("U=", "ʉ"), + ("u=", "ɯ"), + ("i=", "ɪ"), + ("y=", "ʏ"), + ("u<", "ʊ"), + ("o>", "ø"), + ("E=", "ɘ"), + ("O=", "ɵ"), + ("O>", "ɤ"), + ("e=", "ə"), + ("e<", "ɛ"), + ("E<", "œ"), + ("e>", "ɜ"), + ("O<", "ɞ"), + ("u>", "ʌ"), + ("o<", "ɔ"), + ("a<", "æ"), + ("a>", "ɐ"), + ("E>", "ɶ"), + ("a=", "ɑ"), + ("o=", "ɒ"), + + // consonants part 2. + ("p", "p"), + ("b", "b"), + ("t", "t"), + ("d", "d"), + ("c", "c"), + ("k", "k"), + ("q", "q"), + ("m", "m"), + ("n", "n"), + ("r", "r"), + ("f", "f"), + ("v", "v"), + ("s", "s"), + ("z", "z"), + ("x", "x"), + ("h", "h"), + ("j", "j"), + ("l", "l"), + ("!", "ǃ"), + ("w", "w"), + + // vowels part 2. + ("i", "i"), + ("y", "y"), + ("u", "u"), + ("e", "e"), + ("o", "o"), +) diff --git a/packages/preview/ascii-ipa/1.1.1/src/translations/xsampa.typ b/packages/preview/ascii-ipa/1.1.1/src/translations/xsampa.typ new file mode 100644 index 0000000000..6178ccda14 --- /dev/null +++ b/packages/preview/ascii-ipa/1.1.1/src/translations/xsampa.typ @@ -0,0 +1,184 @@ +// adaptation of https://github.com/tirimid/ipa-translate/blob/master/translations/xsampa.rs + +#let xsampa-translations = ( + // diacritics part 1. + ("_A", "̘"), + ("_a", "̺"), + ("_B_L", "᷅"), + ("_B", "̏"), + ("_c", "̜"), + ("_d", "̪"), + ("_e", "̴"), + ("", "↘"), + ("_F", "̂"), + ("_G", "ˠ"), + ("_H_T", "᷄"), + ("_H", "́"), + ("_h", "ʰ"), + ("_j", "ʲ"), + ("_k", "̰"), + ("_L", "̀"), + ("_l", "ˡ"), + ("_M", "̄"), + ("_m", "̻"), + ("_N", "̼"), + ("_n", "ⁿ"), + ("_O", "̹"), + ("_o", "̞"), + ("_q", "̙"), + ("", "↗"), + ("_R_F", "᷈"), + ("_R", "̌"), + ("_r", "̝"), + ("_T", "̋"), + ("_t", "̤"), + ("_v", "̬"), + ("_w", "ʷ"), + ("_X", "̆"), + ("_x", "̽"), + + // lowercase symbols. + ("a", "a"), + ("b_<", "ɓ"), + ("b", "b"), + ("c", "c"), + ("d_<", "ɗ"), + ("d`", "ɖ"), + ("d", "d"), + ("e", "e"), + ("f", "f"), + ("g_<", "ɠ"), + ("g", "ɡ"), + ("h\\", "ɦ"), + ("h", "h"), + ("i", "i"), + ("j\\", "ʝ"), + ("j", "j"), + ("k", "k"), + ("l`", "ɭ"), + ("l\\", "ɺ"), + ("l", "l"), + ("m", "m"), + ("n`", "ɳ"), + ("n", "n"), + ("o", "o"), + ("p\\", "ɸ"), + ("p", "p"), + ("q", "q"), + ("r\\`", "ɻ"), + ("r\\", "ɹ"), + ("r`", "ɽ"), + ("r", "r"), + ("s\\", "ɕ"), + ("s`", "ʂ"), + ("s", "s"), + ("t`", "ʈ"), + ("t", "t"), + ("u", "u"), + ("v\\", "ʋ"), + ("v", "v"), + ("w", "w"), + ("x\\", "ɧ"), + ("x", "x"), + ("y", "y"), + ("z\\", "ʑ"), + ("z`", "ʐ"), + ("z", "z"), + + // uppercase symbols. + ("A", "ɑ"), + ("B\\", "ʙ"), + ("B", "β"), + ("C", "ç"), + ("D", "ð"), + ("E", "ɛ"), + ("F", "ɱ"), + ("G\\_<", "ʛ"), + ("G\\", "ɢ"), + ("G", "ɣ"), + ("H\\", "ʜ"), + ("H", "ɥ"), + ("I\\", "ᵻ"), + ("I", "ɪ"), + ("J\\_<", "ʄ"), + ("J\\", "ɟ"), + ("J", "ɲ"), + ("K\\", "ɮ"), + ("K", "ɬ"), + ("L\\", "ʟ"), + ("L", "ʎ"), + ("M\\", "ɰ"), + ("M", "ɯ"), + ("N\\", "ɴ"), + ("N", "ŋ"), + ("O\\", "ʘ"), + ("O", "ɔ"), + ("P", "ʋ"), + ("Q", "ɒ"), + ("R\\", "ʀ"), + ("R", "ʁ"), + ("S", "ʃ"), + ("T", "θ"), + ("U\\", "ᵿ"), + ("U", "ʊ"), + ("V", "ʌ"), + ("W", "ʍ"), + ("X\\", "ħ"), + ("X", "χ"), + ("Y", "ʏ"), + ("Z", "ʒ"), + ("@`", "ɚ"), + + // diacritics part 2. + ("_\"", "̈"), + ("_+", "̟"), + ("_-", "̠"), + ("_/", "̌"), + ("_0", "̥"), + ("_=", "̩"), + ("=", "̩"), + ("_>", "ʼ"), + ("_?\\", "ˤ"), + ("_\\", "̂"), + ("_^", "̯"), + ("_}", "̚"), + ("`", "˞"), + ("_~", "̃"), + ("~", "̃"), + + // other symbols. + (".", "."), + ("\"", "ˈ"), + ("%", "ˌ"), + ("'", "ʲ"), + (":\\", "ˑ"), + (":", "ː"), + ("@\\", "ɘ"), + ("@", "ə"), + ("{", "æ"), + ("}", "ʉ"), + ("1", "ɨ"), + ("2", "ø"), + ("3\\", "ɞ"), + ("3", "ɜ"), + ("4", "ɾ"), + ("5", "ɫ"), + ("6", "ɐ"), + ("7", "ɤ"), + ("8", "ɵ"), + ("9", "œ"), + ("&", "ɶ"), + ("?\\", "ʕ"), + ("?", "ʔ"), + ("<\\", "ʢ"), + (">\\", "ʡ"), + ("^", "ꜛ"), + ("!\\", "ǃ"), + ("!", "ꜜ"), + ("|\\\|\\", "ǁ"), + ("|\|", "‖"), + ("|\\", "ǀ"), + ("|", "|"), + ("=\\", "ǂ"), + ("-\\", "‿"), +) diff --git a/packages/preview/ascii-ipa/1.1.1/test/test.typ b/packages/preview/ascii-ipa/1.1.1/test/test.typ new file mode 100644 index 0000000000..f35128666e --- /dev/null +++ b/packages/preview/ascii-ipa/1.1.1/test/test.typ @@ -0,0 +1,105 @@ +#import "../ascii-ipa.typ": * + +#let run-tests = (tests, translator, name) => { + for test in tests { + assert( + translator(test.at(0)) == test.at(1), + message: name + ": " + test.at(0) + " -> " + test.at(1) + ) + assert( + translator(test.at(1), reverse: true) == test.at(0), + message: name + " " + test.at(1) + " -> " + test.at(0) + ) + } +} + +#let xsampa-tests = ( + ("Ii:Uu:O:eE:@3:Q{VA:", "ɪiːʊuːɔːeɛːəɜːɒæʌɑː"), + ("mnN", "mnŋ"), + ("pttSkbddZg", "pttʃkbddʒɡ"), + ("fTsSxvDzZh", "fθsʃxvðzʒh"), + ("lrjw", "lrjw"), + ("i1ueoa", "iɨueoa"), + ("mm_jnn_j", "mmʲnnʲ"), + ("pp_jtt_jkk_jbb_jdd_jgg_j", "ppʲttʲkkʲbbʲddʲɡɡʲ"), + ("tsts_jts\\", "tstsʲtɕ"), + ("ff_jss_js`s\\:xx_jvv_jzz_jz`z\\:G", "ffʲssʲʂɕːxxʲvvʲzzʲʐʑːɣ"), + ("5l_jj", "ɫlʲj"), + ("r_jr", "rʲr"), + ("iui:u:aa:awaj", "iuiːuːaaːawaj"), + ("ptt_?\\kq?bdd_?\\dZg", "pttˤkqʔbddˤdʒɡ"), + ("fTss_?\\SxXX\\hvDzD_?\\z_?\\GR?\\", "fθssˤʃxχħhvðzðˤzˤɣʁʕ"), + ("mn", "mn"), + ("r", "r"), + ("l5jw", "lɫjw"), + ("E@`pO@`t", "ɛɚpɔɚt"), +) + +#let praat-tests = ( + ("\\ici\\:f\\hsu\\:f\\ct\\:fe\\ef\\:f\\sw", "ɪiːʊuːɔːeɛːə"), + ("\\er\\:f\\ab\\ae\\vt\\as\\:f", "ɜːɒæʌɑː"), + ("mn\\ng", "mnŋ"), + ("ptt\\shkbdd\\zh\\gs", "pttʃkbddʒɡ"), + ("f\\tfs\\shxv\\dhz\\zhh", "fθsʃxvðzʒh"), + ("lrjw", "lrjw"), + ("i\\i-ueoa", "iɨueoa"), + ("mm\\^jnn\\^j", "mmʲnnʲ"), + ("pp\\^jtt\\^jkk\\^jbb\\^jdd\\^j\\gs\\gs\\^j", "ppʲttʲkkʲbbʲddʲɡɡʲ"), + ("tsts\\^jt\\cc", "tstsʲtɕ"), + ("ff\\^jss\\^j\\s.\\cc\\:fxx\\^jvv\\^j", "ffʲssʲʂɕːxxʲvvʲ"), + ("zz\\^j\\z.\\zc\\:f\\gf", "zzʲʐʑːɣ"), + ("\\l~l\\^jj", "ɫlʲj"), + ("r\\^jr", "rʲr"), + ("iui\\:fu\\:faa\\:fawaj", "iuiːuːaaːawaj"), + ("ptt\\^9kq\\?gbdd\\^9d\\zh\\gs", "pttˁkqʔbddˁdʒɡ"), + ("f\\tfss\\^9\\shx\\cf\\h-hv\\dh", "fθssˁʃxχħhvð"), + ("z\\dh\\^9z\\^9\\gf\\ri\\9e", "zðˁzˁɣʁʕ"), + ("mn", "mn"), + ("r", "r"), + ("l\\l~jw", "lɫjw"), +) + +#let branner-tests = ( + ("Ii:Uu:c&:eE:@E&:a\"&ae)v&a\":", "ɪiːʊuːɔːeɛːəɜːɒæʌɑː"), + ("mnng)", "mnŋ"), + ("pttSkbdd3\"g", "pttʃkbddʒɡ"), + ("fO-sSxvd-z3\"h", "fθsʃxvðzʒh"), + ("lrjw", "lrjw"), ("ii-ueoa", "iɨueoa"), + ("mmj^nnj^", "mmʲnnʲ"), + ("ppj^ttj^kkj^bbj^ddj^ggj^", "ppʲttʲkkʲbbʲddʲɡɡʲ"), + ("tstsj^tci)", "tstsʲtɕ"), + ("ffj^ssj^sr)ci):xxj^vvj^zzj^zr)zi):g\"", "ffʲssʲʂɕːxxʲvvʲzzʲʐʑːɣ"), + ("l~)lj^j", "ɫlʲj"), + ("rj^r", "rʲr"), ("iui:u:aa:awaj", "iuiːuːaaːawaj"), + ("ptt&g^kq?bdd&g^d3\"g", "pttˤkqʔbddˤdʒɡ"), + ("fO-ss&g^SxXh-hvd-zd-&g^z&g^g\"R%?&", "fθssˤʃxχħhvðzðˤzˤɣʁʕ"), + ("mn", "mn"), + ("r", "r"), + ("ll~)jw", "lɫjw"), +) + +#let sil-tests = ( + ("i=i:u:o=aa=:", "ɪiːʊuːɔːeɛːəɜːɒæʌɑː"), + ("mnn>", "mnŋ"), + ("ptts=kbddz=g<", "pttʃkbddʒɡ"), + ("ft=ss=xvd=zz=h", "fθsʃxvðzʒh"), + ("lrjw", "lrjw"), + ("iI=ueoa", "iɨueoa"), + ("mmj^nnj^", "mmʲnnʲ"), + ("ppj^ttj^kkj^bbj^ddj^g:g=", "ffʲssʲʂɕːxxʲvvʲzzʲʐʑːɣ"), + ("l~~lj^j", "ɫlʲj"), + ("rj^r", "rʲr"), + ("iui:u:aa:awaj", "iuiːuːaaːawaj"), + ("ptt?<^kq?=bdd?<^dz=g<", "pttˤkqʔbddˤdʒɡ"), + ("ft=ss?<^s=xx=h>hvd=zd=?<^z?<^g=R>?<", "fθssˤʃxχħhvðzðˤzˤɣʁʕ"), + ("mn", "mn"), + ("r", "r"), + ("ll~~jw", "lɫjw"), +) + +#run-tests(branner-tests, branner, "Branner") +#run-tests(praat-tests, praat, "Praat") +#run-tests(sil-tests, sil, "SIL") +#run-tests(xsampa-tests, xsampa, "X-SAMPA") diff --git a/packages/preview/ascii-ipa/1.1.1/typst.toml b/packages/preview/ascii-ipa/1.1.1/typst.toml new file mode 100644 index 0000000000..5b53980bbf --- /dev/null +++ b/packages/preview/ascii-ipa/1.1.1/typst.toml @@ -0,0 +1,11 @@ +[package] +name = "ascii-ipa" +version = "1.1.1" +entrypoint = "ascii-ipa.typ" +authors = ["imatpot"] +license = "MIT" +description = "Converter for ASCII representations of the International Phonetic Alphabet (IPA)" +repository = "https://github.com/imatpot/typst-packages" +keywords = ["ascii", "ipa", "linguistics", "phonetics", "phonology", "branner", "praat", "sil", "x-sampa", "xsampa"] +compiler = "0.7.0" +exclude = ["test"]