diff --git a/funcs.el b/funcs.el index 6964521..0a48345 100644 --- a/funcs.el +++ b/funcs.el @@ -43,15 +43,15 @@ Arguments: (concat (conlanging//declare-node (car tree) current-generation) (conlanging//make-link previous-generation current-generation) (conlanging//tree-to-dot-helper (cdr tree) - (+ 1 (* 10 current-generation)) - current-generation))) + (+ 1 (* 10 current-generation)) + current-generation))) ((listp (car tree)) ;; '(() () ()) (concat (conlanging//tree-to-dot-helper (car tree) ;; child of current node - current-generation - previous-generation) + current-generation + previous-generation) (conlanging//tree-to-dot-helper (cdr tree) - (+ 1 current-generation) - previous-generation))))) + (+ 1 current-generation) + previous-generation))))) (defun conlanging/tree-to-dot (tree) "Returns a graphviz’s dot compatible string representing an Elisp tree" @@ -282,30 +282,41 @@ runes during org-mode export" ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Ñ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 "ø") - ("ó" nil nil "ɤ") - ("e" nil nil "ɛ") - ("o" nil nil "ɔ") - (" " nil nil " ") - ("," nil nil " ") - (";" nil nil " ") - ("." nil nil " "))) +(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 "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) - "" - t) - () - 2)) - (concat "@@html:" - text - " /" - phonetics - "/@@@@latex:\\textit{" - text - "} (/" - phonetics - "/)@@")) + (cond + ((eq nil phonetics) ;; first call to the function + (conlanging/nyqy-to-phonetics text + (split-string (downcase text) + "" + t) + "")) + ((eq nil nyqy) ;; no more to convert + (progn + (format (concat "@@html:%s/%s/@@" + "@@latex:\\textit{%s} (/%s/)@@") + text + phonetics + text + 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))))))