You will need to find a way to detect where the text starts and ends (warning: there is more text after the book, which you will need to figure out how to get rid of). This means that you must use search strategies to detect where these things are and store the values in variables. In other words, you can use position numbers in your code, so long as you are using a python tool to find those position numbers. find(), etc to find the start and end positions and then slice, but you may not add these position numbers directly into your code. o If you are doing anything 27 separate times in your code, you are hard coding. But again, you can’t do this for each chapter. o You absolutely can use split, though, on specific text. More details: o you can look for text that says “CHAPTER I” or “CHAPTER” but you cannot do this 27 times to find all the chapters).This will let you complete the assignment so you can get points on the other elements. If you a struggling and want to hard code these things in, you’ll only lose small points on that element. I’m also happy to answer any emails to ask if the method you are using is hard coding. If I see anything that looks like hard coding, I’ll tell you. Navigating this can be tricky, which is where the check in comes in. You may not hard code any line numbers, position numbers, or chapter numbers into your script (as in explicitly list a line number for the text in the code. o The content of your chapter files needs to look exactly as it does from the original file (but again, don’t worry about extra newlines at the beginning and the end of the file). o This means you’ll need to retain or recreate the newlines within the text file as they appear. o Example: Dracula-Chapter-1.txt should start with “CHAPTER I” and the last line of text should be “sky.” Plus maybe some newlines on either end, but no other text. Don’t worry about extra newlines at the beginning or the end, but you should not have extra newlines between the text lines (watch out for this one). Each chapter file should start with “CHAPTER…” as the first line and contain exactly the text content of that chapter.the chapter number from inside the chapter, so you will need to use some form of a counter. Your job will be to parse through this document, find the individual chapters, and write those out as separate files.
0 Comments
Leave a Reply. |