I am new to text mining and have been playing around with the code provided in the book Applied Text Analysis With Python. I came to a problem with this specific part:

https://github.com/foxbook/atap/blob/master/snippets/ch08/oz.py

In this python script, most of the code is commented out. Is there a specific reason why someone would do that? What's the correct way to uncomment it?

I am using jupyter notebook, I pasted the code in a cell and deleted one by one each '#', but I think I messed up the indentation.

有帮助吗?

解决方案

Welcome to the site! It looks to me that the code you reference is just showing some example usage for the functions defined above it. There are several reasons someone might do this--sometimes it's so auto-documentation generating code (e.g., doxygen) can pick up the example code for downstream formatting, other times it's so that the reader can identify the code they might need to modify for their own use case. I suspect the latter here. If you're interested in trying to just run the code as written, you could copy it into a text editor like TextMate or VSCode and do a vertical select (usually shift+option+click/drag) to highlight and delete the comment characters!

许可以下: CC-BY-SA归因
scroll top