home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: Multimed / Multimed.zip / fest-141.zip / festival / lib / token.scm < prev    next >
Text File  |  1999-06-12  |  23KB  |  597 lines

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;;;                                                                       ;;
  3. ;;;                Centre for Speech Technology Research                  ;;
  4. ;;;                     University of Edinburgh, UK                       ;;
  5. ;;;                       Copyright (c) 1996,1997                         ;;
  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. ;;;  THE UNIVERSITY OF EDINBURGH 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 THE UNIVERSITY OF EDINBURGH 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. ;;;
  34. ;;;  Various tokenizing functions and customization 
  35.  
  36. (define (Token utt)
  37.   "(Token UTT)
  38. Build a Word stream from the Token stream, analyzing compound words
  39. numbers etc as tokens into words. Respects the Parameter Language
  40. to choose the appropriate token to word module."
  41.   (let ((rval (apply_method 'Token_Method utt)) ;; might be defined
  42.     (language (Parameter.get 'Language)))
  43.     (cond
  44.      (rval rval)  ;; newer style
  45.      ((or (string-equal "britishenglish" language)
  46.       (string-equal "english" language)
  47.       (string-equal "americanenglish" language))
  48.       (Token_English utt))
  49.      ((string-equal "welsh" language)
  50.       (Token_Welsh utt))
  51.      (t
  52.       (Token_Any utt)))))
  53.  
  54. (define (english_token_to_words token name)
  55. "(english_token_to_words TOKEN NAME)
  56. Returns a list of words for NAME from TOKEN.  This allows the
  57. user to customize various non-local, multi-word, context dependent
  58. translations of tokens into words.  If this function is unset only
  59. the builtin translation rules are used, if this is set the builtin
  60. rules are not used unless explicitly called. [see Token to word rules]"
  61.  (cond
  62.   ((string-matches name "[A-Z]*[\\$#\\\\Yú][0-9,]+\\(\\.[0-9]+\\)?")
  63.    ;; Some for of money (pounds or type of dollars)
  64.    (let (amount type currency)
  65.      (cond
  66.       ((string-matches name ".*\\$.*")
  67.        (set! amount (string-after name "$"))
  68.        (set! type (string-before name "$"))
  69.        (set! currency "dollar"))
  70.       ((string-matches name ".*ú.*")
  71.        (set! amount (string-after name "ú"))
  72.        (set! type (string-before name "ú"))
  73.        (set! currency "pound"))
  74.       ((string-matches name ".*#.*")
  75.        (set! amount (string-after name "#"))
  76.        (set! type (string-before name "#"))
  77.        (set! currency "pound"))
  78.       ((string-matches name ".*Y[0-9].*")
  79.        (set! amount (string-after name "Y"))
  80.        (set! type (string-before name "Y"))
  81.        (set! currency "yen"))
  82.       ((string-matches name ".*\\\\.*")
  83.        (set! amount (string-after name "\\"))
  84.        (set! type (string-before name "\\"))
  85.        (set! currency "yen"))
  86.       (t
  87.        ;; who knows
  88.        (set! amount (string-after name "$"))
  89.        (set! type (string-before name "$"))
  90.        (set! currency "dollar")))
  91.      (cond
  92.       ((string-matches (item.feat token "n.name")
  93.                ".*illion.?")
  94.        (append   ;; "billions and billions" - Sagan
  95.     (builtin_english_token_to_words token amount)
  96.     (list (item.feat token "n.name")) ;; illion
  97.     (token_money_expand type)
  98.     (list (string-append currency "s"))))
  99.       ((string-matches amount ".*\\...$")
  100.        (append   ;; exactly two places after point
  101.     (builtin_english_token_to_words token (string-before amount "."))
  102.     (token_money_expand type)
  103.     (if (or (string-matches amount "1\\..*")
  104.         (string-equal currency "yen"))
  105.         (list currency)
  106.         (list (string-append currency "s")))
  107.     (if (not (string-matches name ".*\\.00$"))
  108.         (builtin_english_token_to_words 
  109.          token (remove_leading_zeros (string-after amount ".")))
  110.         nil)))
  111.       (t
  112.        (append   ;; nothing after point or lots after point
  113.     (builtin_english_token_to_words token amount)
  114.     (token_money_expand type)
  115.     (if (or (string-matches amount "1")
  116.         (string-equal currency "yen"))
  117.         (list currency)
  118.         (list (string-append currency "s"))))))))
  119.   ((and (string-matches name ".*illion.?")
  120.     (string-matches (item.feat token "p.name")
  121.             "[A-Z]*[\\$#][0-9,]+\\(\\.[0-9]+\\)?"))
  122.    nil ;; dealt with on the previous symbol
  123.    )
  124.   ((string-matches name "[1-9][0-9]*/[1-9][0-9]*")
  125.    (let ((numerator (string-before name "/"))
  126.      (denominator (string-after name "/"))
  127.      )
  128.      (cond
  129.       ((string-matches name "1/2")
  130.        (list "half"))
  131.       ((string-matches denominator "4")
  132.        (append
  133.     (builtin_english_token_to_words token numerator)
  134.     (list "quarter")
  135.     (if (string-equal numerator "1")
  136.         (list '((name "'s")(pos nnp)))
  137.         nil)))
  138.       (t
  139.        (append
  140.     (builtin_english_token_to_words token numerator)
  141.     (begin
  142.       (item.set_feat token "token_pos" "ordinal")
  143.       (builtin_english_token_to_words token denominator))
  144.     (if (string-equal numerator "1")
  145.         nil
  146.         (list '((name "'s")(pos nnp)))))))))
  147.   ((and (string-matches name "No")
  148.         (string-matches (item.feat token "n.name")
  149.             "[0-9]+"))
  150.    (list
  151.     "number"))
  152.   ((string-matches name ".*%$")
  153.    (append
  154.     (token_to_words token (string-before name "%"))
  155.     (list "percent")))
  156.   ((string-matches name "[0-9]+s")  ;; e.g. 1950s
  157.    (item.set_feat token "token_pos" "year")  ;; reasonable guess
  158.    (append
  159.     (builtin_english_token_to_words token (string-before name "s"))
  160.     (list '((name "'s")(pos nnp))) ;; will get assimilated by postlexical rules
  161.    ))
  162.   ((string-matches name "[0-9]+'s")  ;; e.g. 1950's
  163.    (item.set_feat token "token_pos" "year")  ;; reasonable guess
  164.    (append
  165.     (builtin_english_token_to_words token (string-before name "'s"))
  166.     (list '((name "'s")(pos nnp))) ;; will get assimilated by postlexical rules
  167.    ))
  168.   ((and (string-matches name ".*s$")
  169.     (string-equal (item.feat token "punc") "'"))
  170.    ;; potential possessive or may be end of a quote
  171.    (if (token_no_starting_quote token)
  172.        (item.set_feat token "punc" ""))
  173.    (builtin_english_token_to_words token name))
  174.   ((and (string-equal name "A")  ;; letter or determiner
  175.     (or (string-matches (item.feat token "p.name") "[a-z].*")
  176.         (string-matches (item.feat token "n.name") "[A-Z].*")))
  177.    (list (list '(name "a")(list 'pos token.letter_pos))))
  178.   ((member_string name english_homographs)
  179.    (list (list (list 'name name)
  180.            (list 'hg_pos (item.feat token "token_pos")))))
  181.   ((string-matches name "[0-9]?[0-9][:\\.][0-9][0-9][AaPp][Mm]")  ;; time
  182.    ;;  must be am/pm present for . to be acceptable separator
  183.    (let (hours mins half sep (ttime (downcase name)))
  184.      (if (string-matches ttime ".*:.*")
  185.      (set! sep ":")
  186.      (set! sep "."))
  187.      (set! hours (string-before ttime sep))
  188.      (set! mins (string-after ttime sep))
  189.      (if (string-matches ttime "am")
  190.      (set! sep "am")
  191.      (set! sep "pm"))
  192.      (set! mins (string-before mins sep))
  193.      (append
  194.       (builtin_english_token_to_words token hours)
  195.       (builtin_english_token_to_words token mins)
  196.       (list sep))))
  197.   ((string-matches name "[0-9]?[0-9]:[0-9][0-9]")  ;; time
  198.    (append
  199.      (builtin_english_token_to_words 
  200.       token (remove_leading_zeros (string-before name ":")))
  201.      (builtin_english_token_to_words 
  202.       token (remove_leading_zeros (string-after name ":")))))
  203.   ((string-matches name "[0-9][0-9]:[0-9][0-9]:[0-9][0-9]")  ;; exact time
  204.    (append
  205.     (builtin_english_token_to_words 
  206.      token (remove_leading_zeros (string-before name ":")))
  207.     (list "hours")
  208.     (builtin_english_token_to_words 
  209.       token (remove_leading_zeros 
  210.          (string-before (string-after name ":") ":")))
  211.     (list "minutes" "and")
  212.     (builtin_english_token_to_words 
  213.       token (remove_leading_zeros
  214.          (string-after (string-after name ":") ":")))
  215.     (list "seconds")))
  216.   ((string-matches name "[0-9][0-9]?/[0-9][0-9]?/[0-9][0-9]\\([0-9][0-9]\\)?")
  217.    ;; date, say it as numbers to avoid American/British problem
  218.    (let ((num1 (string-before name "/"))
  219.      (num2 (string-before (string-after name "/") "/"))
  220.      (year (string-after (string-after name "/") "/"))
  221.      day month)
  222.      (item.set_feat token "token_pos" "cardinal")
  223.      (set! day (builtin_english_token_to_words token num1))
  224.      (set! month (builtin_english_token_to_words token num2))
  225.      (item.set_feat token "token_pos" "year")
  226.      (append
  227.       day
  228.       month
  229.       (list '((name ",")(pbreak_scale 0.9)))
  230.       (builtin_english_token_to_words token year))))
  231.   ((string-matches name "[0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]")
  232.    (item.set_feat token "token_pos" "digits")  ;; canonical phone number
  233.    (append
  234.     (builtin_english_token_to_words token (string-before name "-"))
  235.     (list '((name ",")(pbreak_scale 1.0)))
  236.     (builtin_english_token_to_words token (string-after name "-"))))
  237.   ((string-matches name "[0-9]+-[0-9]+-[-0-9]+")
  238.    ;; long distance number 
  239.    (let ((r '(dummy)) (remainder name))
  240.      (item.set_feat token "token_pos" "digits")
  241.      (while (> (length remainder) 0)
  242.        (if (string-matches remainder "[0-9]+")
  243.        (set! r (append r 
  244.                (builtin_english_token_to_words 
  245.             token remainder)))
  246.        (set! r (append r 
  247.                (builtin_english_token_to_words 
  248.                 token (string-before remainder "-")))))
  249.        (set! remainder (string-after remainder "-"))
  250.        (if (> (length remainder) 0)
  251.        (set! r (append r (list '((name ",")(pbreak_scale 1.0)))))))
  252.      (cdr r))
  253.    )
  254.   ((and (string-matches name "[0-9][0-9][0-9]")
  255.     (string-matches (item.feat token "n.name")
  256.             "[0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]"))
  257.      (item.set_feat token "token_pos" "digits")
  258.      (builtin_english_token_to_words token name))
  259.   ((string-matches name "[0-9]+-[0-9]+")
  260.    (let ((tokpos))
  261.      (item.set_name token (string-before name "-"))
  262.      (set! tokpos (wagon token 
  263.              (car (cdr (assoc "[0-9]+" token_pos_cart_trees)))))
  264.      (item.set_feat token "token_pos" (car tokpos))
  265.      (append
  266.       (builtin_english_token_to_words token (string-before name "-"))
  267.       (list "to")
  268.       (builtin_english_token_to_words token (string-after name "-")))))
  269.   ((string-matches name "\\(II?I?\\|IV\\|VI?I?I?\\|IX\\|X[VIX]*\\)")
  270.    ;; Roman numerals
  271.    (let ((tp (item.feat token "token_pos")))
  272.      (cond
  273.       ((string-matches tp "century");; always believe this
  274.        (item.set_feat token "token_pos" "ordinal")
  275.        (if (or (string-equal "1" (tok_rex token))
  276.            (item.feat token "p.lisp_tok_rex_names"))
  277.        (append
  278.         (list "the")
  279.         (builtin_english_token_to_words 
  280.          token (tok_roman_to_numstring name)))
  281.        (builtin_english_token_to_words 
  282.         token (tok_roman_to_numstring name))))
  283.       ((string-matches name "[IVX]");; be *very* wary of this one
  284.        (if (and (string-equal 
  285.          "1" (item.feat token "p.lisp_tok_section_name"))
  286.         (string-matches tp "number"))
  287.        (builtin_english_token_to_words 
  288.         token (tok_roman_to_numstring name))
  289.        (tok_string_as_letters name)))
  290.       ((string-matches tp "number")
  291.        (item.set_feat token "token_pos" "cardinal")
  292.        (builtin_english_token_to_words 
  293.     token (tok_roman_to_numstring name)))
  294.       (t;; else its a letter
  295.        (tok_string_as_letters name)))))
  296.   ((and (string-matches name "pp")
  297.     (string-matches (item.feat token "n.name")
  298.             "[0-9]+-[0-9]+"))
  299.    (list "pages"))
  300.   ((and (string-matches name "ss")
  301.     (string-matches (item.feat token "n.name")
  302.             "[0-9]+-[0-9]+"))
  303.    (list "sections"))
  304.   ((string-matches name "_____+")
  305.    (list "line" "of" "underscores"))
  306.   ((string-matches name "=====+")
  307.    (list "line" "of" "equals"))
  308.   ((string-matches name "-----+")
  309.    (list "line" "of" "hyphens"))
  310.   ((string-matches name "\\*\\*\\*\\*\\*+")
  311.    (list "line" "of" "asterisks"))
  312.   ((string-matches name "--+")
  313.    (list '((name ",")(pbreak_scale 1.0))))
  314.   ((string-matches name ".*--+.*")
  315.    (append
  316.     (builtin_english_token_to_words token (string-before name "--"))
  317.     (list '((name ",")(pbreak_scale 1.0)))
  318.     (builtin_english_token_to_words token (string-after name "--"))))
  319.   ((string-matches name "[A-Z][A-Z]?&[A-Z][A-Z]?")
  320.    (append
  321.     (tok_string_as_letters (string-before name "&"))
  322.     (list "and")
  323.     (tok_string_as_letters (string-after name "&"))))
  324.   ((or (string-matches name "[A-Z][A-Z]+s")
  325.        (string-matches name "[BCDEFGHJKLMNOPQRSTVWXYZ]+s"))
  326.    (append
  327.     (builtin_english_token_to_words token (string-before name "s"))
  328.     (list '((name "'s")(pos nnp))) ;; will get assimilated by postlexical rules
  329.     ))
  330.   ((string-matches name "<.*@.*>")  ;; quoted e-mail
  331.    (append 
  332.     (builtin_english_token_to_words
  333.      token (string-after (string-before name "@") "<"))
  334.     (list "at")
  335.     (builtin_english_token_to_words
  336.      token (string-before (string-after name "@") ">"))))
  337.   ((string-matches name ".*@.*")  ;; e-mail
  338.    (append 
  339.     (builtin_english_token_to_words
  340.      token (string-before name "@"))
  341.     (list "at")
  342.     (builtin_english_token_to_words
  343.      token (string-after name "@") ">")))
  344.   ((string-matches name "\\([dD][Rr]\\|[Ss][tT]\\)")
  345.    (if (string-equal (item.feat token "token_pos") "street")
  346.        (if (string-matches name "[dD][rR]")
  347.        (list "drive")
  348.        (list "street"))
  349.        (if (string-matches name "[dD][rR]")  ;; default on title side
  350.        (list "doctor")
  351.        (list "saint"))))
  352.   ((string-matches name "[Cc]alif")  ;; hopelessly specific ...
  353.    (list 
  354.     "california"))
  355.   (t
  356.    (builtin_english_token_to_words token name))))
  357.  
  358. ;;; This is set as the default
  359. (defvar token_to_words english_token_to_words)
  360.  
  361. (defvar token.punctuation "\"'`.,:;!?(){}[]"
  362.   "token.punctuation
  363. A string of characters which are to be treated as punctuation when
  364. tokenizing text.  Punctuation symbols will be removed from the text
  365. of the token and made available through the \"punctuation\" feature.
  366. [see Tokenizing]")
  367. (defvar token.prepunctuation "\"'`({["
  368.   "token.prepunctuation
  369. A string of characters which are to be treated as preceding punctuation
  370. when tokenizing text.  Prepunctuation symbols will be removed from the text
  371. of the token and made available through the \"prepunctuation\" feature.
  372. [see Tokenizing]")
  373. (defvar token.whitespace " \t\n\r"
  374.   "token.whitespace
  375. A string of characters which are to be treated as whitespace when
  376. tokenizing text.  Whitespace is treated as a separator and removed
  377. from the text of a token and made available through the \"whitespace\"
  378. feature.  [see Tokenizing]")
  379. (defvar token.singlecharsymbols ""
  380.   "token.singlecharsymbols
  381. Characters which have always to be split as tokens.  This would be
  382. usual is standard text, but is useful in parsing some types of
  383. file. [see Tokenizing]")
  384.  
  385. (defvar token.letter_pos 'nn
  386.   "token.letter_pos
  387. The part of speech tag (valid for your part of speech tagger) for
  388. individual letters.  When the tokenizer decide to pronounce a token
  389. as a list of letters this tag is added to each letter in the list.  
  390. Note this should be from the part of speech set used in your tagger 
  391. which may not be the same one that appears in the actual lexical 
  392. entry (if you map them afterwards).  This specifically allows \"a\"
  393. to come out as ae rather than @.")
  394.  
  395. (defvar token.unknown_word_name "unknown"
  396.   "token.unknown_word_name
  397. When all else fails and a pronunciation for a word or character can't
  398. be found this word will be said instead.  If you make this \"\" them
  399. the unknown word will simple be omitted.  This will only
  400. really be called when there is a bug in the lexicon and characters
  401. are missing from the lexicon.  Note this word should be in the lexicon.")
  402.  
  403. (def_feature_docstring
  404.   'Token.punc
  405.   "Token.punc
  406. Succeeding punctuation symbol found after token in original 
  407. string/file.")
  408. (def_feature_docstring
  409.   'Token.whitespace
  410.   "Token.whitespace
  411. Whitespace found before token in original string/file.")
  412. (def_feature_docstring
  413.   'Token.prepunctuation
  414.   "Token.prepunctuation
  415. Preceeding puctuation symbol found before token in original string/file.")
  416.  
  417. (require 'tokenpos)
  418. ;;;
  419. ;;;  Token pos are gross level part of speech tags which help decide
  420. ;;;  pronunciation of tokens (particular expansion of Tokens into words)
  421. ;;;  The most obvious example is identifying number types (ordinals,
  422. ;;;  years, digits or numbers).
  423. ;;;
  424. (defvar english_token_pos_cart_trees
  425.   '(
  426.     ;;  Format is (Regex Tree)
  427.     ("[0-9]+" 
  428.      ((lisp_num_digits < 3.8)
  429.       ((p.lisp_token_pos_guess is month)
  430.        ((lisp_month_range is 0) ((year)) ((ordinal)))
  431.        ((n.lisp_token_pos_guess is month)
  432.     ((lisp_month_range is 0) ((cardinal)) ((ordinal)))
  433.     ((n.lisp_token_pos_guess is numeric)
  434.      ((lisp_num_digits < 2)
  435.       ((p.lisp_token_pos_guess is numeric)
  436.        ((pp.lisp_token_pos_guess is sym) ((digits)) ((cardinal)))
  437.        ((cardinal)))
  438.       ((nn.lisp_token_pos_guess is sym) ((cardinal)) ((digits))))
  439.      ((lisp_num_digits < 2)
  440.       ((nn.lisp_token_pos_guess is numeric)
  441.        ((n.lisp_token_pos_guess is sym)
  442.         ((lisp_month_range is 0) ((digits)) ((cardinal)))
  443.         ((cardinal)))
  444.        ((cardinal)))
  445.       ((name < 302.3)
  446.        ((p.lisp_token_pos_guess is flight)
  447.         ((digits))
  448.         ((n.lisp_token_pos_guess is sym)
  449.          ((p.lisp_token_pos_guess is sym) ((digits)) ((cardinal)))
  450.          ((cardinal))))
  451.        ((p.lisp_token_pos_guess is a)
  452.         ((digits))
  453.         ((n.lisp_token_pos_guess is sym)
  454.          ((nn.lisp_token_pos_guess is sym)
  455.           ((name < 669.2) ((digits)) ((cardinal)))
  456.           ((cardinal)))
  457.          ((name < 373.2)
  458.           ((cardinal))
  459.           ((name < 436.2)
  460.            ((name < 392.6) ((digits)) ((cardinal)))
  461.            ((name < 716.5)
  462.         ((cardinal))
  463.         ((name < 773.6)
  464.          ((p.lisp_token_pos_guess is _other_) ((digits)) ((cardinal)))
  465.          ((cardinal)))))))))))))
  466.       ((p.lisp_token_pos_guess is numeric)
  467.        ((pp.lisp_token_pos_guess is month)
  468.     ((year))
  469.     ((nn.lisp_token_pos_guess is numeric) ((cardinal)) ((digits))))
  470.        ((nn.lisp_token_pos_guess is numeric)
  471.     ((n.lisp_token_pos_guess is month)
  472.      ((cardinal))
  473.      ((n.lisp_token_pos_guess is numeric)
  474.       ((digits))
  475.       ((p.lisp_token_pos_guess is _other_) ((cardinal)) ((year)))))
  476.     ((p.lisp_token_pos_guess is _other_)
  477.      ((lisp_num_digits < 4.4)
  478.       ((name < 2959.6)
  479.        ((name < 1773.4) ((cardinal)) ((year)))
  480.        ((cardinal)))
  481.       ((pp.lisp_token_pos_guess is _other_) ((digits)) ((cardinal))))
  482.      ((n.lisp_token_pos_guess is to)
  483.       ((year))
  484.       ((p.lisp_token_pos_guess is sym)
  485.        ((pp.lisp_token_pos_guess is sym)
  486.         ((cardinal))
  487.         ((lisp_num_digits < 4.6) ((year)) ((digits))))
  488.        ((lisp_num_digits < 4.8)
  489.         ((name < 2880)
  490.          ((name < 1633.2)
  491.           ((name < 1306.4) ((cardinal)) ((year)))
  492.           ((year)))
  493.          ((cardinal)))
  494.         ((cardinal)))))))))
  495.      )
  496.     ("\\(II?I?\\|IV\\|VI?I?I?\\|IX\\|X[VIX]*\\)";; Roman numerals
  497.      ((p.lisp_tok_rex_names is 0)
  498.       ((lisp_num_digits is 5)
  499.        ((number))
  500.        ((lisp_num_digits is 4)
  501.     ((number))
  502.     ((nn.lisp_num_digits is 13)
  503.      ((number))
  504.      ((p.lisp_num_digits is 7)
  505.       ((number))
  506.       ((p.lisp_tok_section_name is 0)
  507.        ((lisp_tok_rex is 0)
  508.         ((lisp_num_digits is 3)
  509.          ((p.lisp_num_digits is 4)
  510.           ((number))
  511.           ((nn.lisp_num_digits is 4)
  512.            ((number))
  513.            ((n.lisp_num_digits is 4)
  514.         ((number))
  515.         ((pp.lisp_num_digits is 3)
  516.          ((number))
  517.          ((p.lisp_num_digits is 2)
  518.           ((letter))
  519.           ((nn.lisp_num_digits is 2)
  520.            ((letter))
  521.            ((n.cap is 0) ((letter)) ((number)))))))))
  522.          ((nn.lisp_num_digits is 11)
  523.           ((letter))
  524.           ((lisp_num_digits is 1)
  525.            ((pp.lisp_num_digits is 9)
  526.         ((letter))
  527.         ((p.lisp_num_digits is 9)
  528.          ((letter))
  529.          ((n.lisp_num_digits is 6)
  530.           ((letter))
  531.           ((pp.lisp_num_digits is 6)
  532.            ((letter))
  533.            ((pp.cap is 0)
  534.             ((n.cap is 0)
  535.              ((p.lisp_num_digits is 1)
  536.               ((letter))
  537.               ((n.lisp_num_digits is 4) ((letter)) ((letter))))
  538.              ((letter)))
  539.             ((letter)))))))
  540.            ((p.lisp_num_digits is 10)
  541.         ((number))
  542.         ((n.lisp_num_digits is 8)
  543.          ((number))
  544.          ((pp.lisp_num_digits is 9)
  545.           ((number))
  546.           ((nn.lisp_num_digits is 5)
  547.            ((number))
  548.            ((n.lisp_num_digits is 4) ((number)) ((letter))))))))))
  549.         ((letter)))
  550.        ((number)))))))
  551.       ((century))))
  552.     ("\\([dD][Rr]\\|[Ss][tT]\\)"
  553.      ((n.name is 0)
  554.       ((p.cap is 1)
  555.        ((street))
  556.        ((p.name matches "[0-9]*\\(1[sS][tT]\\|2[nN][dD]\\|3[rR][dD]\\|[0-9][tT][hH]\\)")
  557.     ((street))
  558.     ((title))))
  559.       ((punc matches ".*,.*")
  560.        ((street))
  561.        ((p.punc matches ".*,.*")
  562.     ((title))
  563.     ((n.cap is 0)
  564.      ((street))
  565.      ((p.cap is 0)
  566.       ((p.name matches "[0-9]*\\(1[sS][tT]\\|2[nN][dD]\\|3[rR][dD]\\|[0-9][tT][hH]\\)")
  567.        ((street))
  568.        ((title)))
  569.       ((pp.name matches "[1-9][0-9]+")
  570.        ((street))
  571.        ((title)))))))))
  572.     ("lead"
  573.      ((p.name in (was were had been having has is are))
  574.       ((led))
  575.       ((liid))))
  576.     ("read"
  577.      ((p.name in (to))
  578.       ((riid))
  579.       ((red))))
  580.     ))
  581.  
  582. (defvar english_homographs
  583.   '("lead" "read")
  584.   "english_homographs
  585. A list of tokens that are dealt with by a homograph disambiguation tree
  586. in english_token_pos_cart_trees.")
  587.  
  588. (defvar token_pos_cart_trees
  589.   english_token_pos_cart_trees
  590.   "token_pos_cart_trees
  591. This is a list of pairs or regex plus CART tree.  Tokens that match
  592. the regex will have the CART tree aplied, setting the result as
  593. the token_pos feature on the token.  The list is checked in order
  594. and only the first match will be applied.")
  595.  
  596. (provide 'token)
  597.