11 Creating an authorship identification program
This chapter covers
- Writing an authorship identification program using top-down design
- Learning about refactoring code and why you would do it
In chapter 7, we learned about problem decomposition and top-down design when we wrote our Spelling Suggestions program. Here, we’re going to take top-down design to the next level and solve a much larger problem. We’re still doing the same thing as in chapter 7: dividing a problem into subproblems, and further dividing those subproblems into sub-subproblems as needed. And, just like before, we’re looking to design functions with a small number of parameters that return a meaningful and useful result to their caller. It’s also a good sign if we’re able to design functions that are called by multiple other functions—that helps reduce code repetition!
We’re including this chapter because we wanted to provide a more authentic example than the Spelling Suggestions problem we solved in chapter 7. We hope our example here is motivating and feels like a real problem that you could imagine yourself wanting to solve.
In this chapter, we’re going to write a program that tries to identify the unknown author of a mystery book. It’ll be an example of a program that uses artificial intelligence (AI) to make a prediction. We couldn’t resist the opportunity to include an AI example in a book about programming with AI!