Context: Wikipedia categories and CATfishing

Every Wikipedia article has several categories assigned to it, which you can see when you scroll down to the bottom of the page. There’s also a fun game you can play with these categories called “CATfishing”, where you are given a list of categories and try to guess which page it refers to. You can play a version of this game online at catfishing.net.

It turns out that these categories are just WikiText links, which are written in double square brackets that start with the keyword Category:. For example, here are the list of categories on the page Kichio Allen Arai.

[[Category:1900s births]]
[[Category:1966 deaths]]
[[Category:People from Bainbridge Island, Washington]]
[[Category:University of Washington College of Built Environments alumni]]
[[Category:Harvard Graduate School of Design alumni]]
[[Category:American people of Japanese descent]]
[[Category:Japanese-American internees]]
[[Category:Architects from Seattle]]
[[Category:20th-century American architects]]

Your CATfishing game in C

Your task for this homework will be to write a command-line game that works like CATfishing: The user will be presented with a list of categories, they will input a line of text, and the game will tell them whether it is the correct page or not.

How will the game decide which pages to quiz the user on and how will it get the list of categories to display? The program will be provided with command-line arguments which contain a list of filenames, and each of these files will contain a different category link on each line. By convention, these filenames will end in .category (e.g., Kichio_Allen_Arai.category). Using glob, you can easily pass a list of all the .category files in the current directory with *.category

Wouldn’t it be nice if we had a script that could download Wikipedia articles and extract just the category links from them? Oh wait, you just implemented that in the previous homework 😉

Tip

You can use the scripts you just wrote to download more articles and test out the CATfishing game you create.

Starter code

Compiling

We will use a tool called make to automate compilation, so you don’t have to type long compilation commands. For this assignment we have provided a Makefile which tells make which gcc commands to run. In future assignments you may have to modify or write your own Makefile.

In general, you should be able to just use the following commands:

# Compiles and links the code, displays compiler error messages
make
# Removes binary files (executables, .o files)
make clean
# Runs the testing framework, same as ./test_StringUtils
make test

StringUtils

To make our code more modular, we have created a “library” called StringUtils, documented in StringUtils.h. Your first task will be to implement the helper functions, placing them in a file called StringUtils.c.

Main loop

You have been provided with skeleton code in hw3.c and some comments explaining how you need to fill it out. Do not change any of the existing skeleton code.

Tip

Once you’re done, read the instructions again to see if you overlooked anything.