home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DOS/V Power Report 1999 April
/
VPR9904A.BIN
/
Vpr_data
/
Special
/
Yoolw101
/
Yoolw101.lzh
/
ENG2JAP.YO
< prev
next >
Wrap
Lisp/Scheme
|
1998-09-19
|
9KB
|
308 lines
; 英語→日本語変換プログラム
;
; 単語の登録
; (putprop 'word '((品詞の略号 "意味")(品詞の略号 "意味") 'English))
; 例
; (putprop 'I '((n . "私")) 'English)
; (putprop 'have '((vt . "持っている")) 'English)
; (putprop 'a '((def . "1つの")) 'English)
; 単語の意味の取り出し方
; (get 'ward 'English)
;
(setq error '(promp ">>"))
; 文字の最初が大文字なら小文字に変換
; 文字の最後にピリオドがあったら取り除く
(de 'b2l '(lambda(x)(prog(str)
(setq str x)
(if
(or (> (ascii "A") (ascii str)) (< (ascii "Z") (ascii str)))
nil
(setq str (concat
(char (+ (- (ascii str) (ascii "A")) (ascii "a")))
(substr str 2 (strlng str))
))
)
(if
(eq (ascii (substr str (strlng str) (strlng str))) (ascii "."))
(setq str (substr str 1 (- (strlng str) 1)))
)
(return str)
)))
; メインルーチン
(de 'e2j '(lambda()(prog()
(print "*** 英語→日本語 翻訳プログラム ***")
(print " 使い方")
(print " I have a pen.のように入力して下さい。")
(print " 今は、第1文型と第2文型、第3文型の肯定文と")
(print " 命令文しか翻訳出来ません。")
(print " 終了する時は、endとタイプして下さい。")
(promp "E2J>")
(loop(eng x)
(setq eng (sread))
(setq eng (b2l eng))
(if
(not (listp (s2l eng)))
(setq eng (s2l (concat "(" eng ")")))
(setq eng (s2l eng))
)
(cond
((or (eq (car eng) 'end) (eq (car eng) 'END))(return t))
)
(setq x (e2j_bunkatu eng))
(cond
((null x) (print "この英語は、翻訳出来ません!"))
(t (e2j_showj x))
)
)
(print "英語→日本語 翻訳プログラムを終了します!")
(print "再度、起動する時は(e2j)とタイプして下さい。")
(promp ">>")
)))
;
;e2j_bunkatu
; ((主部)(副詞)(直接目的語)(間接目的語)(補語)(述部))
;
(de 'e2j_bunkatu '(lambda(sentence)(prog(SUBJ ADVE VERB COMP IOBJ DOBJ x vtype bunkei meaning)
(setq SUBJ nil)
(setq ADVE nil)
(setq VERB nil)
(setq COMP nil)
(setq IOBJ nil)
(setq DOBJ nil)
(setq x sentence)
; 主部の取り出し
(loop()
(if (null x) (return nil))
(setq meaning (get (car x) 'English))
(cond
((and (null (assoc meaning 'vi)) (null (assoc meaning 'vt)) (null (assoc meaning 'aux)) (null (assoc meaning 'ad)))
(setq SUBJ (append SUBJ (list (car x))))
)
(t (return t))
)
(setq x (cdr x))
)
; 述部の取り出し
(setq sentence nil)
(setq vtype nil)
(loop()
(if (null x) (return nil))
(setq meaning (get (car x) 'English))
(cond
((not (null (assoc meaning 'vi)))
(prog()
(setq VERB (append VERB (list (car x))))
(setq vtype 'vi)
)
)
((not (null (assoc meaning 'vt)))
(prog()
(setq VERB (append VERB (list (car x))))
(setq vtype 'vt)
)
)
((not (null (assoc meaning 'ad)))
(setq ADVE (cons (car x) ADVE))
)
((not (null (assoc meaning 'aux)))
(setq VERB (cons (car x) VERB))
)
(t (setq sentence (append sentence (list (car x)))))
)
(setq x (cdr x))
)
;目的語・補語の取り出し
(cond
((null vtype) nil)
((eq vtype 'vi) (setq COMP sentence))
((eq vtype 'vt) (setq DOBJ sentence))
(t nil)
)
(return (list SUBJ ADVE IOBJ DOBJ COMP VERB))
)))
(de 'e2j_showj '(lambda(sentlist)(prog(meirei)
(setq meirei nil)
(prog()
;主語の翻訳
(cond
((null (car sentlist)) (setq meirei t))
(t (prog()
(e2j_print (car sentlist) nil)
(princ "は、")
))
)
(setq sentlist (cdr sentlist))
;副詞の翻訳
(cond
((null (car sentlist)) nil)
(t (prog()
(e2j_print (car sentlist) 'ad)
))
)
(setq sentlist (cdr sentlist))
;間接目的語の翻訳
(cond
((null (car sentlist)) nil)
(t (prog()
(e2j_print (car sentlist) nil)
(princ "に、")
))
)
(setq sentlist (cdr sentlist))
;直接目的語の翻訳
(cond
((null (car sentlist)) nil)
(t (prog()
(e2j_print (car sentlist) nil)
; (princ "を、")
))
)
(setq sentlist (cdr sentlist))
;補語の翻訳
(cond
((null (car sentlist)) nil)
(t (prog()
(e2j_print (car sentlist) nil)
(princ "")
))
)
(setq sentlist (cdr sentlist))
;動詞の翻訳
(cond
((null (car sentlist)) (print "動詞が見付かりません!"))
(t (prog()
(e2j_print (car sentlist) nil)
(e2j_print (car sentlist) 'aux)
))
)
)
(if meirei
(print "ようにしなさい!")
(print "。")
)
)))
(de 'e2j_print '(lambda(x y)(cond
((null x) nil)
((atom x) (cond
((null y) (cond
((null (get x 'English)) (princ x))
(t (princ (cdar (get x 'English))))
))
(t (cond
((null (assoc (get x 'English) y)) t)
(t (princ (cdr (assoc (get x 'English) y))))
))
))
((not (null y)) (prog()
(e2j_print (car x) y)
(e2j_print (cdr x) y)
))
(t (prog()
(cond
((and (atom (car x)) (null (get (car x) 'English)))
(e2j_print (car x) nil)
)
((null (cdr x))(e2j_print (car x) nil))
(t (prog()
(e2j_print (car x) 'def)
(e2j_print (car x) 'a)
(e2j_print (car x) 'ad)
))
)
(e2j_print (cdr x) nil)
))
)))
(putprop 'I '((n . "私")) 'English)
(putprop 'i '((n . "私")) 'English)
(putprop 'my '((a . "私の")) 'English)
(putprop 'mine '((n . "私の物")) 'English)
(putprop 'you '((n . "あなた")) 'English)
(putprop 'your '((a . "あなたの")) 'English)
(putprop 'yours '((n . "私の物")) 'English)
(putprop 'he '((n . "彼")) 'English)
(putprop 'his '((a . "彼の")(n . "彼の物")) 'English)
(putprop 'she '((n . "彼女")) 'English)
(putprop 'her '((a . "彼女の")) 'English)
(putprop 'hers '((n . "彼女の物")) 'English)
(putprop 'it '((n . "それ")) 'English)
(putprop 'its '((a . "その")) 'English)
(putprop 'this '((n . "これ")(a . "この")) 'English)
(putprop 'that '((n . "あれ")(a . "あの")) 'English)
(putprop 'pen '((n . "ペン")) 'English)
(putprop 'pens '((n . "ペン")) 'English)
(putprop 'pencil '((n . "鉛筆")) 'English)
(putprop 'pencils '((n . "鉛筆")) 'English)
(putprop 'desk '((n . "机")) 'English)
(putprop 'desks '((n . "机")) 'English)
(putprop 'chair '((n . "いす")) 'English)
(putprop 'chairs '((n . "いす")) 'English)
(putprop 'watch '((n . "時計")) 'English)
(putprop 'watches '((n . "時計")) 'English)
(putprop 'student '((n . "学生")) 'English)
(putprop 'students '((n . "学生")) 'English)
(putprop 'teacher '((n . "先生")) 'English)
(putprop 'teachers '((n . "先生")) 'English)
(putprop 'dog '((n . "犬")) 'English)
(putprop 'dogs '((n . "犬")) 'English)
(putprop 'cat '((n . "猫")) 'English)
(putprop 'cats '((n . "猫")) 'English)
(putprop 'apple '((n . "リンゴ")) 'English)
(putprop 'apples '((n . "リンゴ")) 'English)
(putprop 'ogange '((n . "オレンジ")) 'English)
(putprop 'oganges '((n . "オレンジ")) 'English)
(putprop 'name '((n . "名前")) 'English)
(putprop 'hat '((n . "帽子")) 'English)
(putprop 'hats '((n . "帽子")) 'English)
(putprop 'shopping '((n . "買い物")) 'English)
(putprop 'baseball '((n . "野球")) 'English)
(putprop 'tennis '((n . "テニス")) 'English)
(putprop 'swimming '((n . "水泳")) 'English)
(putprop 'English '((n . "英語")(a . "英国の")) 'English)
(putprop 'Japanese '((n . "日本語")(a . "日本語の")) 'English)
(putprop 'one '((n . "物")(n . "1つ")(a . "1つの")) 'English)
(putprop 'another '((n . "もう1つ")) 'English)
(putprop 'two '((n . "2")(a . "2つの")) 'English)
(putprop 'three '((n . "3")(a . "3つの")) 'English)
(putprop 'is '((vi . "です")) 'English)
(putprop 'am '((vi . "です")) 'English)
(putprop 'are '((vi . "です")) 'English)
(putprop 'like '((vt . "を好む")) 'English)
(putprop 'thank '((vt . "に感謝する")) 'English)
(putprop 'have '((vt . "を持っている")) 'English)
(putprop 'get '((vt . "を手に入れる")) 'English)
(putprop 'feel '((vi . "と感じる")) 'English)
(putprop 'play '((vt . "で遊ぶ")(vi . "遊ぶ")) 'English)
(putprop 'make '((vt . "を作る")) 'English)
(putprop 'run '((vi . "走る")) 'English)
(putprop 'go '((vi . "行く")) 'English)
(putprop 'come '((vi . "来る")) 'English)
(putprop 'speak '((vt . "を話す") (vi . "話す")) 'English)
(putprop 'can '((aux . "ことができる")) 'English)
(putprop 'will '((aux . "だろう")) 'English)
(putprop 'must '((aux . "必要がある")) 'English)
(putprop 'may '((aux . "に違いない")) 'English)
(putprop 'a '((def . "1つの")) 'English)
(putprop 'an '((def . "1つの")) 'English)
(putprop 'the '((def . "")) 'English)
(putprop 'good '((a . "良い")) 'English)
(putprop 'fine '((a . "良い")) 'English)
(putprop 'red '((a . "赤い")) 'English)
(putprop 'blue '((a . "青い")) 'English)
(putprop 'green '((a . "緑の")) 'English)
(putprop 'yellow '((a . "黄色い")) 'English)
(putprop 'fast '((ad . "速く")) 'English)
(putprop 'always '((ad . "いつも")) 'English)
(putprop 'sometimes '((ad . "時々")) 'English)
(putprop 'often '((ad . "しばしば")) 'English)
(putprop 'well '((ad . "うまく") (a . "健康")) 'English)
;pleaseは本当は動詞ですが、当翻訳ソフトでは副詞で定義します
(putprop 'please '((ad . "どうか")) 'English)
(putprop 'here '((ad . "ここへ")(n . "ここ")) 'English)
(putprop 'there '((ad . "そこへ")(n . "そこ")) 'English)
" 英文和訳プログラム"
"(e2j):英文和訳プログラムを起動する。後はメッセージに従って英文を"
" 入力してください。"