+ (with-current-buffer "Statistics Output"
+ (insert (format "%s,%s,%s,0,0,%s,%s,%s,%s,%s,QUAN-L2,segmented,aux,level,subject,yearofclil,month\n" personid episodenumber duration role context demand asunitspersecondl2 asunitspersecondl1)))
+ (princ (format "L2(Asunits/second): %s, L2(clauses/Asunit): %s, L2(errors/Asunit):%s, L1(Asunits/second): %s\n"
+ asunitspersecondl2 clausesperasunitl2 errorsperasunitl2 asunitspersecondl1))
+ (princ (format "Functions/unit: Initiating: %s, Responding: %s, Control: %s, Expressive: %s, Interpersonal: %s" initiatingperasunitl2 respondingperasunitl2 controlperasunitl2 expressiveperasunitl2 interpersonalperasunitl2)))))
+
+(defun transcribe-analyze-all ()
+ "Analyze all file and output to 'Statistics Output' buffer. The buffer will
+ lost all previous data. The data in the buffer can be saved to a file and be
+ passed to 'R' for statistical analysis."
+ (interactive)
+ (let* ((xml (xml-parse-region (point-min) (point-max)))
+ (results (car xml))
+ (episodes (xml-get-children results 'episode)))
+
+ (with-current-buffer "Statistics Output"
+ (erase-buffer)
+ (insert "person,episode,duration,C-UNITS(L2),C-UNITS(L1),role,context,demand,QUAN-L2,QUAN-L1,QUAL-L2,segmented,aux,level,subjects,yearofCLIL,month\n"))
+ (dolist (episode episodes)
+ (let* ((numbernode (xml-get-children episode 'number))
+ (participantsnode (xml-get-children episode 'participants))
+ ;; (transcription (xml-get-children episode 'transcription))
+ (number (nth 2 (car numbernode)))
+ (participantsstring (nth 2 (car participantsnode)))
+ (participants (split-string participantsstring)))
+
+ (dolist (participant participants)
+ (transcribe-analyze number participant))))))
+