home *** CD-ROM | disk | FTP | other *** search
- 1010 ' Initialization
- 1020 DEFINT A-Z
- 1030 OPTION BASE 1
- 1040 '
- 1050 ' Integers
- 1060 LC = 0 ' line counter
- 1070 WC = 0 ' word counter
- 1080 SC = 0 ' sentence counter
- 1090 INWORD = 0 ' currently building a word? (true/false)
- 1100 WORPART = 0 ' part of a word? (true/false)
- 1110 ENOUGH = 0 ' over 400 words and at end of sentence? (true/false)
- 1120 '
- 1130 ' Strings
- 1140 A$ = "" ' most frequently manipulated string
- 1150 AN$ = "abcdefghijklmnopqrstuvwxyz'1234567890" ' alpha-numerics (kinda)
- 1160 ST$ = ".!?" ' sentence terminators
- 1170 AP$ = ";,)-" + CHR$(34) ' other anotated punctuation
- 1180 '
- 1190 ' Integer Arrays
- 1200 DIM STC(3) ' sentence type counters. Note 3 = LEN(ST$)
- 1210 DIM APC(5) ' other annotated punctuation counters. Note 5 = LEN(AP$)
- 1220 '
- 1230 ' String Arrays
- 1240 DIM TEXT$(100) ' storage for text lines
- 1250 DIM WORD$(500) ' word list
- 1260 '
- 1270 ' Get Filename
- 1280 INPUT "File to analyze"; F$
- 1290 OPEN "I", 1, F$ ' open requested file for input
- 1300 '
- 1310 ' Read the file
- 1320 PRINT "Reading " F$ ", ";
- 1330 WHILE (NOT EOF(1)) AND (LC<100)
- 1340 LC=LC+1
- 1350 LINE INPUT #1, TEXT$(LC)
- 1360 WEND
- 1370 CLOSE
- 1380 '
- 1390 ' build word list
- 1400 PRINT "counting words/punctuation, ";
- 1410 FOR CL = 1 TO LC
- 1420 IF ENOUGH THEN 1610 ' to: @ENDLINE
- 1430 FOR CP = 1 TO LEN(TEXT$(CL))
- 1440 A$ = MID$(TEXT$(CL),CP,1) ' point to current character
- 1450 ' punctuation checks
- 1460 ST = INSTR(ST$,A$) ' sentence termination
- 1470 IF ST<>0 THEN SC=SC+1:STC(ST)=STC(ST)+1:IF WC>450 THEN ENOUGH=-1:ELSE INWORD=0
- 1480 IF ENOUGH THEN 1560 ' to: @ENDWORD
- 1490 PC = INSTR(AP$,A$) ' othar annotated punctuation
- 1500 IF PC<>0 THEN APC(PC)=APC(PC)+1 : INWORD = 0
- 1510 'word build and counter
- 1520 WORDPART = INSTR(AN$,A$) <> 0 ' is this part of a word?
- 1530 IF NOT WORDPART THEN INWORD = 0
- 1540 IF WORDPART AND NOT INWORD THEN WC = WC + 1 : INWORD = -1
- 1550 IF INWORD THEN WORD$(WC)=WORD$(WC)+A$
- 1560 '@ENDWORD
- 1570 NEXT CP
- 1580 ' at end of line, bump word counter
- 1590 IF INWORD AND (NOT ENOUGH) THEN WC=WC+1
- 1600 IF WC=500 THEN ENOUGH=-1
- 1610 '@ENDLINE
- 1620 NEXT CL
- 1630 '
- 1640 ' word lengths calculations
- 1650 PRINT "calculating:"
- 1660 FOR I=1 TO WC
- 1670 IF LEN(WORD$(I))=>5 AND LEN(WORD$(I))=<9 THEN MD=MD+1
- 1680 IF LEN(WORD$(I))=>10 THEN SF=SF+1
- 1690 IF LEN(WORD$(I))=8 THEN MW=MW+1
- 1700 IF LEN(WORD$(I))=9 THEN LW=LW+1
- 1710 NEXT I
- 1720 '
- 1730 ' other calculations
- 1740 AV=INT((WC/SC)+.5)
- 1750 SF=INT((SF+(.8*LW)+(.45*MW))+.5)
- 1760 SW=INT((((WC-(SF+MD))*100)/WC)+.5)
- 1770 MW=INT(((MD*100)/WC)+.5)
- 1780 LW=INT(((SF*100)/WC)+.5)
- 1790 ML=INT((((MD+SF)/WC)*100)+.5)
- 1800 FI=INT((((AV)+((SF*100)/WC))*.4)+.5)
- 1810 '
- 1820 '@REPORT
- 1830 ' report word and sentence count, average length
- 1840 PRINT
- 1850 PRINT "Scanned" WC "words in" SC "sentences."
- 1860 PRINT "Average sentence length:" AV "words."
- 1870 IF AV>19 THEN PRINT " -> Sentences may be too wordy."
- 1880 '
- 1890 ' report sentence type, usage
- 1900 PRINT
- 1910 PRINT STC(1) "direct statement(s)"
- 1920 PRINT APC(3) "parenenthetical remarks"
- 1930 IF APC(3)*4 > SC THEN PRINT " -> Could some of these `asides' stand alone?"
- 1940 PRINT STC(2) "exclamation(s)"
- 1950 IF STC(2)*8 > SC THEN PRINT " -> Calm down. Why are you shouting?"
- 1960 PRINT STC(3) "question(s)"
- 1970 IF STC(3)*5 > SC THEN PRINT " -> Is this some kind of test? Or rhetorical?"
- 1980 '
- 1990 ' report subordinate clause usage
- 2000 PRINT APC(1) "semicolons"
- 2010 IF APC(1)*3 > SC THEN PRINT " -> Try making clauses into separate sentences."
- 2020 PRINT APC(2) "commas"
- 2030 IF APC(2) > SC THEN PRINT " -> Try making clauses into separate sentences."
- 2040 '
- 2050 ' report other punctuation notes
- 2060 PRINT
- 2070 PRINT "Miscellaneous: "APC(4) "hyphen(s); " INT((APC(5)/2)+.5) "quote(s)."
- 2080 '
- 2090 ' word length and usage notes
- 2100 PRINT
- 2110 PRINT "% Short words: "; SW; "(all figures rounded)"
- 2120 PRINT "% Medium words: "; MW
- 2130 PRINT "% Long words: "; LW
- 2140 PRINT "% Medium & Long: "; ML
- 2150 IF ML > 50 THEN PRINT "-> Try to use shorter words"
- 2160 PRINT
- 2170 PRINT " -> FOG Index: "; FI
- 2180 '
- 2190 '
- 2200 ' make sure user got a chance to read it all
- 2210 PRINT
- 2220 PRINT "Repeat display (Y/n)? ";
- 2230 A$=INPUT$(1)
- 2240 IF INSTR("Nn",A$)=0 THEN PRINT "Yes" : GOTO 1820 ' to: @REPORT
- 2250 PRINT "No";
- 2260 '
- 2270 END