Fixed issue with Ñyqy conversion function
Function used to ask for a mutated consonant if the initial word began with a vowel. Also merged helper function with original function.
This commit is contained in:
parent
89d053b722
commit
f65d603f8e
153
funcs.el
153
funcs.el
@ -282,30 +282,41 @@ runes during org-mode export"
|
|||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
; Ñyqy ;
|
; Ñyqy ;
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
(setq conlanging//nyqy-phonetics '(("q" t t "q" "ħ")
|
(defvar conlanging//nyqy-phonetics '(("q" t t "q" "ħ")
|
||||||
("g" t t "ɢ" "ʢ")
|
("g" t t "ɢ" "ʢ")
|
||||||
("ñ" t t "ɴ" "m")
|
("ñ" t t "ɴ" "m")
|
||||||
("c" t t "t͡ʃ" "ɬ")
|
("c" t t "t͡ʃ" "ɬ")
|
||||||
("j" t t "d͡ʒ" "ɮ")
|
("j" t t "d͡ʒ" "ɮ")
|
||||||
("w" t t "w" "l")
|
("w" t t "w" "l")
|
||||||
("p" t nil "p" "χ")
|
("p" t nil "χ" "p")
|
||||||
("b" t nil "b" "ʁ")
|
("b" t nil "ʁ" "b")
|
||||||
("m" t nil "m" "ʀ")
|
("m" t nil "ʀ" "m")
|
||||||
("n" t nil "n" "j")
|
("n" t nil "j" "n")
|
||||||
("s" t nil "s" "x")
|
("s" t nil "x" "s")
|
||||||
("z" t nil "z" "ɣ")
|
("z" t nil "ɣ" "z")
|
||||||
("y" nil nil "y")
|
("y" nil "y")
|
||||||
("ú" nil nil "u")
|
("ú" nil "u")
|
||||||
("i" nil nil "ɪ")
|
("i" nil "ɪ")
|
||||||
("u" nil nil "ʊ")
|
("u" nil "ʊ")
|
||||||
("é" nil nil "ø")
|
("é" nil "ø")
|
||||||
("ó" nil nil "ɤ")
|
("ó" nil "ɤ")
|
||||||
("e" nil nil "ɛ")
|
("e" nil "ɛ")
|
||||||
("o" nil nil "ɔ")
|
("o" nil "ɔ")
|
||||||
(" " nil nil " ")
|
(" " nil " ")
|
||||||
("," nil nil " ")
|
("," nil " ")
|
||||||
(";" nil nil " ")
|
(";" nil " ")
|
||||||
("." nil nil " ")))
|
("." nil " "))
|
||||||
|
"List of Ñyqy characters and their phonetics equivalent.
|
||||||
|
|
||||||
|
The first value is the translitteration of a sound in Ñyqy. The
|
||||||
|
second is whether or not it represents a consonant.
|
||||||
|
|
||||||
|
If it is a consonant, then the third value is whether it is a
|
||||||
|
dorsal consonant by default or not. Then we have the consonant's
|
||||||
|
dorsal prononciation and its non-dorsal pronunciation.
|
||||||
|
|
||||||
|
If it is not a consonant, then the third value is its
|
||||||
|
pronunciation already.")
|
||||||
|
|
||||||
(defun conlanging//nyqy-is-consonant (elem)
|
(defun conlanging//nyqy-is-consonant (elem)
|
||||||
(nth 1 elem))
|
(nth 1 elem))
|
||||||
@ -313,55 +324,71 @@ runes during org-mode export"
|
|||||||
(defun conlanging//nyqy-is-dorsal (elem)
|
(defun conlanging//nyqy-is-dorsal (elem)
|
||||||
(nth 2 elem))
|
(nth 2 elem))
|
||||||
|
|
||||||
(defun conlanging//nyqy-get-phoneme (consonant phon need-dorsal is-dorsal)
|
(defun conlanging//nyqy-get-phoneme (phoneme &optional is-consonant is-dorsal)
|
||||||
(nth (if (or (eq need-dorsal 2)
|
"Extracts a phoneme from `phoneme'.
|
||||||
(not consonant))
|
|
||||||
3
|
|
||||||
(if (eq is-dorsal need-dorsal)
|
|
||||||
3
|
|
||||||
4))
|
|
||||||
phon))
|
|
||||||
|
|
||||||
(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//nyqy-is-consonant curr-phon-list))
|
|
||||||
(dorsal (conlanging//nyqy-is-dorsal curr-phon-list))
|
|
||||||
(phon (conlanging//nyqy-get-phoneme consonant curr-phon-list
|
|
||||||
need-dorsal dorsal)))
|
|
||||||
(if (eq need-dorsal 2)
|
|
||||||
(setq-local 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:
|
Arguments:
|
||||||
- text: text to convert to phonetics"
|
- phoneme: array from `conlanging//nyqy-phonetics'
|
||||||
|
- is-consonant: whether `phoneme' represents a
|
||||||
|
consonant (default: nil)
|
||||||
|
- is-dorsal: whether `phoneme' should be a dorsal
|
||||||
|
consonant (default: nil)"
|
||||||
|
(if is-consonant
|
||||||
|
(if is-dorsal
|
||||||
|
(nth 3 phoneme)
|
||||||
|
(nth 4 phoneme))
|
||||||
|
(nth 2 phoneme)))
|
||||||
|
|
||||||
|
(defun conlanging/nyqy-to-phonetics (text &optional nyqy phonetics met-consonant
|
||||||
|
dorsal)
|
||||||
|
"Returns the phonetics equivalent of the Ñyqy `text', either as
|
||||||
|
a tooltip in HTML or plain text for LaTeX exports.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
- text: text to convert to phonetics
|
||||||
|
- nyqy: for internal use only, `text' argument but as a list of
|
||||||
|
characters
|
||||||
|
- phonetics: for internal use only, result phonetics, array
|
||||||
|
- met-consonant: for internal use only, `t' if a consonant has
|
||||||
|
been met previously, `nil' otherwise
|
||||||
|
- dorsal: for internal use only, `t' if the current consonant is
|
||||||
|
required to be dorsal, `nil' otherwise"
|
||||||
(interactive)
|
(interactive)
|
||||||
(setq-local phonetics
|
(cond
|
||||||
(conlanging//nyqy-convert (split-string (downcase text)
|
((eq nil phonetics) ;; first call to the function
|
||||||
|
(conlanging/nyqy-to-phonetics text
|
||||||
|
(split-string (downcase text)
|
||||||
""
|
""
|
||||||
t)
|
t)
|
||||||
()
|
""))
|
||||||
2))
|
((eq nil nyqy) ;; no more to convert
|
||||||
(concat "@@html:<span class=\"tooltip\"><i>"
|
(progn
|
||||||
|
(format (concat "@@html:<span class=\"tooltip\"><i>%s</i><span class=\"tooltiptext\">/%s/</span></span>@@"
|
||||||
|
"@@latex:\\textit{%s} (/%s/)@@")
|
||||||
text
|
text
|
||||||
"</i><span class=\"tooltiptext\"> /"
|
|
||||||
phonetics
|
phonetics
|
||||||
"/</span></span>@@@@latex:\\textit{"
|
|
||||||
text
|
text
|
||||||
"} (/"
|
phonetics)))
|
||||||
phonetics
|
(t (let* ((cur-char (car nyqy)) ;; default option
|
||||||
"/)@@"))
|
(cur-phon (seq-find (lambda (elt)
|
||||||
|
(string= (car elt)
|
||||||
|
cur-char))
|
||||||
|
conlanging//nyqy-phonetics))
|
||||||
|
(is-consonant (conlanging//nyqy-is-consonant cur-phon))
|
||||||
|
(dorsal (if (or met-consonant
|
||||||
|
(not is-consonant))
|
||||||
|
dorsal
|
||||||
|
(conlanging//nyqy-is-dorsal cur-phon))))
|
||||||
|
(if is-consonant
|
||||||
|
(conlanging/nyqy-to-phonetics text
|
||||||
|
(cdr nyqy)
|
||||||
|
(concat phonetics
|
||||||
|
(conlanging//nyqy-get-phoneme cur-phon t dorsal))
|
||||||
|
t
|
||||||
|
(not dorsal))
|
||||||
|
(conlanging/nyqy-to-phonetics text
|
||||||
|
(cdr nyqy)
|
||||||
|
(concat phonetics
|
||||||
|
(conlanging//nyqy-get-phoneme cur-phon nil))
|
||||||
|
met-consonant
|
||||||
|
dorsal))))))
|
||||||
|
Reference in New Issue
Block a user