added function to get phonetics from Ňyqy text

This commit is contained in:
Phuntsok Drak-pa 2019-09-15 03:58:20 +02:00
parent 8fa7818b70
commit 757ac2ea2d

View File

@ -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 " <span class=\"tooltip\">/"
phonetics "/</span>")))