From 757ac2ea2d581cc2c04f8d0170e9c0f8a206ac26 Mon Sep 17 00:00:00 2001 From: Phuntsok Drak-pa Date: Sun, 15 Sep 2019 03:58:20 +0200 Subject: [PATCH] =?UTF-8?q?added=20function=20to=20get=20phonetics=20from?= =?UTF-8?q?=20=C5=87yqy=20text?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- funcs.el | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/funcs.el b/funcs.el index 0bd981e..16fc55a 100644 --- a/funcs.el +++ b/funcs.el @@ -214,3 +214,91 @@ runes during org-mode export" (conlanging//replace-string-by-char text conlanging//eittlanda-latin-to-latex) "}") (conlanging//replace-string-by-char text conlanging//eittlanda-latin-to-runes))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ; Ňyqy ; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +(setq conlanging//nyqy-phonetics '(("q" t t "q" "ħ") + ("g" t t "ɢ" "ʢ") + ("ň" t t "ɴ" "m") + ("c" t t "t͡ʃ" "ɬ") + ("j" t t "d͡ʒ" "ɮ") + ("w" t t "w" "l") + ("p" t nil "p" "χ") + ("b" t nil "b" "ʁ") + ("m" t nil "m" "ʀ") + ("n" t nil "n" "j") + ("s" t nil "s" "x") + ("z" t nil "z" "ɣ") + ("y" nil nil "y") + ("ú" nil nil "u") + ("i" nil nil "ɪ") + ("u" nil nil "ʊ") + ("é" nil nil "e") + ("ó" nil nil "o") + ("e" nil nil "ɛ") + ("o" nil nil "ɔ") + (" " nil nil " ") + ("," nil nil " ") + (";" nil nil " ") + ("." nil nil " "))) + +(defun conlanging//is-consonant (elem) + (nth 1 elem)) + +(defun conlanging//is-dorsal (elem) + (nth 2 elem)) + +(defun conlanging//nyqy-get-phoneme (consonant phon need-dorsal) + (let* ((is-dorsal (nth 1 phon))) + (nth (if (or (eq need-dorsal 2) (not consonant)) 3 + (if (eq is-dorsal need-dorsal) 3 4)) + phon))) + +(defun conlanging//find-elem-in-list (elem list) + "In a list containing lists, returns the element of `list' +whose first element equals `elem'" + (if list + (if (string= (caar list) + elem) + (car list) + (conlanging//find-elem-in-list elem + (cdr list))) + nil)) + +(defun conlanging//nyqy-convert (text phonetics need-dorsal) + " +need-dorsal: initial = 2, sinon t ou nil +" + (if (null text) + (mapconcat 'identity phonetics "") + (let* ((curr-char (car text)) + (curr-phon-list (conlanging//find-elem-in-list curr-char conlanging//nyqy-phonetics)) + (consonant (conlanging//is-consonant curr-phon-list)) + (dorsal (conlanging//is-dorsal curr-phon-list)) + (phon (conlanging//nyqy-get-phoneme consonant curr-phon-list need-dorsal))) + (if (eq need-dorsal 2) + (setq need-dorsal dorsal)) + (conlanging//nyqy-convert (cdr text) + (append phonetics + (list phon)) + (if consonant + (not need-dorsal) + need-dorsal))))) + +(defun conlanging/nyqy-to-phonetics (text) + "Adds to Ňyqy text its phonetics equivalent, either as a +tooltip in HTML or as plain text appended in LaTeX. + +Arguments: +- text: text to convert to phonetics" + (interactive) + (setq-local phonetics + (conlanging//nyqy-convert (split-string text "" t) + () + 2)) + (if (org-export-derived-backend-p org-export-current-backend + 'latex) + (concat text " /" phonetics "/") + (concat text " /" + phonetics "/")))