root/lang/elisp/pdicv-mode/trunk/nt-english.el @ 75

Revision 71, 11.8 kB (checked in by naoya_t, 16 years ago)
Line 
1;;; nt-english.el --- English
2;;
3;; Copyright (C) 2005-2009 naoya_t. All Rights Reserved.
4;;
5;; Author: naoya_t <naoya.t@aqua.plala.or.jp>
6;; Maintainer: naoya_t <naoya.t@aqua.plala.or.jp>
7;; Primary distribution site:
8;;   http://lambdarepos.svnrepository.com/svn/share/lang/elisp/pdicv-mode/trunk
9;;
10;; Created: 23 Dec 2005
11;; Last modified: 23 Dec 2005
12;; Version: 0.2
13;; Keywords:
14
15(provide 'nt-english)
16
17;;; Commentaries:
18
19; (nt:english-guess-original-form WORD)
20;    - ������ñ���������Ȥ��롣
21;      ������Υꥹ�Ȥˤ�WORD �ϴޤޤ�����
22;
23; (nt:skipit-p WORD)
24;    - �����åפ�����ñ����, �����Ǥʤ��� nil
25
26;; Code
27(defvar nt-skip-words '("the" "a" "an"
28                        "i" "you" "he" "she" "it" "we" "they"
29                        "am" "are" "is" "was" "were"
30                        "this" "that" "these" "those"
31                        "or" "and" "but"))
32
33(defvar nt-english-irreg-verbs-list
34      '(("abode" . "abide")
35        ("alit" . "alight")
36        ("arose" . "arise") ("arisen" . "arise")
37        ("awoke" . "awake") ("awoken" . "awake")
38        ("backbit" . "backbite") ("backbitten" . "backbite")
39        ("backslid" . "backslide")
40        ("was" . "be") ("were" . "be") ("been" . "be")
41        ("bore" . "bear") ("borne" . "bear") ("born" . "bear")
42        ("beaten" . "beat")
43        ("became" . "become")
44        ("befell" . "befall") ("befallen" . "befall")
45        ("begot" . "beget") ("begotten" . "beget")
46        ("began" . "begin") ("begun" . "begin")
47        ("beheld" . "behold")
48        ("bent" . "bend")
49        ("bereft" . "bereave")
50        ("besought" . "beseech")
51        ("bade" . "bid") ("bidden" . "bid")
52        ("bade" . "bide")
53        ("bound" . "bind")
54        ("bit" . "bite") ("bitten" . "bite")
55        ("bled" . "bleed")
56        ("blent" . "blend")
57        ("blest" . "bless")
58        ("blew" . "blow") ("blown" . "blow")
59        ("broke" . "break") ("broken" . "break")
60        ("bred" . "breed")
61        ("brought" . "bring")
62        ("built" . "build")
63        ("burnt" . "burn")
64        ("bought" . "buy")
65        ("caught" . "catch")
66        ("chose" . "choose") ("chosen" . "choose")
67        ("clove" . "cleave") ("cleft" . "cleave") ("cloven" . "cleave")
68        ("clung" . "cling")
69        ("clad" . "clothe")
70        ("came" . "come")
71        ("crept" . "creep")
72        ("crew" . "crow")
73        ("durst" . "dare")
74        ("dealt" . "deal")
75        ("dug" . "dig")
76        ("did" . "do") ("done" . "do")
77        ("drew" . "draw") ("drawn" . "draw")
78        ("dreamt" . "dream")
79        ("drank" . "drink") ("drunk" . "drink")
80        ("drove" . "drive") ("driven" . "drive")
81        ("dwelt" . "dwell")
82        ("ate" . "eat") ("eaten" . "eat")
83        ("fell" . "fall") ("fallen" . "fall")
84        ("fed" . "feed")
85        ("felt" . "feel")
86        ("fought" . "fight")
87        ("found" . "find")
88        ("fled" . "flee")
89        ("flung" . "fling")
90        ("flew" . "fly") ("flown" . "fly")
91        ("forbade" . "forbid") ("forbad" . "forbid") ("forbidden" . "forbid")
92        ("forgot" . "forget") ("forgotten" . "forget")
93        ("forgave" . "forgive") ("forgiven" . "forgive")
94        ("forsook" . "forsake") ("forsaken" . "forsake")
95        ("froze" . "freeze") ("frozen" . "freeze")
96        ("gelt" . "geld")
97        ("got" . "get") ("gotten" . "get")
98        ("gilt" . "gild")
99        ("girt" . "gird")
100        ("gave" . "give") ("given" . "give")
101        ("gnawn" . "gnaw")
102        ("went" . "go") ("gone" . "go")
103        ("graven" . "grave")
104        ("ground" . "grind")
105        ("gript" . "grip")
106        ("grew" . "grow") ("grown" . "grow")
107        ("hamstrung" . "hamstring")
108        ("hung" . "hang") ("hung" . "hang")
109        ("had" . "have")
110        ("heard" . "hear")
111        ("hove" . "heave")
112        ("hewn" . "hew")
113        ("hid" . "hide") ("hidden" . "hide")
114        ("held" . "hold")
115        ("inlaid" . "inlay")
116        ("kept" . "keep")
117        ("knelt" . "kneel")
118        ("knew" . "know") ("known" . "know")
119        ("laid" . "lay")
120        ("led" . "lead")
121        ("leant" . "lean")
122        ("leapt" . "leap")
123        ("learnt" . "learn")
124        ("left" . "leave")
125        ("lent" . "lend")
126        ("lay" . "lie") ("lain" . "lie")
127        ("lit" . "light")
128        ("lost" . "lose")
129        ("made" . "make")
130        ("meant" . "mean")
131        ("met" . "meet")
132        ("molten" . "melt")
133        ("misled" . "mislead")
134        ("mistook" . "mistake") ("mistaken" . "mistake")
135        ("misunderstood" . "misunderstand")
136        ("mowed" . "mow") ("mown" . "mow")
137        ("outdid" . "outdo") ("outdone" . "outdo")
138        ("outwent" . "outgo") ("outgone" . "outgo")
139        ("outgrew" . "outgrow") ("outgrown" . "outgrow")
140        ("outran" . "outrun")
141        ("overcame" . "overcome")
142        ("overdid" . "overdo") ("overdone" . "overdo")
143        ("overdrew" . "overdraw") ("overdrawn" . "overdraw")
144        ("overtook" . "overtake") ("overtaken" . "overtake")
145        ("overthrew" . "overthrow") ("overthrown" . "overthrow")
146        ("paid" . "pay")
147        ("pent" . "pen")
148        ("pled" . "plead")
149        ("proven" . "prove")
150        ("rent" . "rend")
151        ("repaid" . "repay")
152        ("retold" . "retell")
153        ("rewound" . "rewind")
154        ("rewrote" . "rewrite") ("rewritten" . "rewrite")
155        ("rode" . "ride") ("ridden" . "ride")
156        ("rang" . "ring") ("rung" . "ring")
157        ("rose" . "rise") ("risen" . "rise")
158        ("ran" . "run")
159        ("sawn" . "saw")
160        ("said" . "say")
161        ("saw" . "see") ("seen" . "see")
162        ("sought" . "seek")
163        ("sold" . "sell")
164        ("sent" . "send")
165        ("sewn" . "sew")
166        ("shook" . "shake") ("shaken" . "shake")
167        ("shaven" . "shave")
168        ("shorn" . "shear")
169        ("shone" . "shine") ("shone" . "shine")
170        ("shat" . "shit")
171        ("shod" . "shoe")
172        ("shot" . "shoot")
173        ("shown" . "show")
174        ("shrank" . "shrink") ("shrunk" . "shrink") ("shrunken" . "shrink")
175        ("shrove" . "shrive") ("shriven" . "shrive")
176        ("sang" . "sing") ("sung" . "sing")
177        ("sank" . "sink") ("sunk" . "sink") ("sunken" . "sink")
178        ("sat" . "sit")
179        ("slew" . "slay") ("slain" . "slay")
180        ("slept" . "sleep")
181        ("slid" . "slide")
182        ("slung" . "sling")
183        ("slunk" . "slink")
184        ("smelt" . "smell")
185        ("smote" . "smite") ("smitten" . "smite")
186        ("sown" . "sow")
187        ("spoke" . "speak") ("spoken" . "speak")
188        ("sped" . "speed")
189        ("spelt" . "spell")
190        ("spellbound" . "spellbind")
191        ("spent" . "spend")
192        ("spilt" . "spill")
193        ("spun" . "spin") ("span" . "spin")
194        ("spat" . "spit")
195        ("spoilt" . "spoil")
196        ("sprang" . "spring") ("sprung" . "spring")
197        ("stood" . "stand")
198        ("stove" . "stave")
199        ("stole" . "steal") ("stolen" . "steal")
200        ("stuck" . "stick")
201        ("stung" . "sting")
202        ("stank" . "stink") ("stunk" . "stink")
203        ("strewn" . "strew")
204        ("strode" . "stride") ("stridden" . "stride")
205        ("struck" . "strike") ("stricken" . "strike")
206        ("strung" . "string")
207        ("strove" . "strive") ("striven" . "strive")
208        ("swore" . "swear") ("sworn" . "swear")
209        ("swept" . "sweep")
210        ("swollen" . "swell")
211        ("swam" . "swim") ("swum" . "swim")
212        ("swung" . "swing")
213        ("took" . "take") ("taken" . "take")
214        ("taught" . "teach")
215        ("tore" . "tear") ("torn" . "tear")
216        ("telecasted" . "telecast")
217        ("told" . "tell")
218        ("thought" . "think")
219        ("throve" . "thrive") ("thriven" . "thrive")
220        ("threw" . "throw") ("thrown" . "throw")
221        ("thrust" . "thrust") ("thrust" . "thrust")
222        ("trod" . "tread") ("trodden" . "tread")
223        ("unbent" . "unbend")
224        ("unbound" . "unbind")
225        ("underwent" . "undergo") ("undergone" . "undergo")
226        ("understood" . "understand")
227        ("undertook" . "undertake") ("undertaken" . "undertake")
228        ("undid" . "undo") ("undone" . "undo")
229        ("woke" . "wake") ("woken" . "wake")
230        ("wore" . "wear") ("worn" . "wear")
231        ("wove" . "weave") ("woven" . "weave")
232        ("wept" . "weep")
233        ("won" . "win")
234        ("wound" . "wind")
235        ("withdrew" . "withdraw") ("withdrawn" . "withdraw")
236        ("withheld" . "withhold")
237        ("withstood" . "withstand")
238        ("wrought" . "work")
239        ("wrung" . "wring")
240        ("wrote" . "write") ("written" . "write")
241;;
242        ("does" . "do") ("did" "do")
243        ("could" . "can")
244        ("would" . "will")
245        ("should" . "shall")
246        ("might" . "may")
247;       ("ain't" "be")
248        ))
249
250(defvar nt-english-irreg-nouns-list
251      '(
252        ("children" . "child")
253        ("boxen" . "box") ("oxen" . "ox")
254        ("men" . "man") ("women" . "woman")
255        ("geese" . "goose") ("teeth" . "tooth") ("feet" . "foot") ("mice" . "mouse")
256                                        ; ("those" . "that") ("these" . "this")
257        ))
258
259(defun nt:english-guess-original-form (word)
260  (catch 'block
261    (cond
262     ((null word) (throw 'block nil))
263     ((string= word "") (throw 'block nil))
264         (t nil))
265   
266    (let* ((word-len (length word))
267           (body-1 nil) (suffix-1 nil)
268           (body-2 nil) (suffix-2 nil)
269           (body-3 nil) (suffix-3 nil)
270           (body-4 nil) (suffix-4 nil) (tmp))
271
272      (setq body-1 (substring word 0 -1))
273      (setq suffix-1 (substring word -1 nil))
274
275      (when (>= word-len 2)
276                (setq body-2 (substring word 0 -2))
277                (setq suffix-2 (substring word -2 nil))
278                (when (>= word-len 3)
279                  (setq body-3 (substring word 0 -3))
280                  (setq suffix-3 (substring word -3 nil))
281                  (when (>= word-len 4)
282                        (setq body-4 (substring word 0 -4))
283                        (setq suffix-4 (substring word -4 nil)))))
284     
285      ;; irregular verbs/nouns first.
286      (setq tmp (cdr (assoc word nt-english-irreg-verbs-list)))
287      (when tmp (throw 'block (list tmp)))
288      (setq tmp (cdr (assoc word nt-english-irreg-nouns-list)))
289      (when tmp (throw 'block (list tmp)))
290     
291      (cond
292       ((string= suffix-3 "ves") (list (concat body-3 "fe") (concat body-3 "f") body-1)) ;; -f > -ves
293       ((string= suffix-3 "ies") (list (concat body-3 "y") body-1)) ;; -y > -ies
294       ((string= suffix-3 "oes") (list body-2)) ;; o > o(e)s
295       ((string= suffix-2 "es") (list (concat body-2 "is") body-1 body-2)) ;; (e)s, -is
296       ((string= suffix-1 "s") (list body-1))
297       ((string= suffix-1 "i") (list (concat body-1 "us"))) ;; -us > -i
298       ((string= suffix-1 "a") (list (concat body-1 "um") (concat body-1 "on"))) ;; -um > -a
299       ((string= suffix-2 "ae") (list body-1)) ;; -a > -ae
300       
301                                        ; verb -ed
302       ((string= suffix-4 "nned") (list body-3)) ;; -n > -nned
303       ((string= suffix-4 "dded") (list body-3)) ;; -d > -dded
304       ((string= suffix-4 "tted") (list body-3)) ;; -t > -tted
305       ((string= suffix-4 "pped") (list body-3)) ;; -p > -pped
306       ((string= suffix-4 "gged") (list body-3)) ;; -g > -gged
307       ((string= suffix-4 "cked") (list body-2 body-3)) ;; -c[k] > -cked
308       ((string= suffix-3 "ied") (list (concat body-3 "y"))) ;; -�Ҳ�+y > -ied ��-���+y > yed
309       ((string= suffix-2 "ed") (list body-1 body-2)) ;; (default) -(e) > -ed
310       ((string= suffix-2 "id") (list (concat body-2 "y"))) ;; pay > paid, say > said
311                                        ; verb -ing
312       ((string= suffix-4 "ying") (list (concat body-4 "ie") body-3))
313       ((string= suffix-3 "ing") (list (concat body-3 "e") body-3))
314
315       ((string= suffix-3 "n't") (list body-3))
316       ((string= suffix-3 "'ll") (list body-3))
317       ((string= suffix-3 "'re") (list body-3))
318       ((string= suffix-2 "'m") (list body-2))
319       ((string= suffix-2 "'d") (list body-2))
320       ((string= suffix-2 "'s") (list body-2))
321     
322       (t nil))))) ;; ������ʤ���������������
323
324(defmacro nt:skipit-p (word)
325  `(if (member (downcase ,word) nt-skip-words) t nil))
326
327;;; nt-english.el ends here
Note: See TracBrowser for help on using the browser.