diff --git a/055/FirstFile.txt b/055/FirstFile.txt new file mode 100644 index 0000000..f1ddf0f --- /dev/null +++ b/055/FirstFile.txt @@ -0,0 +1,12 @@ +# This is a comment line. +# Anything after the "#" should +# be ignored. +# bunny +# That one doesn't count! + +The output for this file should be 1. + +bunn ... coffee is good. yes. + +bunny +giraffe diff --git a/055/Project5-5_Assignment.html b/055/Project5-5_Assignment.html new file mode 100644 index 0000000..f0f18dd --- /dev/null +++ b/055/Project5-5_Assignment.html @@ -0,0 +1,237 @@ + + + + + + + +Project 5.5 Assignment + + + + + + + + + + + + + + + + + + +
+

Project 5.5 Assignment

+
+

Table of Contents

+ +
+ + + +
+

1. Videos to watch

+
+

+Links to videos that you may find useful +

+ +
    +
  • +CLI and Python basics +

    + +

    +This shows some of file access basics and terminal access. As long as you are able to access a shell or terminal and launch python with command line options, then you should be fine. See the next section for the FastX links. I have requested that each of you have access. The GNOME interface you will see is very slightly different, but the general topics are the same. +

  • + +
  • +Object Oriented Text Processing +

    + +

    +Probably the most relevant item for getting started doing things most related to this activity. +

  • + +
  • +Directory Access +

    + +

    +Another look at directory access and going through all files in a directory from within a program. This is typically a confusing item students. +

  • +
+
+
+ +
+

2. Getting a Linux GUI going … if you want

+
+

+This piece is presented in class. You are able to access a Linux GUI through a web browser. This is helpful to test to ensure that our code will work on both your own machine (which may be Windows or Mac based) as well as another POSIX environment like a Linux filesystem. +

+ +

+We will be doing some basic processing with the CLI. For now, let’s try it on a Linux machine. You can figure out how to get VSCode setup to work for you with a command line interface later. +

+ +

+We will use the FastX web-based interface. Bucknell has some information at this link: Bucknell LIT Info +

+ +

+Or just use one of these: +

+ +
+
+ + +
+

3. Assignment

+
+
+

+bunny +

+
+ +

+Your goal is to call your program and ask have it count the number of times “bunny” occurs in a text file. The file to be scanned will be passed into your program from the command line. Your program should print out some helpful information to the output, and then write the number of times “bunny” occurs into a separate file. There are two parts to this—scanning a single file, and then scanning through all files in a directory. +

+
+ +
+

3.1. Part 1—Single File

+
+

+Run your bunny-scanning program with the FirstFile.txt and then SecondFile.txt and look at the outputs. Do they match with my output or what you expected it to be? +

+ + +
+
$> python bunny.py FirstFile.txt
+In FirstFile.txt I counted bunny 1 times.
+
+
+ +

+Once this matches, then your program should write the number 1 to the file FirstFile.out. After running your program, printing out the contents of FirstFile.out (I am using the unix command cat to display the file contents) should look like below. +

+ +
+
$> cat FirstFile.out
+1
+
+
+ +

+The cat command will output the contents of a file to the command line. Do your results match? +

+ +
+
$> python bunny.py SecondFile.txt
+In SecondFile.txt I counted bunny 4 times.
+
+
+

+The number 4 should then be written to SecondFile.out. +

+
+
+
+ +
+

4. Second part

+
+

+Now we will pass a directory to the bunny-counting program. When we pass a directory, for each file inside the directory that ends in .txt, you should look for “bunny” in the file. We do not need to worry about recursively descending through all the directories. Print out the number of times that “bunny” is in all the .txt files in the directory and then write your results to a .out file that is inside the directory with the name <directory name>.out, where you replace <directory name> with the name of the directory you scanned. An example will help this make more sense. +

+ +
+
$> python bunny.py ./hare/
+In ./hare/ I counted bunny 10 times.
+
+
+ +

+The number 10 should then be stored in a file named ./hare/hare.out. +

+ +
+
$> cat ./hare/hare.out
+10
+
+
+
+
+ +
+

5. File Locations

+
+

+You can download the files at +https://eg.bucknell.edu/~sjt015/eceg431/p55Items/p55Assignment/project5-5.zip +or +this link: Project 5-5 zip file. +

+
+
+ +
+

6. ZIP FILE CONTENTS

+
+

+The zip file should could contain the following files: +

+
+
+
+
+

Author: Stewart Thomas

+

Created: 2025-09-22 Mon 10:04

+

Validate

+
+ + \ No newline at end of file diff --git a/055/Project5-5_Assignment.pdf b/055/Project5-5_Assignment.pdf new file mode 100644 index 0000000..df89d22 Binary files /dev/null and b/055/Project5-5_Assignment.pdf differ diff --git a/055/SecondFile.txt b/055/SecondFile.txt new file mode 100644 index 0000000..76dda88 --- /dev/null +++ b/055/SecondFile.txt @@ -0,0 +1,17 @@ +# This is a comment line. +# Anything after the "#" should +# be ignored. +# bunny +# This is the second test. +bunny +The output for this file should not be 1. +It shoud be 4. +bun # ny bunny # + . bunny . +. bunny . +hare +. hare . +rabbit #bunny +bunn y +rabbits + bunny diff --git a/055/hare/barf.txt b/055/hare/barf.txt new file mode 100644 index 0000000..1b94ccb --- /dev/null +++ b/055/hare/barf.txt @@ -0,0 +1,9 @@ +# barf.txt +# this is a comment +# Ignore this: bunny +rabbit +hare +hare +giraffe +carrot +The output is zero. diff --git a/055/hare/bee.asm b/055/hare/bee.asm new file mode 100644 index 0000000..79a135d --- /dev/null +++ b/055/hare/bee.asm @@ -0,0 +1,8 @@ + I am an asm file. + You are not. + + bunny + + I like bunnies. + + The output is 1 diff --git a/055/hare/cats.dog b/055/hare/cats.dog new file mode 100644 index 0000000..20d9a41 --- /dev/null +++ b/055/hare/cats.dog @@ -0,0 +1,7 @@ +Obviously dogs are the best. +bunny +bunny +bunny +bunny +bunny +But bunnies are neat too. diff --git a/055/hare/egads.txt b/055/hare/egads.txt new file mode 100644 index 0000000..1ff3252 --- /dev/null +++ b/055/hare/egads.txt @@ -0,0 +1,7 @@ +# egads.txt +# this is a comment +# Ignore this: bunny +bunny +rabbit +bunny bunny +Should output three. diff --git a/055/hare/ynnub.txt b/055/hare/ynnub.txt new file mode 100644 index 0000000..90b10d1 --- /dev/null +++ b/055/hare/ynnub.txt @@ -0,0 +1,12 @@ +# ynnub.txt +# this is a comment +# Ignore this: bunny +bunny bunny bunny bunny +bunny +bunny +# bunny bunny bunny +bunny # bunny +rabbit +bunn y + +I think its 7