ローマ字入力

 投稿者:しばっち  投稿日:2011年11月13日(日)20時05分38秒
  ローマ字 to 平仮名変換

DIM ROME$(500), NIHON$(500)
DO
   LET  K = K + 1
   READ ROME$(K), NIHON$(K)
LOOP UNTIL ROME$(K)=""
CALL SORT(ROME$, NIHON$, K)
INPUT  PROMPT "文字列=": A$
!'LET A$="shibacchi"
LET  A$ = UCASE$(A$)
DO
   LET  A$ = LTRIM$(A$)
   FOR J=4 TO 1 STEP -1
      LET AA$=LEFT$(A$,J)
      FOR I = 1 TO K
         IF AA$ = ROME$(I) THEN
            PRINT NIHON$(I);
            IF J=2 AND POS("BB CC DD FF GG HH JJ KK PP SS TT ZZ", AA$)<>0 THEN
               LET  A$ = MID$(A$, 2,LEN(A$)-1)
               EXIT FOR
            END IF
            LET  A$ = RIGHT$(A$, LEN(A$)-J)
            EXIT FOR
         END IF
      NEXT I
      IF I<=K THEN EXIT FOR
   NEXT J
LOOP UNTIL A$ = ""
DATA A,あ,I,い,U,う,E,え,O,お
DATA BA,ば,BI,び,BU,ぶ,BE,べ,BO,ぼ
DATA CA,か,CI,ち,CU,く,CE,せ,CO,こ
DATA DA,だ,DI,ぢ,DU,づ,DE,で,DO,ど,TZU,づ
DATA FA,ふぁ,FI,ふぃ,FU,ふ,FE,ふぇ,FO,ふぉ
DATA GA,が,GI,ぎ,GU,ぐ,GE,げ,GO,ご
DATA HA,は,HI,ひ,HU,ふ,HE,へ,HO,ほ
DATA JA,じゃ,JI,じぃ,JU,じゅ,JE,じぇ,JO,じょ
DATA KA,か,KI,き,KU,く,KE,け,KO,こ
DATA LA,ら,LI,り,LU,る,LE,れ,LO,ろ
DATA MA,ま,MI,み,MU,む,MU,め,MO,も
DATA NA,な,NI,に,NU,ぬ,NE,ね,NO,の
DATA PA,ぱ,PI,ぴ,PU,ぷ,PE,ぺ,PO,ぽ
DATA QA,くぁ,QI,くぃ,QU,くぅ,QE,くぇ,QO,くぉ
DATA RA,ら,RI,り,RU,る,RE,れ,RO,ろ
DATA SA,さ,SI,し,SU,す,SE,せ,SO,そ
DATA TA,た,TI,ち,TU,つ,TE,て,TO,と
DATA YA,や,YI,ゐ,YU,ゆ,YE,ゑ,YO,よ
DATA VA,ヴァ,VI,ヴィ,VU,ぶ,VE,ヴェ,VO,ヴォ
DATA WA,わ,WI,うぃ,WU,う,WE,うぇ,WO,を
DATA XA,ざぁ,XI,じぃ,XU,ずぅ,XE,ぜぇ,XO,ぞぉ
DATA ZA,ざ,ZI,じ,ZU,ず,ZE,ぜ,ZO,ぞ
DATA N,ん,NQ,ん,Q,ん,NX,ん,XN,ん
DATA BYA,びゃ,BYI,びぃ,BYU,びゅ,BYE,びぇ,BYO,びょ
DATA GYA,ぎゃ,GYI,ぎぃ,GYU,ぎゅ,GYE,ぎぇ,GYO,ぎょ
DATA HYA,ひゃ,HYI,ひぃ,HYU,ひゅ,HYE,ひぇ,HYO,ひょ
DATA JYA,じゃ,JYI,じぃ,JYU,じゅ,JYE,じぇ,JYO,じょ
DATA KYA,きゃ,KYI,きぃ,KYU,きゅ,KYE,きぇ,KYO,きょ
DATA MYA,みゃ,MYI,みぃ,MYU,みゅ,MYE,みぇ,MYO,みょ
DATA NYA,にゃ,NYI,にぃ,NYU,にゅ,NYE,にぇ,NYO,にょ
DATA PYA,ぴゃ,PYI,ぴぃ,PYU,ぴゅ,PYE,ぴぇ,PYO,ぴょ
DATA RYA,りゃ,RYI,りぃ,RYU,りゅ,RYE,りぇ,RYO,りょ
DATA SYA,しゃ,SYI,しぃ,SYU,しゅ,SYE,しぇ,SYO,しょ
DATA TYA,ちゃ,TYI,ちぃ,TYU,ちゅ,TYE,ちぇ,TYO,ちょ
DATA ZYA,じゃ,ZYI,じぃ,ZYU,じゅ,ZYE,じぇ,ZYO,じょ
DATA BHA,びぁ,BHI,びぃ,BHU,びゅ,BHE,びぇ,BHO,びょ
DATA CHA,ちぁ,CHI,ち,CHU,ちゅ,CHE,ちぇ,CHO,ちょ
DATA PHA,ふぁ,PHI,ふぃ,PHU,ふぅ,PHE,ふぇ,PHO,ふょ
DATA SHA,しゃ,SHI,し,SHU,しゅ,SHE,しぇ,SHO,しょ
DATA TSA,つぁ,TSI,つぃ,TSU,つ,TSE,つぇ,TSO,つぉ
DATA LTU,っ,XTU,っ,LTSU,っ,XTU,っ,XTSU,っ
DATA WRI,らい,XY,っくし,CK,っく,TCHI,っち
DATA BB,っ,CC,っ,DD,っ,FF,っ,GG,っ,HH,っ,JJ,っ,KK,っ,PP,っ,SS,っ,TT,っ,ZZ,っ
DATA LKA,カ,XKA,カ,LKE,ケ,XKE,ケ,X,っくす
DATA "",""
END

EXTERNAL  SUB SORT (A$(), B$(), N)
FOR I=1 TO N-1
   FOR J=I+1 TO N
      IF A$(I)>A$(J) THEN
         SWAP A$(I), A$(J)
         SWAP B$(I), B$(J)
      END IF
   NEXT J
NEXT I
END SUB
 

戻る