/usr/share/festival/dicts/upc/upclex_catalan.scm is in festival-ca 3.0.6-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; ;;;
;;; Carnegie Mellon University ;;;
;;; and Alan W Black and Kevin Lenzo ;;;
;;; Copyright (c) 1998-2000 ;;;
;;; All Rights Reserved. ;;;
;;; ;;;
;;; Permission is hereby granted, free of charge, to use and distribute ;;;
;;; this software and its documentation without restriction, including ;;;
;;; without limitation the rights to use, copy, modify, merge, publish, ;;;
;;; distribute, sublicense, and/or sell copies of this work, and to ;;;
;;; permit persons to whom this work is furnished to do so, subject to ;;;
;;; the following conditions: ;;;
;;; 1. The code must retain the above copyright notice, this list of ;;;
;;; conditions and the following disclaimer. ;;;
;;; 2. Any modifications must be clearly marked as such. ;;;
;;; 3. Original authors' names are not deleted. ;;;
;;; 4. The authors' names are not used to endorse or promote products ;;;
;;; derived from this software without specific prior written ;;;
;;; permission. ;;;
;;; ;;;
;;; CARNEGIE MELLON UNIVERSITY AND THE CONTRIBUTORS TO THIS WORK ;;;
;;; DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ;;;
;;; ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT ;;;
;;; SHALL CARNEGIE MELLON UNIVERSITY NOR THE CONTRIBUTORS BE LIABLE ;;;
;;; FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ;;;
;;; WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN ;;;
;;; AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ;;;
;;; ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF ;;;
;;; THIS SOFTWARE. ;;;
;;; ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Lexicon, LTS and Postlexical rules for upc_catalan
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Adapted for Catalan by the UPC team
;;;
;;; (c) Antonio Bonafonte
;;; Universitat Politècnica de Catalunya, Barcelona, Spain
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defvar upclexdir (path-append lexdir "upc"))
(defvar upc_catalan::dialect "central") ; we need a default value. if it is already set then it will not be changed
(require 'lts)
; depend on dialect information
(require 'upclex_syl)
(require 'upclex_central)
(require 'upclex_valencia)
(require 'upclex_postlex)
(define (upc_catalan_lex_select_dialect dialect)
"(upc_catalan_lex_select_dialect dialect)
Sets the lexicon attributes depending on the dialect given"
(cond
( (string-equal dialect "central")
(require 'upclex_central)
(if (not (member_string "upc_catalan-central" (lex.list)))
(begin
(lex.create "upc_catalan-central")
(lex.set.compile.file (path-append upclexdir "upcdict_catalan-1.0-central.out"))
(lex.set.phoneset "upc_catalan-central")
(upc_catalan_add_ruleset_catala_downcase)
(upc_catalan_add_ruleset_catala_simplify_vowels)
(upc_catalan_add_ruleset_catala_simplify_vowels_lts)
(upclex_catalan_define_ruleset_syl_central)
(lex.set.lts.method 'upc_catalan_lts_function)
(upc_catalan_addenda)
(upc_catalan_addenda_central)
(require 'upc_catalan_lts_rules-central)
(set! upc_catalan::dialect "central")
)
(begin
(lex.select "upc_catalan-central")
(set! upc_catalan::dialect "central")
)
)
)
( (string-equal dialect "valencia")
(require 'upclex_valencia)
(if (not (member_string "upc_catalan-valencia" (lex.list)))
(begin
(lex.create "upc_catalan-valencia")
(lex.set.compile.file (path-append upclexdir "upcdict_catalan-1.0-valencia.out"))
(lex.set.phoneset "upc_catalan-valencia")
(upc_catalan_add_ruleset_catala_downcase)
(upc_catalan_add_ruleset_catala_simplify_vowels)
(upc_catalan_add_ruleset_catala_simplify_vowels_lts)
(upclex_catalan_define_ruleset_syl_valencia)
(lex.set.lts.method 'upc_catalan_lts_function)
(upc_catalan_addenda)
(upc_catalan_addenda_valencia)
(require 'upc_catalan_lts_rules-valencia)
(set! upc_catalan::dialect "valencia")
)
(begin
(lex.select "upc_catalan-valencia")
(set! upc_catalan::dialect "valencia")
)
)
)
)
)
(define (upc_catalan_select_lts_rules dialect)
"(upc_catalan_select_lts_rules dialect)
Sets the lexicon attributes depending on the dialect given"
(cond
( (string-equal dialect "central")
upc_catalan_lts_rules-central
)
( (string-equal dialect "valencia")
upc_catalan_lts_rules-valencia
)
)
)
;;; Function called when word not found in lexicon
;;; and you've trained letter to sound rules
(define (upc_catalan_lts_function word features)
"(upc_catalan_lts_function word features)
Return pronunciation of word not in lexicon."
; (format t "Word not found in lexicon: \"%s\"\n" word)
(let ((dcword) (syls) (phones))
(if (lts.in.alphabet word 'catala_downcase)
(begin
(set! dcword (apply string-append (lts.apply word 'catala_downcase)))
(set! dcword (lts.apply_if_exists dcword 'catala_simplify_vowels_lts))
(set! phones (lts_predict dcword (upc_catalan_select_lts_rules upc_catalan::dialect)))
(set! syl (lts.apply phones 'upc_catalan_syl)) ;; Handwritten rules for syllabification
;; (set! syls (upc_ca_lex_syllabify_phstress phones)) ;; Automatic rules for syllabification
(set! syls (upc_catalan_brackets syl))
)
(begin
(set! syls nil) ;If we can't downcase the word, there are strange chars. Play nothing and warn user.
(format t "upc_catalan_lts_function: Word ommitted: %s.\n" word)
)
)
(list word features syls)
)
)
(define (lts.apply_if_exists word ruleset)
"(lts.apply_if_exists)
Applies ruleset to word for the characters available in the ruleset.
Leave the rest characters as they are.
Not robust if the ruleset has rules, as context between characters is lost."
(let ( (symb (symbolexplode word) ) (current) (output "") )
(while (> (length symb) 0)
(set! current (car symb))
(set! symb (cdr symb))
(if (lts.in.alphabet current ruleset)
(set! output (string-append output (apply string-append (lts.apply current ruleset))))
(set! output (string-append output current))
)
)
output
)
)
(define (upc_catalan_addenda)
"(upc_catalan_addenda)
Basic lexicon should (must ?) have basic letters, symbols and punctuation."
;;; Words to be added in future versions:
; Currently prediction is bad for these words:
; <Empty (for now)>
;;; Common words on the internet
; gmail, hotmail, facebook
; ;;; Symbols ...
;; Basic punctuation must be in with nil pronunciation
(lex.add.entry '("." punc nil))
;(lex.add.entry '("." nn (((p u1 n) 1) ((t o) 0))))
(lex.add.entry '("'" punc nil))
(lex.add.entry '(":" punc nil))
(lex.add.entry '(";" punc nil))
(lex.add.entry '("," punc nil))
;(lex.add.entry '("," nn (((k o1) 1) ((m a) 0))))
(lex.add.entry '("-" punc nil))
(lex.add.entry '("\"" punc nil))
(lex.add.entry '("`" punc nil))
(lex.add.entry '("?" punc nil))
(lex.add.entry '("¿" punc nil))
(lex.add.entry '("!" punc nil))
(lex.add.entry '("¡" punc nil))
(lex.add.entry '("(" punc nil))
(lex.add.entry '(")" punc nil))
(lex.add.entry '("[" punc nil))
(lex.add.entry '("]" punc nil))
(lex.add.entry '("{" punc nil))
(lex.add.entry '("}" punc nil))
(lex.add.entry '("<" punc nil))
(lex.add.entry '(">" punc nil))
)
(define (upc_catalan_brackets phones)
"(upc_catalan_brackets phones)
Takes a list of phones containing - as syllable boundary. Construct the
Festival bracket structure."
(let ((syl nil) (syls nil) (p phones) (stress 0))
(if (string-matches (car p) '-) (set! p (cdr p)))
(while p
(set! syl nil)
(set! stress 0)
(while (and p (not (eq? '- (car p))))
(set! syl (cons (car p) syl))
(if (string-matches (car p) "[a e E i O o u]1")
(set! stress 1))
(set! p (cdr p)))
(set! p (cdr p)) ;; skip the syllable separator
(if (eq? '- (car p))
(set! p (cdr p)))
(set! syls (cons (list (reverse syl) stress) syls)))
(reverse syls)))
(define (catala_downcase word)
"(catala_downcase WORD)
Downs case word using a letter to sound rules table because accented characters
are note included in the builtin function."
(if (lts.in.alphabet word 'catala_downcase)
(lts.apply word 'catala_downcase)
(symbolexplode word)
)
)
(define (catala_simplify_vowels word)
"(catala_simplify_vowels WORD)
Simplifies forbidden vowels such as î by converting them in regular i."
(lts.apply word 'catala_simplify_vowels)
)
(define (catala_trans word)
" (catala_trans WORD)
Downs case word, apply LTS, stress and syllabification"
(let ((dword (apply string-append (lts.apply word 'catala_downcase))) (phones) (phones2) (syls))
(set! phones (lts_predict dword upc_catalan_lts_rules))
(set! phones2 (lts.apply phones 'upc_ca_correct_LTS))
(set! syl (lts.apply phones2 'upc_ca_syl))
(set! syls (upc_ca_brackets syl))
(list word syls)
)
)
(define (catala_trans2 word phones)
" (catala_trans2 WORD)
Apply stress and syllabification to phone list (phones)"
(let ((syl) (syls))
(set! syl (lts.apply phones 'upc_ca_syl))
(set! syls (upc_ca_brackets syl))
(list word syls)))
(define (catala_trans3_festival word phones)
" (catala_trans3 WORD)
Apply stress and automatic syllabification to phone list (phones)"
(let ((syls))
(set! syls (upc_ca_lex_syllabify_phstress phones))
(list word syls)))
(define (catala_trans4 word)
" (catala_trans WORD)
Downs case word, apply LTS, stress and syllabification"
(let ((dword (apply string-append (lts.apply word 'catala_downcase))) (syl) (phones) (phones2) (syls))
; (format t "Paraula %s\n" dword)
(set! phones (lts_predict dword upc_catalan_lts_rules))
(set! phones2 (lts.apply phones 'upc_ca_correct_LTS))
(set! syl (upc_ca_lex_syllabify_phstress phones2))
;(set! syls (upc_ca_brackets syl))
(list word syl)
)
)
;Thanks to Nickolay V. Shmyrev for strconcat:
(define (strconcat list)
"convert list into string"
(cond ((null list) "")
(t (string-append (car list) (strconcat (cdr list))))
)
)
(define (catala_downcase_string word)
; (format t "catala_downcase_string word :%l\n)
(if (string-matches word 0)
(string-append "")
(strconcat (catala_downcase word))
)
)
(define (upc_ca_is_vowel x)
(string-equal "+" (phone_feature x "vc")))
(define (upc_ca_contains_vowel l)
(member_string
t
(mapcar (lambda (x) (upc_ca_is_vowel x)) l)))
(define (upc_ca_lex_sylbreak currentsyl remainder)
"(upc_ca_lex_sylbreak currentsyl remainder)
t if this is a syl break, nil otherwise."
(cond
((not (upc_ca_contains_vowel remainder))
nil)
((not (upc_ca_contains_vowel currentsyl))
nil)
(t
;; overly naive, I mean wrong
t))
)
(define (upc_ca_lex_syllabify_phstress phones)
(let ((syl nil) (syls nil) (p phones) (stress 0))
(while p
(set! syl nil)
(set! stress 0)
(while (and p (not (upc_ca_lex_sylbreak syl p)))
(if (string-matches (car p) "xxxx")
(begin
;; whatever you do to identify stress
(set! stress 1)
(set syl (cons (car p-stress) syl)))
(set! syl (cons (car p) syl)))
(set! p (cdr p)))
(set! syls (cons (list (reverse syl) stress) syls)))
(reverse syls)
)
)
(define (upc_catalan_add_ruleset_catala_simplify_vowels_lts)
"(upc_catalan_add_ruleset_catala_simplify_vowels_lts)
Loads into the current lexicon a ruleset used to simplify foreign vowels."
(lts.ruleset
catala_simplify_vowels_lts
( )
;; Simplifica les lletres que no tenen LTS.
(
;; Vocals amb dièresi
( [ ä ] = a ) ;some foreign word
( [ ë ] = e ) ;some foreign word
( [ ï ] = i )
( [ ö ] = o ) ;some foreign word
( [ ü ] = u )
;; Vocals amb circumflex
( [ â ] = a ) ;some foreign word
( [ ê ] = e ) ;some foreign word
( [ î ] = i ) ;some foreign word
( [ ô ] = o ) ;some foreign word
( [ û ] = u ) ;some foreign word
)
)
)
(define (upc_catalan_add_ruleset_catala_downcase)
"(upc_catalan_add_ruleset_catala_downcase)
Loads into the current lexicon a ruleset used to downcase words.
Ideally it should be loaded in a single Catalan-generic lexicon, but
code needs to be cleaned in order to do this."
(lts.ruleset
catala_downcase
( )
;; Transforma els caràcters en el seu format en minúscula.
(
;; MINÚSCULES
;; Vocals accentuades codificació occidental
( [ á ] = à )
( [ à ] = à )
( [ é ] = é )
( [ è ] = è )
( [ í ] = í )
( [ ì ] = ì )
( [ ó ] = ó )
( [ ò ] = ò )
( [ ú ] = ú )
( [ ù ] = ù )
;; Vocals no accentuades
( [ a ] = a )
( [ e ] = e )
( [ i ] = i )
( [ o ] = o )
( [ u ] = u )
;; Vocals amb dièresi
( [ ä ] = ä ) ;some foreign word
( [ ë ] = ë ) ;some foreign word
( [ ï ] = ï )
( [ ö ] = ö ) ;some foreign word
( [ ü ] = ü )
;; Vocals amb circumflex
( [ â ] = â ) ;some foreign word
( [ ê ] = ê ) ;some foreign word
( [ î ] = î ) ;some foreign word
( [ ô ] = ô ) ;some foreign word
( [ û ] = û ) ;some foreign word
;; Consonants
( [ b ] = b )
( [ c ] = c )
( [ ç ] = ç )
( [ d ] = d )
( [ f ] = f )
( [ g ] = g )
( [ h ] = h )
( [ j ] = j )
( [ k ] = k )
( [ l ] = l )
( [ m ] = m )
( [ n ] = n )
( [ ñ ] = ñ )
( [ p ] = p )
( [ q ] = q )
( [ r ] = r )
( [ s ] = s )
( [ t ] = t )
( [ v ] = v )
( [ w ] = w )
( [ x ] = x )
( [ y ] = y )
( [ z ] = z )
;;; Símbols
( [ "·" ] = "·" )
( [ "'" ] = "" )
( [ "\·" ] = "\·" )
( [ "\!" ] = "\!" )
( [ "\"" ] = "\"" )
( [ "\#" ] = "\#" )
( [ "\$" ] = "\$" )
( [ "\£" ] = "\£" )
( [ "\¤" ] = "\¤" )
( [ "\%" ] = "\%" )
( [ "\&" ] = "\&" )
( [ "\'" ] = "\'" )
( [ "\(" ] = "\(" )
( [ "\)" ] = "\)" )
( [ "\*" ] = "\*" )
( [ "\+" ] = "\+" )
( [ "\," ] = "\," )
( [ "\-" ] = "\-" )
( [ "\." ] = "\." )
( [ "\/" ] = "\/" )
( [ "\:" ] = "\:" )
( [ "\;" ] = "\;" )
( [ "\<" ] = "\<" )
( [ "\=" ] = "\=" )
( [ "\>" ] = "\>" )
( [ "\?" ] = "\?" )
( [ "\@" ] = "\@" )
( [ "\[" ] = "\[" )
( [ "\\" ] = "\\" )
( [ "\^" ] = "\^" )
( [ "\_" ] = "\_" )
( [ "\`" ] = "\`" )
( [ "\{" ] = "\{" )
( [ "\|" ] = "\|" )
( [ "\}" ] = "\}" )
( [ "\~" ] = "\~" )
( [ " " ] = " " )
( [ "%" ] = "%" )
;; MAJÚSCULES
;; Vocals accentuades amb codificació occidental
( [ Á ] = á )
( [ À ] = à )
( [ É ] = é )
( [ È ] = è )
( [ Í ] = í )
( [ Ì ] = ì )
( [ Ó ] = ó )
( [ Ò ] = ò )
( [ Ú ] = ú )
( [ Ù ] = ù )
;; Vocals amb diéresi
( [ Ä ] = à ) ;some foreign word
( [ Ë ] = é ) ;some foreign word
( [ Ï ] = ï )
( [ Ü ] = ü )
( [ Ö ] = ö ) ;some foreign word
;; Vocals amb circumflex
( [ Â ] = â ) ;some foreign word
( [ Ê ] = ê ) ;some foreign word
( [ Î ] = î ) ;some foreign word
( [ Ô ] = ô ) ;some foreign word
( [ Û ] = û ) ;some foreign word
;; Vocals no accentuades
( [ A ] = a )
( [ E ] = e )
( [ I ] = i )
( [ O ] = o )
( [ U ] = u )
;; Consonants
( [ B ] = b )
( [ C ] = c )
( [ Ç ] = ç )
( [ D ] = d )
( [ F ] = f )
( [ G ] = g )
( [ H ] = h )
( [ J ] = j )
( [ K ] = k )
( [ L ] = l )
( [ M ] = m )
( [ N ] = n )
( [ Ñ ] = ñ )
( [ P ] = p )
( [ Q ] = q )
( [ R ] = r )
( [ S ] = s )
( [ T ] = t )
( [ V ] = v )
( [ W ] = w )
( [ X ] = x )
( [ Y ] = y )
( [ Z ] = z )
;; Números
( [ 0 ] = 0 )
( [ 1 ] = 1 )
( [ 2 ] = 2 )
( [ 3 ] = 3 )
( [ 4 ] = 4 )
( [ 5 ] = 5 )
( [ 6 ] = 6 )
( [ 7 ] = 7 )
( [ 8 ] = 8 )
( [ 9 ] = 9 )
))
)
(define (upc_catalan_add_ruleset_catala_simplify_vowels)
"(upc_catalan_add_ruleset_catala_simplify_vowels)
Loads into the current lexicon a ruleset used to simplify weird accents in characters
in order to spell words in tokenizer.
Ideally it should be loaded in a single Catalan-generic lexicon, but
code needs to be cleaned in order to do this."
(lts.ruleset
catala_simplify_vowels
( )
;; Transforma vocals lletges. S'utilitza en el tokenizer
(
;; MINÚSCULES
;; Vocals accentuades codificació occidental
( [ a ] = a )
( [ à ] = a )
( [ á ] = a )
( [ ä ] = a )
( [ â ] = a )
( [ e ] = e )
( [ é ] = e )
( [ è ] = e )
( [ ë ] = e )
( [ ê ] = e )
( [ i ] = i )
( [ ì ] = i )
( [ í ] = i )
( [ ï ] = i )
( [ î ] = i )
( [ o ] = o )
( [ ó ] = o )
( [ ò ] = o )
( [ ö ] = o )
( [ ô ] = o )
( [ u ] = u )
( [ ú ] = u )
( [ ù ] = u )
( [ ü ] = u )
( [ û ] = u )
))
)
(provide 'upclex_catalan)
|