Mar-07-2019, 02:02 AM
Mar-07-2019, 11:22 PM
with open(os.path.abspath("c:/Python36/kodovi/inauguration.txt"), "r", encoding='latin-1') as file: text = file.read() print(text[0:1000])Yes, this works.
Mar-08-2019, 06:15 AM
(Mar-07-2019, 11:22 PM)Truman Wrote: [ -> ]Yes, this works.That's different is a file path in you other post it's a url.
Then need a web package as mention bye @ichabod801,then it's of course Requests you should use.
import requests import os url = 'http://pythonscraping.com/files/inaugurationSpeech.txt' file_name = os.path.basename(url) response = requests.get(url) with open(file_name,'wb') as f: f.write(response.content)Do not use
encoding='latin-1'
the rule is simple do text show without any problem in Python 3.Then take it out/in with
encoding='utf-8'
.Taking data into Python 3 may sometime require other encoding that utf-8.
s = 'Crème and Spicy jalapeño ☂ ⛄日本語のキ' # Out with open('unicode.txt', 'w', encoding='utf-8') as f_out: f_out.write(s) # Back in with open('unicode.txt', encoding='utf8') as f: data = f.read() print(data)
Output:Crème and Spicy jalapeño ☂ ⛄日本語の
Mar-14-2019, 01:28 AM
http://www.nltk.org/book/ch00.html
I've just started reading this book. Are you maybe familiar if solutions to the problems given in the book can be found on github?
I found this one>
https://github.com/JuliaNeumann/nltk_book_exercises
wondering if there's an 'official' one.
I've just started reading this book. Are you maybe familiar if solutions to the problems given in the book can be found on github?
I found this one>
https://github.com/JuliaNeumann/nltk_book_exercises
wondering if there's an 'official' one.
Mar-14-2019, 04:19 AM
I purchased a copy of this book several years ago.
I just took a look at my epub version of the book, and I always store any example code in the same location as my books.
I have none, so my guess is that there is no 'official' download available.
However that's not an issue with this text as almost all of the example code is done using interactive python, and where not,
the code can easily be cut and pasted.
So, my guess is you use Julia Neumann's version (which I just downloaded), Thanks for the link!
** Added Note ** I'll check into my O'reilly account and see if an official version has been added.
I just took a look at my epub version of the book, and I always store any example code in the same location as my books.
I have none, so my guess is that there is no 'official' download available.
However that's not an issue with this text as almost all of the example code is done using interactive python, and where not,
the code can easily be cut and pasted.
So, my guess is you use Julia Neumann's version (which I just downloaded), Thanks for the link!
** Added Note ** I'll check into my O'reilly account and see if an official version has been added.
Mar-14-2019, 04:25 AM
I actually purchased my copy in Feb of 2015.
But O'Reilly keeps all pertinent data updated on every one of their books, and still no 'official' code download. So there you go.
Again the link you posted looks like a good one.
But O'Reilly keeps all pertinent data updated on every one of their books, and still no 'official' code download. So there you go.
Again the link you posted looks like a good one.
Mar-15-2019, 12:44 AM
Yet, I decided to finish Web Scraping with Python ( I'm on Markov models right now ) by Mitchell before I start a new book. And in the meantime maybe I should start some real project.