From: David Gonzalez Gandara Date: Sun, 13 Dec 2015 21:35:24 +0000 (+0100) Subject: /transcribe/transcribe.el: Add some functions, fix bugs X-Git-Url: https://code.delx.au/gnu-emacs-elpa/commitdiff_plain/979b09b2dec589220689a9e29bfd57b4b1c6a04d /transcribe/transcribe.el: Add some functions, fix bugs --- diff --git a/packages/transcribe/transcribe.el b/packages/transcribe/transcribe.el index 679727af9..684e505aa 100644 --- a/packages/transcribe/transcribe.el +++ b/packages/transcribe/transcribe.el @@ -41,7 +41,7 @@ ;; on the language used by the person. The attributes expected are the ;; number of clauses that form the utterance, the number of errors the ;; transcriber observes, and the function of the speech act. The parser will -;; even if some attributes are missing. +;; work even if some attributes are missing. ;; ;; ;; AUDIO COMMANDS @@ -56,29 +56,22 @@ ;; ;; XML TAGGING COMMANDS ;; -------------------------------------------------- -;; C-x C-n --> Create new episode structure. This is useful in case your -;; xml file structure requires it. You can customize the text -;; inserted manipulating the realted function. -;; -----> Interactively insert a function attribute in a speech act +;; C-x C-n ------> Create new episode structure. This is useful in case your +;; xml file structure requires it. +;; ---------> Interactively insert a function attribute in a speech act ;; (l1 or l2) tag. -;; -----> Interactively insert a move attribute in a turn (person) tag -;; -----> Interactively insert an attribute (any kind) -;; -----> Interactively insert new tag. You will be prompted for the -;; content of the tag. The starting tag and the end tag will be -;; inserted automatically and the cursor placed in the proper -;; place to type. +;; ---------> Interactively insert a move attribute in a turn (person) tag +;; ---------> Interactively insert an attribute (any kind) +;; ---------> Insert turn (person) tag. Inserts a move attribute. +;; --------> Insert a custom tag. Edit the function to adapt to your needs. +;; --------> Insert speech act tag in L1, with clauses, errors and function +;; attributes. +;; --------> Insert speech act tag in L2, with clauses, errors and function +;; attributes. ;; -;; -;; -;; SPECIFIC COMMANDS I USE, THAT YOU MAY FIND USEFUL -;; ------------------------------------------------ +;; AUTOMATIC PARSING +;; ----------------------------------------------------- ;; C-x C-a ------> Analyses the text for measurments of performance. -;; --------> Customised tag 1. Edit the function to adapt to your needs. -;; --------> Customised tag 2. Edit the function to adapt to your needs. -;; ---------> Break tag. This command "breaks" a tag in two, that is -;; it inserts an ending tag and then a starting tag. -;; ---------> Insert atributes. This function insert custom xml attributes. -;; Edit the function to suit you needs. ;;; Code: @@ -100,7 +93,7 @@ (defvar transcribe-function-list '("initiating" "responding" "control" "expresive" "interpersonal")) (defvar transcribe-move-list '("initiation" "response" "follow-up")) -(defvar transcribe-attribute-list (append '("clauses" "errors") transcribe-function-list transcribe-move-list)) +(defvar transcribe-attribute-list '("clauses" "errors" "function" "move")) ;(append transcribe-attribute-list transcribe-function-list transcribe-move-list) (defun transcribe-analyze-episode (episode person) @@ -180,13 +173,30 @@ (princ (format "L2(Asunits/second): %s, L2(clauses/Asunit): %s, L1(Asunits/second): %s" asunitspersecondl2 clausesperasunitl2 asunitspersecondl1))))) -(defun transcribe-define-xml-tag (xmltag) - "This function allows the automatic insetion of a xml tag and places the cursor." +(defun transcribe-xml-tag-person (xmltag) + "This function allows the automatic insetion of a speaker xml tag and places the cursor." + (interactive "stag:") + (insert (format "<%s move=\"\">" xmltag xmltag)) + (backward-char 3) + (backward-char (string-width xmltag))) + +(defun transcribe-xml-tag (xmltag) + "This function allows the automatic insetion of a custom xml tag and places the cursor." (interactive "stag:") (insert (format "<%s>" xmltag xmltag)) (backward-char 3) (backward-char (string-width xmltag))) +(defun transcribe-region-xml-tag (xmltag) + "This function encapsulates the marked region in the given tag." + (interactive "stag:") + (let ((beginning (region-beginning)) + (end (region-end))) + (goto-char beginning) + (insert (format "<%s>" xmltag)) + (goto-char end) + (insert (format "" xmltag)))) + (defun transcribe-add-attribute (att val) "Adds a xml attribute at cursor with the name and value specified (autocompletion possible)" (interactive (list(completing-read "attibute name:" transcribe-attribute-list)(read-string "value:"))) @@ -205,19 +215,19 @@ (defun transcribe-xml-tag-l1 () "Inserts a l1 tag and places the cursor" (interactive) - (insert "") - (backward-char 3) - (backward-char 2)) + (insert "") + (backward-char 5)) (defun transcribe-xml-tag-l2 () "Inserts a l2 tag and places the cursor" (interactive) - (insert "") - (backward-char 3) - (backward-char 2)) + (insert "") + (backward-char 5)) -(fset 'transcribe-xml-tag-l2-break "") - ;inserts a break inside a l2 tag +(defun transcribe-xml-tag-break (xmltag) + "This function breaks an unit into two. That is, insert a closing and an opening equal tags" + (interactive "stag:") + (insert (format "<%s clauses=\"1\" errors=\"0\" function=\"\">" xmltag xmltag))) (defun transcribe-display-audio-info () (interactive) @@ -239,14 +249,16 @@ ([?\C-x down] . emms-stop) ([?\C-x right] . emms-seek-forward) ([?\C-x left] . emms-seek-backward) + ([f2] . transcribe-add-attribute-function) ([f3] . transcribe-add-attribute-move) - ([f4] . transcribe-add-atribute) + ([f4] . transcribe-add-attribute) + ([f5] . emms-pause) - ([f6] . transcribe-define-xml-tag) - ([f7] . transcribe-xml-tag-l2-break) ([f8] . emms-seek) + ([f9] . transcribe-xml-tag) + ([f10] . transcribe-xml-tag-person) ([f11] . transcribe-xml-tag-l1) ([f12] . transcribe-xml-tag-l2)) )