Initial commit

This commit is contained in:
Gregory Campbell
2021-07-08 21:25:14 -04:00
commit 6fc4bba27f
8 changed files with 360 additions and 0 deletions
Executable
+18
View File
@@ -0,0 +1,18 @@
I amar prestar aen. Han mathon ne nen. Han mathon ne chae. A han noston
ned 'wilith. The world is changed. I feel it in the water. I feel it in
the earth. I smell it in the air.
Much that once was is lost, for none now live who remember it.
It began with the forging of the Great Rings. Three were given to the
Elves, immortal, wisest, and fairest of all beings. Seven to the Dwarf
lords, great miners and craftsman of the mountain halls. And nine...
nine rings were gifted to the race of Men, who above all else desire power.
For within these rings was bound the strength and will to govern each race.
But they were all of them deceived, for another ring was made. In the land
of Mordor, in the fires of Mount Doom, the Dark Lord Sauron forged in
secret a master ring to control all others. And into this ring he poured
his cruelty, his malice, and his will to dominate all life. One ring to
rule them all. One by one, the free lands of Middle-earth fell to the power
of the Ring. But there were some who resisted. A last alliance of Men and
Elves marched against the armies of Mordor, and on the slopes of Mount
Doom, they fought for the freedom of Middle-earth.
Executable
+25
View File
@@ -0,0 +1,25 @@
In a hole in the ground there lived a hobbit. Not a nasty, dirty, wet hole,
filled with the ends of worms and an oozy smell, nor yet a dry, bare, sandy hole
with nothing in it to sit down on or to eat: it was a hobbit-hole, and that
means comfort. It had a perfectly round door like a porthole, painted green,
with a shiny yellow brass knob in the exact middle. The door opened on to a
tube-shaped hall like a tunnel: a very comfortable tunnel without smoke, with
panelled walls, and floors tiled and carpeted, provided with polished chairs,
and lots and lots of pegs for hats and coats - the hobbit was fond of visitors.
The tunnel wound on and on, going fairly but not quite straight into the side of
the hill - The Hill, as all the people for many miles round called it - and many
little round doors opened out of it, first on one side and then on another. No
going upstairs for the hobbit: bedrooms, bathrooms, cellars, pantries (lots of
these), wardrobes (he had whole rooms devoted to clothes), kitchens,
dining-rooms, all were on the same floor, and indeed on the same passage. The
best rooms were all on the left-hand side (going in), for these were the only
ones to have windows, deep-set round windows looking over his garden and meadows
beyond, sloping down to the river. This hobbit was a very well-to-do hobbit, and
his name was Baggins. The Bagginses had lived in the neighbourhood of The Hill
for time out of mind, and people considered them very respectable, not only
because most of them were rich, but also because they never had any adventures
or did anything unexpected: you could tell what a Baggins would say on any
question without the bother of asking him. This is a story of how a Baggins had
an adventure, found himself doing and saying things altogether unexpected. He
may have lost the neighbours' respect, but he gained-well, you will see whether
he gained anything in the end.
+8
View File
@@ -0,0 +1,8 @@
main: wordStat.cob
cobc -x -free -Wall wordStat.cob
old: stat.cob
cobc -x -free -Wall stat.cob
clean:
rm out.txt stats.txt stat wordStat
Executable
+5
View File
@@ -0,0 +1,5 @@
The Lord of the Rings is an epic fantasy saga by the
British author J. R. R. Tolkien, his most popular work
and a sequel to his popular fantasy novel, The Hobbit.
The Lord of the Rings was written during World War II
and originally published in three volumes in 1954 and 1955.
Executable
+130
View File
@@ -0,0 +1,130 @@
identification division.
program-id. text-stats.
environment division.
input-output section.
file-control.
select input-file assign to "text.txt"
organization is line sequential.
select output-file assign to "out.txt"
organization is line sequential.
data division.
file section.
fd input-file.
01 sample-input pic x(80).
fd output-file.
01 output-line pic x(80).
working-storage section.
77 eof-switch pic 9 value 1.
77 exit-switch pic 9.
01 no-of-sentences pic s9(7) comp.
01 no-of-words pic s9(7) comp.
01 no-of-characters pic s9(7) comp.
01 k pic s9(2) comp.
01 input-area.
02 line1 pic x occurs 80 times.
01 output-title-line.
02 filler pic x(31) value spaces.
02 filler pic x(19) value "input text analyzed".
01 output-underline.
02 filler pic x(41)
value " ----------------------------------------".
02 filler pic x(40)
value "----------------------------------------".
01 output-area.
02 filler pic x value space.
02 out-line pic x(80).
01 output-statistics-line-1.
02 filler pic x(20) value spaces.
02 filler pic x(20) value "number of sentences=".
02 out-no-senten pic -(7)9.
01 output-statistics-line-2.
02 filler pic x(19) value spaces.
02 filler pic x(33) value "number of words=".
02 out-no-word pic -(7)9.
01 output-statistics-line-3.
02 filler pic x(19) value spaces.
02 filler pic x(33) value "number of chars=".
02 out-no-char pic -(7)9.
01 output-statistics-line-4.
02 filler pic x(19) value spaces.
02 filler pic x(33)
value "average number of words/sentence=".
02 aver-words-se pic -(4)9.9(2).
01 output-statistics-line-5.
02 filler pic x(20) value spaces.
02 filler pic x(31)
value "average number of symbols/word=".
02 aver-char-wor pic -(4)9.9(2).
procedure division.
open input input-file, output output-file.
move 2 to exit-switch.
perform proc-body until exit-switch is equal to 3.
proc-body.
move zeroes to no-of-sentences, no-of-words, no-of-characters.
move 81 to k.
write output-line from output-title-line after advancing 0 lines.
write output-line from output-underline after advancing 1 line.
move 2 to exit-switch.
perform outer-loop until exit-switch is equal to zero.
outer-loop.
read input-file into input-area at end perform end-of-job.
move input-area to out-line.
write output-line from output-area after advancing 1 line.
subtract 80 from k.
perform new-sentence-proc until exit-switch is equal to zero
or k is greater than 80.
new-sentence-proc.
move 2 to exit-switch.
if line1(k) is not equal to "/"
perform process-loop
until k is greater than 80 or exit-switch is less than 2
else perform output-statistics-proc.
output-statistics-proc.
move no-of-sentences to out-no-senten.
move no-of-words to out-no-word.
move no-of-characters to out-no-char.
divide no-of-sentences into no-of-words
giving aver-words-se rounded.
divide no-of-words into no-of-characters
giving aver-char-wor rounded.
write output-line from output-underline after advancing 1 line.
write output-line from output-statistics-line-1 after advancing 1 line.
write output-line from output-statistics-line-2 after advancing 1 line.
write output-line from output-statistics-line-3 after advancing 1 line.
write output-line from output-statistics-line-4 after advancing 1 line.
write output-line from output-statistics-line-5 after advancing 1 line.
write output-line from output-underline after advancing 1 line.
move zero to exit-switch.
process-loop.
if line1(k) is equal to space
add 1 to no-of-words
add 1 to k
else if line1(k) is not equal to "."
add 1 to k
if line1(k) is not equal to ","
if line1(k) is not equal to ";"
if line1(k) is not equal to "-"
add 1 to no-of-characters
else
next sentence
else
next sentence
else next sentence
else add 1 to no-of-sentences
add 1 to no-of-words
add 3 to k
move 1 to exit-switch.
end-of-job.
close input-file, output-file.
stop run.
Executable
+5
View File
@@ -0,0 +1,5 @@
It may be hard for an egg to turn into a bird: it would be a jolly sight harder
for it to learn to fly while remaining an egg. We are like eggs at present. And
you cannot go on indefinitely being just an ordinary, decent egg. We must be
hatched or go bad.
/
Executable
+3
View File
@@ -0,0 +1,3 @@
I've been waiting for you Obi-Wan. We meet again, at last.
The circle is now complete; when I left you, I was but the
learner, now I am the master. Only a master of evil, Darth.
Executable
+166
View File
@@ -0,0 +1,166 @@
*> Program Created by Gregory Campbell
identification division.
program-id. wordStat.
environment division.
input-output section.
file-control.
*>I set up the input and output files so the input file name is dynamic whereas the
*>output file is always created with the same name
select input-file assign to dynamic fname
organization is line sequential
file status is inputFS.
select output-file assign to "stats.txt"
organization is line sequential
file status is outputFS.
data division.
file section.
*>Declaration of all the variables used throughout the program
fd input-file.
01 finput pic x(80).
fd output-file.
01 foutput pic x(80).
working-storage section.
77 endOfFile pic 9 value 1.
77 inputFS pic xx.
77 outputFS pic xx.
77 fname pic x(30).
01 numSent pic s9(7) comp.
01 numWords pic s9(7) comp.
01 numChar pic s9(7) comp.
01 numNums pic s9(7) comp.
01 linePos pic s9(2) comp.
01 skip pic s9(2) comp.
01 input-area.
02 charScan pic x occurs 80 times.
01 output-title.
02 filler pic x(20) value "INPUT TEXT ANALYZED:".
01 output-underline.
02 filler pic x(40)
value "----------------------------------------".
02 filler pic x(40)
value "----------------------------------------".
01 output-area.
02 filler pic x value space.
02 out-line pic x(80).
01 output-stat-1.
02 filler pic x(20) value "number of sentences=".
02 outSent pic -(7)9.
01 output-stat-2.
02 filler pic x(16) value "number of words=".
02 outWords pic -(7)9.
01 output-stat-3.
02 filler pic x(16) value "number of chars=".
02 outChar pic -(7)9.
01 output-stat-4.
02 filler pic x(16) value "number of nums=".
02 outNums pic -(7)9.
01 output-stat-5.
02 filler pic x(33)
value "average number of words/sentence=".
02 averWordSent pic -(4)9.9.
01 output-stat-6.
02 filler pic x(31)
value "average number of symbols/word=".
02 averCharWord pic -(4)9.9.
*>Program starts by asking the user to input the name of the file that will be analyzed
procedure division.
display "Input filename: ".
accept fname.
*>checks if file exists, program ends if it doesnt exist
open input input-file.
if inputFS not = "00"
if inputFS = "35"
display "File not found: ", fname
stop run
end-if
end-if.
open output output-file.
write foutput from output-title after advancing 0 lines.
compute numSent = 0.
compute numWords = 0.
compute numChar = 0.
compute numNums = 0.
*> calls function that runs until the file is completely analyzed
perform readFile
until endOfFile is = 0.
*>stat values are moved into output variables and all output
*>is put onto the output file
compute outSent = numSent.
compute outWords = numWords.
compute outChar = numChar.
compute outNums = numNums.
compute averWordSent = numWords / numSent.
compute averCharWord = numChar / numWords.
write foutput from output-underline after advancing 1 line.
write foutput from output-stat-1 after advancing 1 line.
write foutput from output-stat-2 after advancing 1 line.
write foutput from output-stat-3 after advancing 1 line.
write foutput from output-stat-4 after advancing 1 line.
write foutput from output-stat-5 after advancing 1 line.
write foutput from output-stat-6 after advancing 1 line.
write foutput from output-underline after advancing 1 line.
close input-file.
close output-file.
display "Word Statistics generated to stats.txt".
stop run.
*>function that goes through everyline of the file until end of file is reached
*>writes every line of this file into the output file
*>calls a function that looks at every character
readFile.
compute linePos = 81.
read input-file into input-area
at end compute endOfFile = 0
end-read.
if endOfFile is not = 0
move input-area to out-line
write foutput from output-area after advancing 1 line
end-if.
compute linePos = 0.
perform statCheck
until linePos is > 80 or endOfFile is = 0.
*>function looks at every character in the file in order to determine
*>what statistic can be found based on the character and possibly
*>the character in after it depending on the character
statCheck.
compute skip = 0.
if charScan(linePos) is equal to space
compute linePos = linePos + 1
if charScan(linePos) is not equal to space
compute numWords = numWords + 1
else
compute skip = skip + 1
else if charScan(linePos) is equal to "." or "!" or "?"
compute numSent = numSent + 1
compute linePOs = linePos + 1
else if charScan(linePos) is numeric
compute linePos = linePos + 1
if charScan(linePos) is numeric
compute skip = skip + 1
else
compute numNums = numNums + 1
else if charScan(linePos) is not alphabetic
compute linePos = linePos + 1
else
compute numChar = numChar + 1
compute linePos = linePos + 1.
end-of-job.