Skip to content

Instantly share code, notes, and snippets.

@yfwu
Last active September 4, 2019 14:50
Show Gist options
  • Save yfwu/5b15f64c5a69c14f490d63182f316143 to your computer and use it in GitHub Desktop.
Save yfwu/5b15f64c5a69c14f490d63182f316143 to your computer and use it in GitHub Desktop.
modified read_data for generating word array
def read_data_modified(fname):
data = []
with open(fname) as f:
for line in f.readlines():
line = re.sub('[!@#%^&:;,`\.\']', '', line)
data.extend(line.replace('\n', '').strip().lower().split(' '))
return data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment