| 1 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 2 |
;;; Lexicon, LTS and Postlexical rules for upc_catalan |
| 3 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 4 |
;;; Adapted for Catalan by the UPC team |
| 5 |
;;; |
| 6 |
;;; (c) Antonio Bonafonte |
| 7 |
;;; Universitat Politècnica de Catalunya, Barcelona, Spain |
| 8 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 9 |
|
| 10 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 11 |
;;; |
| 12 |
;;; Syllabification Test |
| 13 |
;;; |
| 14 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 15 |
|
| 16 |
(define (upc_ca_test_syl file) |
| 17 |
(let ((fd (fopen file "r")) (w 0) (c 0) (entry) (wordlex) (wordlts)) |
| 18 |
(while (not (equal? (set! entry (readfp fd)) (eof-val))) |
| 19 |
(set! w (+ w 1)) |
| 20 |
(set! wordlex (car (cdr (cdr (lex.lookup entry))))) |
| 21 |
(set! wordlts (car (cdr (catala_trans entry)))) |
| 22 |
(if (equal? (upc_ca_compare_syl wordlex wordlts) 0) |
| 23 |
(format t "PARAULA ERRÒNIA: %s LEX: %l LTS: %l\n" entry wordlex wordlts) |
| 24 |
(set! c (+ c 1))) |
| 25 |
) |
| 26 |
|
| 27 |
(format t "PARAULES TOTALS: %d ENCERTS %d (%2.2f)\n" w c (/ (* c 100) w)) |
| 28 |
(fclose fd) |
| 29 |
)) |
| 30 |
|
| 31 |
|
| 32 |
(define (upc_ca_test_nolts_syl filelts filewords) |
| 33 |
(let ((fd (fopen filewords "r")) (fs (fopen filelts "r")) (w 0) (c 0) (entry) (wordlex) (wordlts)) |
| 34 |
(while (not (equal? (set! entry_word (readfp fd)) (eof-val))) |
| 35 |
(set! entry_phones (readfp fs)) |
| 36 |
(set! w (+ w 1)) |
| 37 |
(set! wordlex (car (cdr (cdr (lex.lookup entry_word))))) |
| 38 |
(set! wordlts (car (cdr (catala_trans2 entry_word entry_phones)))) |
| 39 |
(if (equal? (upc_ca_compare_syl wordlex wordlts) 0) |
| 40 |
(format t "PARAULA ERRÒNIA: %s LEX: %l LTS: %l\n" entry_word wordlex wordlts) |
| 41 |
(set! c (+ c 1))) |
| 42 |
) |
| 43 |
|
| 44 |
(format t "PARAULES TOTALS: %d ENCERTS %d (%2.2f)\n" w c (/ (* c 100) w)) |
| 45 |
(fclose fd) |
| 46 |
(fclose fs) |
| 47 |
)) |
| 48 |
|
| 49 |
(define (upc_ca_test_auto_syl filelts filewords) |
| 50 |
(let ((fd (fopen filewords "r")) (fs (fopen filelts "r")) (w 0) (c 0) (entry) (wordlex) (wordlts)) |
| 51 |
(while (not (equal? (set! entry_word (readfp fd)) (eof-val))) |
| 52 |
(set! entry_phones (readfp fs)) |
| 53 |
(set! w (+ w 1)) |
| 54 |
(set! wordlex (car (cdr (cdr (lex.lookup entry_word))))) |
| 55 |
(set! wordlts (car (cdr (catala_trans3_festival entry_word entry_phones)))) |
| 56 |
(if (equal? (upc_ca_compare_syl wordlex wordlts) 0) |
| 57 |
(format t "PARAULA ERRÒNIA: %s LEX: %l LTS: %l\n" entry_word wordlex wordlts) |
| 58 |
(set! c (+ c 1))) |
| 59 |
) |
| 60 |
|
| 61 |
(format t "TEST AMB SIL·LABIFICACIÓ AUTOMÀTICA \n PARAULES TOTALS: %d ENCERTS %d (%2.2f)\n" w c (/ (* c 100) w)) |
| 62 |
(fclose fd) |
| 63 |
(fclose fs) |
| 64 |
)) |
| 65 |
|
| 66 |
(define (upc_ca_test_auto_syl_with_lts file) |
| 67 |
(let ((fd (fopen file "r")) (w 0) (c 0) (entry) (wordlex) (wordlts)) |
| 68 |
(while (not (equal? (set! entry (readfp fd)) (eof-val))) |
| 69 |
(set! w (+ w 1)) |
| 70 |
(set! wordlex (car (cdr (cdr (lex.lookup entry))))) |
| 71 |
(set! wordlts (car (cdr (catala_trans4 entry)))) |
| 72 |
(if (equal? (upc_ca_compare_syl wordlex wordlts) 0) |
| 73 |
(format t "PARAULA ERRÒNIA: %s LEX: %l LTS: %l\n" entry wordlex wordlts) |
| 74 |
(set! c (+ c 1))) |
| 75 |
) |
| 76 |
|
| 77 |
(format t "TEST AMB SIL·LABIFICACIÓ AUTOMÀTICA I APLICANT LTS \n PARAULES TOTALS: %d ENCERTS %d (%2.2f)\n" w c (/ (* c 100) w)) |
| 78 |
(fclose fd) |
| 79 |
)) |
| 80 |
|
| 81 |
|
| 82 |
(define (count_items lista) |
| 83 |
(let ((i 20)) |
| 84 |
(while (equal? (nth i lista) nil) |
| 85 |
(set! i (- i 1))) |
| 86 |
(set! i (+ i 1)) |
| 87 |
i)) |
| 88 |
|
| 89 |
(define (upc_ca_compare_syl wordlex wordlts) |
| 90 |
(cond |
| 91 |
((equal? (count_items wordlex) (count_items wordlts)) |
| 92 |
(set! num (count_items wordlex)) |
| 93 |
(set! equal 1) |
| 94 |
(set! num (- num 1)) |
| 95 |
(while (equal? num -1) |
| 96 |
(set! syla (car (nth num wordlex))) |
| 97 |
(set! sylb (car (nth num wordlts))) |
| 98 |
(if (not (equal? (count_items syla) (count_items sylb))) |
| 99 |
(set! equal 0)) |
| 100 |
(set! num (- num 1))) |
| 101 |
equal) |
| 102 |
(t |
| 103 |
0))) |
| 104 |
|
| 105 |
(define (upc_catalan_add_ruleset_correct_LTS) |
| 106 |
"(upc_catalan_add_ruleset_correct_LTS) |
| 107 |
Loads into the current lexicon a ruleset. |
| 108 |
I believe it may be used in syllabification, or maybe is just obsolete code." |
| 109 |
(lts.ruleset |
| 110 |
upc_ca_correct_LTS |
| 111 |
( ) |
| 112 |
( |
| 113 |
|
| 114 |
( E1 [ j ] ax = j ) |
| 115 |
( ax [ j ] E1 = j ) |
| 116 |
( ax [ j ] e1 = j ) |
| 117 |
( u1 [ j ] ax = j ) |
| 118 |
( [ j ] = i ) |
| 119 |
|
| 120 |
( [ b ] = b ) |
| 121 |
( [ z ] = z ) |
| 122 |
( [ d ] = d ) |
| 123 |
( [ f ] = f ) |
| 124 |
( [ g ] = g ) |
| 125 |
( [ S ] = S ) |
| 126 |
( [ k ] = k ) |
| 127 |
( [ l ] = l ) |
| 128 |
( [ Z ] = Z ) |
| 129 |
( [ m ] = m ) |
| 130 |
( [ n ] = n ) |
| 131 |
( [ J ] = J ) |
| 132 |
( [ p ] = p ) |
| 133 |
( [ r ] = r ) |
| 134 |
( [ rr ] = rr ) |
| 135 |
( [ s ] = s ) |
| 136 |
( [ t ] = t ) |
| 137 |
( [ L ] = L ) |
| 138 |
( [ j ] = j ) |
| 139 |
( [ w ] = w ) |
| 140 |
( [ j ] = j ) |
| 141 |
|
| 142 |
( [ a1 ] = a1 ) |
| 143 |
( [ a ] = a ) |
| 144 |
( [ E1 ] = E1 ) |
| 145 |
( [ E ] = E ) |
| 146 |
( [ e1 ] = e1 ) |
| 147 |
( [ e ] = e ) |
| 148 |
( [ i1 ] = i1 ) |
| 149 |
( [ i ] = i ) |
| 150 |
( [ O1 ] = O1 ) |
| 151 |
( [ O ] = O ) |
| 152 |
( [ o1 ] = o1 ) |
| 153 |
( [ o ] = o ) |
| 154 |
( [ u1 ] = u1 ) |
| 155 |
( [ u ] = u ) |
| 156 |
( [ ax ] = ax ) |
| 157 |
)) |
| 158 |
|
| 159 |
) |
| 160 |
|
| 161 |
(provide 'upclex_syl) |