Skip to content

Instantly share code, notes, and snippets.

@dubkov
Created October 13, 2018 07:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dubkov/b18334d47d48292f4b50ed15f1248498 to your computer and use it in GitHub Desktop.
Save dubkov/b18334d47d48292f4b50ed15f1248498 to your computer and use it in GitHub Desktop.
lab2 nbc import texts
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