The code provided is not complete. For example you are extracting the text from the pdf but you have included the call to the function in your code. Just for completeness of the article and for first time learners, I would suggest sharing the whole code or providing a link to the whole structures code.