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 ;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
(setq conlanging//nyqy-phonetics '(("q" t t "q" "ħ")
|
||||
(defvar 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 "ø")
|
||||
("ó" nil nil "ɤ")
|
||||
("e" nil nil "ɛ")
|
||||
("o" nil nil "ɔ")
|
||||
(" " nil nil " ")
|
||||
("," nil nil " ")
|
||||
(";" nil nil " ")
|
||||
("." nil nil " ")))
|
||||
("p" t nil "χ" "p")
|
||||
("b" t nil "ʁ" "b")
|
||||
("m" t nil "ʀ" "m")
|
||||
("n" t nil "j" "n")
|
||||
("s" t nil "x" "s")
|
||||
("z" t nil "ɣ" "z")
|
||||
("y" nil "y")
|
||||
("ú" nil "u")
|
||||
("i" nil "ɪ")
|
||||
("u" nil "ʊ")
|
||||
("é" nil "ø")
|
||||
("ó" nil "ɤ")
|
||||
("e" nil "ɛ")
|
||||
("o" 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)
|
||||
(nth 1 elem))
|
||||
@ -313,55 +324,71 @@ runes during org-mode export"
|
||||
(defun conlanging//nyqy-is-dorsal (elem)
|
||||
(nth 2 elem))
|
||||
|
||||
(defun conlanging//nyqy-get-phoneme (consonant phon need-dorsal is-dorsal)
|
||||
(nth (if (or (eq need-dorsal 2)
|
||||
(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.
|
||||
(defun conlanging//nyqy-get-phoneme (phoneme &optional is-consonant is-dorsal)
|
||||
"Extracts a phoneme from `phoneme'.
|
||||
|
||||
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)
|
||||
(setq-local phonetics
|
||||
(conlanging//nyqy-convert (split-string (downcase text)
|
||||
(cond
|
||||
((eq nil phonetics) ;; first call to the function
|
||||
(conlanging/nyqy-to-phonetics text
|
||||
(split-string (downcase text)
|
||||
""
|
||||
t)
|
||||
()
|
||||
2))
|
||||
(concat "@@html:<span class=\"tooltip\"><i>"
|
||||
""))
|
||||
((eq nil nyqy) ;; no more to convert
|
||||
(progn
|
||||
(format (concat "@@html:<span class=\"tooltip\"><i>%s</i><span class=\"tooltiptext\">/%s/</span></span>@@"
|
||||
"@@latex:\\textit{%s} (/%s/)@@")
|
||||
text
|
||||
"</i><span class=\"tooltiptext\"> /"
|
||||
phonetics
|
||||
"/</span></span>@@@@latex:\\textit{"
|
||||
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