Skip to content

Instantly share code, notes, and snippets.

@jgc128
Last active October 17, 2015 01:42
Show Gist options
  • Save jgc128/75964e86b05d760b8158 to your computer and use it in GitHub Desktop.
Save jgc128/75964e86b05d760b8158 to your computer and use it in GitHub Desktop.
Code for homework 1 (2015 Fall NLP Class)
import os
base_dir = '/data1/aromanov/study/2015_fall/nlp/homeworks/hw1/'
brit3_filename = os.path.join(base_dir, 'brit3-excerpt.txt')
brit3_marked_filename = os.path.join(base_dir, 'brit3-excerpt-marked.txt')
problem4_text_filename = os.path.join(base_dir, 'problem4.txt')
def load_documents_from_dir(directory):
files = [os.path.join(directory, f) for f in os.listdir(directory)]
docs = []
for fl in files:
with open(fl, 'r') as f:
d = f.read()
docs.append(d)
return docs
def load_file(filename):
with open(filename, 'r') as f:
result = f.read()
return result
def load_file_lines(filename):
with open(filename, 'r') as f:
lines = f.readlines()
result = [l.strip('\n') for l in lines]
return result
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment