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 string | |
PRINTABLE = set(string.printable) | |
def remove_non_ascii(text): | |
text = str(text) | |
return filter(lambda x: x in PRINTABLE, text) |
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 | |
""" gets all lines from files in start directory and any subdirectories""" | |
def get_lines_from_files_in_subdirs(start_dir, file_ext): | |
for subdir, dirs, files in os.walk(start_dir): | |
for file in files: | |
if file.endswith(file_ext): | |
lines = lines + [line.strip() for line in open(os.path.join(start_dir, file), 'r')] | |
return lines |
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
def find_key(key, dictionary): | |
for k, v in dictionary.items(): | |
if k == key: | |
yield v | |
elif isinstance(v, dict): | |
for result in find_key(key, v): | |
yield result | |
elif isinstance(v, list): | |
for d in v: | |
for result in find_key(key, d): |
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
from __future__ import absolute_import | |
from __future__ import division | |
from __future__ import print_function | |
# Imports | |
import numpy as np | |
import tensorflow as tf | |
tf.logging.set_verbosity(tf.logging.INFO) |