home *** CD-ROM | disk | FTP | other *** search
-
- 20 Gosub Screen'erase
- 30 @"Spelling Program"
- 40 @"By David E. Trachtenbarg"
- 50 @"Copyright 1981"
- 60 Integer I,J,Sector,Record,Finish,Start'word,End'word,Endings
- 70 Integer Bitmask(15),In'dictionary,To'check
- 80 Sector=128
- 90 Dim Eof$(1),String$(10),Text'file$(13),Root$(14),Word'check$(15)
- 100 Dim Dictionary$(13),Check'words$(13),Text$(Sector*2)
- 110 Dim Command$(10),Suffixes$(20),Suffix$(2)
- 120 Dim Uppercase$(25),Lowercase$(25),Numbers$(11),Letters$(63)
- 130 Uppercase$="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- 140 Lowercase$="abcdefghijklmnopqrstuvwxyz"
- 150 Numbers$="0123456789'@"
- 160 Letters$=Uppercase$+Lowercase$+Numbers$
- 170 Eof$=Chr$(26)+Chr$(27)
- 180 Dictionary$="DICTION.DAT"
- 190 Check'words$="CHECK.DAT"
- 200 For I=0 To 6
- 210 Read Suffixes$(I*3,(I+1)*3-1)
- 220 Next I
- 230 Data"es","s","ed","d","ing","ly","y"
- 240 Set 0,-1
- 250 Gosub Set'masks
- 260 Gosub Enter'text'file
- 270 Gosub Set'record
- 280 On Esc Goto Ender
- 290 On Error Goto 350
- 300 Open\1,Sector,1\Text'file$
- 310 Kopen\2\Dictionary$
- 320 Kopen\3\Check'words$
- 330 Gosub Get'file
- 340 Gosub Count
- 350 Close
- 360 Gosub Print'results
- 390 Goto 260
- 400 *Screen'erase
- 410 Out 1,126 : Out 1,28 : Return
- 420 *Enter'text'file
- 430 Repeat
- 440 Set 3,0
- 450 @ : @"Press RETURN to go to the menu."
- 470 Input"To check a text file, enter its name. ",Text'file$
- 480 If Text'file$="" Then Run"SMENU.SAV"
- 490 On Error Goto 520
- 500 Open\1\Text'file$
- 510 Close\1\
- 520 If Sys(3)>0 Then Do
- 530 @ : @"Error ";Sys(3);" has occured."
- 540 If Sys(3)=128 Or Sys(3)=134 Then @"File does not exist on disk."
- 550 If Sys(3)=129 Then @"Please enter a filename."
- 560 If Sys(3)=131 Then Close\1\ : @"File not ready. Please try again."
- 570 Enddo
- 580 Until Sys(3)=0
- 590 On Error Stop
- 600 Return
- 610 *Set'record
- 620 @ : @"Press RETURN to start with record 0"
- 630 Input"Or type a record number to start at: ",String$
- 640 If String$="" Then Record=-1 : Return
- 650 Record=Val(String$)-1
- 660 If Record<-1 Then Record=-1
- 670 Return
- 680 *Get'file
- 690 Text$(0,Sector-1)=Text$(Sector,Sector*2-1)
- 700 Record=Record+1
- 710 Get\1,Record\Text$(Sector,Sector*2-1)
- 720 Finish=Pos(Text$,Eof$(0,0),0)
- 730 If Finish=-1 Then Finish=Sector*2
- 740 I=Sector
- 750 Start'word=Start'word-Sector
- 760 Return
- 770 *Count
- 780 I=Sector
- 790 While Pos(Letters$,Text$(I,I),0)=-1 And I<=Finish
- 800 I=I+1
- 810 If I=Sector*2 Then Gosub Get'file
- 820 Endwhile
- 830 Repeat
- 840 Start'word=I
- 850 End'word=-2
- 860 While End'word=-2 And I<Finish
- 870 If Pos(Letters$,Text$(I,I),0)=-1 Then End'word=I-1
- 880 If End'word=-2 Then I=I+1
- 890 If I=Sector*2 Then Gosub Get'file
- 900 Endwhile
- 910 If I<Finish Then Gosub Spelling
- 920 While Pos(Letters$,Text$(I,I),0)=-1 And I<Finish
- 930 I=I+1
- 940 If I=Sector*2 Then Gosub Get'file
- 950 Endwhile
- 960 Until I>=Finish
- 970 Return
- 980 *Spelling
- 990 Word'check$=Text$(Start'word,End'word)
- 1000 If Len(Word'check$)<4 Then Return
- 1010 If Asc(Word'check$(0,0))<65 Then Return
- 1020 Gosub Lower
- 1030 If Pos(Word'check$,"'",0)>-1 Then Do
- 1040 Local K
- 1050 K=Pos(Word'check$,"'",0)
- 1060 If Word'check$(K+1,K+1)=Chr$(0) Then Word'check$(K,K)=Chr$(0)
- 1070 If Word'check$(K+1,K+1)="s" Then Word'check$(K,K)=Chr$(0) : Word'check$(K+1,K+1)=Chr$(0)
- 1080 Enddo
- 1090 If Len(Word'check$)>15 Then Goto 1210
- 1100 On Error Goto 1140
- 1110 Kgetkey\2,Word'check$(0,14)\
- 1120 In'dictionary=In'dictionary+1
- 1130 @ Word'check$;" OK" : Return
- 1140 On Error Stop
- 1150 Call .Check'for'root (Word'check$)
- 1160 On Error Stop
- 1170 If Found>0 Then @ Word'check$;" OK" : In'dictionary=In'dictionary+1 : Return
- 1180 @ Word'check$;" CHECK";
- 1190 To'check=To'check+1
- 1200 @ Using" ###.##%",(100.0*To'check)/(To'check+In'dictionary)
- 1210 On Error Goto 1230
- 1220 Kadd\3,Word'check$(0,14)\
- 1230 On Error Goto 350
- 1240 Return
- 1250 *Lower
- 1260 Local I
- 1270 For I=0 To Len(Word'check$)-1
- 1280 If Word'check$(I,I)>"@" And Word'check$(I,I)<"]" Then Word'check$(I,I)=Chr$(Asc(Word'check$(I,I))+32)
- 1290 Next I
- 1300 Return
- 1310 Procedure .Check'for'root (Word$)
- 1320 Local I,J,K
- 1330 I=Len(Word$)
- 1340 Found=0 : K=0
- 1350 Repeat
- 1360 K=K+1
- 1370 Suffix$=Suffixes$((K-1)*3,K*3-1)
- 1380 J=Len(Suffix$)
- 1390 If Word$(I-J,I-1)=Suffix$ Then Do
- 1400 Root$=Word$(0,I-J-1)
- 1410 On Error Goto 1440
- 1420 Kgetkey\2,Root$(-1)\Endings
- 1430 If Binand(Endings,Bitmask(K-1))>0 Then Found=K
- 1440 Enddo
- 1450 On Error Stop
- 1460 Until Found>0 Or K>=7
- 1470 Endproc
- 1480 *Print'results
- 1485 @ : @"File examined = ";Text'file$
- 1490 @"Number of words examined = ";In'dictionary+To'check
- 1500 @"Percent in dictionary = ";
- 1505 Print Using"###.##%",(100.0*In'dictionary)/(In'dictionary+To'check)
- 1510 @
- 1520 Return
- 1530 *Ender
- 1540 Close
- 1550 @ : @"Ended at record ";Record : @
- 1555 Gosub Print'results
- 1560 End
- 1570 *Set'masks
- 1580 Local I,J
- 1590 Bitmask(0)=1 : J=1
- 1600 For I=1 To 14
- 1610 J=J*2
- 1620 Bitmask(I)=J
- 1630 Next I
- 1640 Return
-