Created
October 13, 2018 07:35
-
-
Save dubkov/b18334d47d48292f4b50ed15f1248498 to your computer and use it in GitHub Desktop.
lab2 nbc import texts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import numpy as np | |
imported_data = [] | |
dir_paths = ['./data/movie_review/neg/', './data/movie_review/pos/'] | |
for dir_path in dir_paths: | |
for filename in os.listdir(dir_path): | |
with open(dir_path + "/" + filename, 'r') as content_file: | |
imported_data.append([content_file.read(), dir_paths.index(dir_path)]) | |
print "READ", len(os.listdir(dir_path)), "FILES from", dir_path | |
X = np.array(imported_data) | |
print X |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment