| 1 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 2 |
;;; ;;; |
| 3 |
;;; Language Technologies Institute ;;; |
| 4 |
;;; Carnegie Mellon University ;;; |
| 5 |
;;; Copyright (c) 2000 ;;; |
| 6 |
;;; All Rights Reserved. ;;; |
| 7 |
;;; ;;; |
| 8 |
;;; Permission is hereby granted, free of charge, to use and distribute ;;; |
| 9 |
;;; this software and its documentation without restriction, including ;;; |
| 10 |
;;; without limitation the rights to use, copy, modify, merge, publish, ;;; |
| 11 |
;;; distribute, sublicense, and/or sell copies of this work, and to ;;; |
| 12 |
;;; permit persons to whom this work is furnished to do so, subject to ;;; |
| 13 |
;;; the following conditions: ;;; |
| 14 |
;;; 1. The code must retain the above copyright notice, this list of ;;; |
| 15 |
;;; conditions and the following disclaimer. ;;; |
| 16 |
;;; 2. Any modifications must be clearly marked as such. ;;; |
| 17 |
;;; 3. Original authors' names are not deleted. ;;; |
| 18 |
;;; 4. The authors' names are not used to endorse or promote products ;;; |
| 19 |
;;; derived from this software without specific prior written ;;; |
| 20 |
;;; permission. ;;; |
| 21 |
;;; ;;; |
| 22 |
;;; CARNEGIE MELLON UNIVERSITY AND THE CONTRIBUTORS TO THIS WORK ;;; |
| 23 |
;;; DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ;;; |
| 24 |
;;; ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT ;;; |
| 25 |
;;; SHALL CARNEGIE MELLON UNIVERSITY NOR THE CONTRIBUTORS BE LIABLE ;;; |
| 26 |
;;; FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ;;; |
| 27 |
;;; WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN ;;; |
| 28 |
;;; AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ;;; |
| 29 |
;;; ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF ;;; |
| 30 |
;;; THIS SOFTWARE. ;;; |
| 31 |
;;; ;;; |
| 32 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 33 |
;;; Author: Alan W Black ([email protected]) ;;; |
| 34 |
;;; Date: January 2001 ;;; |
| 35 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 36 |
;;; ;;; |
| 37 |
;;; Convert the LT models to C ;;; |
| 38 |
;;; ;;; |
| 39 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 40 |
|
| 41 |
|
| 42 |
(define (f0lrtoC name start mid end odir) |
| 43 |
"(f0lrtoC name start mid endn odir) |
| 44 |
Coverts a f0lr models to a single C fstructure in ODIR/NAME_f0lr.c. As |
| 45 |
there is only one model like this (f2b) this is really only |
| 46 |
one off. and the result is included in another file so this doesn't |
| 47 |
add the headers defs etc just the const initializations" |
| 48 |
(let |
| 49 |
((ofdc (fopen (path-append odir (string-append name "_f0lr.c")) "w"))) |
| 50 |
|
| 51 |
(format ofdc "\n") |
| 52 |
|
| 53 |
(format ofdc "const us_f0_lr_term f0_lr_terms[] = {\n") |
| 54 |
(while start |
| 55 |
(if (not (and (equal? (car (car start)) (car (car mid))) |
| 56 |
(equal? (car (car start)) (car (car end))))) |
| 57 |
(error "don't have the same features")) |
| 58 |
(if (or (not (car (cddr (car start)))) |
| 59 |
(member_string (car (car (cddr (car start)))) |
| 60 |
'("H*" "!H*" "*?" "L-L%" "L-H%" "H-" "!H-"))) |
| 61 |
;; ignore the terms that can never be 1 as cart doesn't predict them |
| 62 |
(begin |
| 63 |
(format ofdc " { \"%s\", %f, %f, %f, %s },\n" |
| 64 |
(car (car start)) |
| 65 |
(cadr (car start)) |
| 66 |
(cadr (car mid)) |
| 67 |
(cadr (car end)) |
| 68 |
(cond |
| 69 |
((not (car (caddr (car start)))) |
| 70 |
"0") |
| 71 |
((string-equal (car (caddr (car start))) "*?") |
| 72 |
"\"L+H*\"") |
| 73 |
((string-equal (car (caddr (car start))) "!H-") |
| 74 |
"\"H-H%\"") |
| 75 |
(t |
| 76 |
(format nil "\"%s\"" (car (caddr (car start))))))))) |
| 77 |
(set! start (cdr start)) |
| 78 |
(set! mid (cdr mid)) |
| 79 |
(set! end (cdr end))) |
| 80 |
|
| 81 |
(format ofdc " { 0, 0, 0, 0, 0 }\n") |
| 82 |
(format ofdc "};\n") |
| 83 |
|
| 84 |
(fclose ofdc))) |
| 85 |
|
| 86 |
(provide 'make_f0lr) |