-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcap-signalization.scm
69 lines (54 loc) · 2.6 KB
/
cap-signalization.scm
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
;;; Capital character signalization
;; Copyright (C) 2003, 2004, 2006 Brailcom, o.p.s.
;; Author: Milan Zamazal <[email protected]>
;; COPYRIGHT NOTICE
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful, but
;; WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
;; for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, write to the Free Software
;; Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
(require 'util)
(require 'oo)
(defvar cap-signalization-mode nil)
(define-wrapper (token_to_words token name) cap-signalization
(if cap-signalization-mode
(let ((ttw* (lambda (token name)
(append (if (string-matches name "^[A-ZÁÈÏÉÌÍÒÓØ©«ÚÙÝ®].*")
;; token_to_words allows only strings and
;; symbols as feature values, so we have to use
;; capital-event, to be transformed later
(list '((name "") (capital-event "")
(event-stick-to next))))
((next-func) token name)))))
(if (string-matches name "^..*[A-ZÁÈÏÉÌÍÒÓØ©«ÚÙÝ®].*")
(let ((i 1))
(while (not (string-matches (substring name i 1)
"^[A-ZÁÈÏÉÌÍÒÓØ©«ÚÙÝ®].*"))
(set! i (+ i 1)))
(append (ttw* token (substring name 0 i))
(token_to_words
token
(substring name i (- (length name) i))
(next-func))))
(ttw* token name)))
((next-func) token name)))
(Param.wrap Token_Method cap-signalization
(lambda (utt)
(apply* (next-value) (list utt))
(do-relation-items (w utt Word)
(if (item.has_feat w 'capital-event)
(add-event utt w '(logical capital) nil)))
utt))
(define (set-cap-signalization-mode mode)
"(set-cap-signalization-mode MODE)
Enable or disable capital letter signalization mode.
If MODE is non-nil, enable the mode, otherwise disable it."
(oo-ensure-function-wrapped 'token_to_words)
(set! cap-signalization-mode mode))
(provide 'cap-signalization)