Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

remove char_index and index_char files #6

Description

@stevemar

Currently the char_indices.txt and indices_char.txt files are loaded from disk.

char_indices = json.loads(open('char_indices.txt').read())
indices_char = json.loads(open('indices_char.txt').read())
chars = sorted(char_indices.keys())

Upon looking at them, they are the same key & value pairs swapped. I think these can be removed and placed in the notebook, then transposed. Kinda like this:

smartinelli-mac $ python
Python 2.7.10 (default, Jun 10 2015, 19:42:47)
[GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> indices_char ={
"0": "\n",
"1": " ",
"2": "!",
"3": "\"",
"4": "#",
"5": "$",
"6": "%",
"7": "&",
"8": "'",
"9": "(",
"10": ")",
"11": "*",
"12": "+",
"13": ",",
"14": "-",
"15": ".",
"16": "/",
"17": "0",
"18": "1",
"19": "2",
"20": "3",
"21": "4",
"22": "5",
"23": "6",
"24": "7",
"25": "8",
"26": "9",
"27": ":",
"28": ";",
"29": "=",
"30": "?",
"31": "[",
"32": "]",
"33": "a",
"34": "b",
"35": "c",
"36": "d",
"37": "e",
"38": "f",
"39": "g",
"40": "h",
"41": "i",
"42": "j",
"43": "k",
"44": "l",
"45": "m",
"46": "n",
"47": "o",
"48": "p",
"49": "q",
"50": "r",
"51": "s",
"52": "t",
"53": "u",
"54": "v",
"55": "w",
"56": "x",
"57": "y",
"58": "z",
"59": "{",
"60": "}"
}
>>>
>>> print indices_char
{'60': '}', '24': '7', '25': '8', '26': '9', '27': ':', '20': '3', '21': '4', '22': '5', '23': '6', '28': ';', '29': '=', '0': '\n', '2': '!', '4': '#', '6': '%', '8': "'", '59': '{', '58': 'z', '11': '*', '10': ')', '13': ',', '12': '+', '15': '.', '14': '-', '17': '0', '16': '/', '19': '2', '18': '1', '57': 'y', '56': 'x', '51': 's', '50': 'r', '53': 'u', '52': 't', '55': 'w', '54': 'v', '48': 'p', '49': 'q', '46': 'n', '47': 'o', '44': 'l', '45': 'm', '42': 'j', '43': 'k', '40': 'h', '41': 'i', '1': ' ', '3': '"', '5': '$', '7': '&', '9': '(', '39': 'g', '38': 'f', '33': 'a', '32': ']', '31': '[', '30': '?', '37': 'e', '36': 'd', '35': 'c', '34': 'b'}
>>> char_indices = {y:int(x) for x,y in indices_char.iteritems()}
>>> print char_indices
{'\n': 0, '!': 2, ' ': 1, '#': 4, '"': 3, '%': 6, '$': 5, "'": 8, '&': 7, ')': 10, '(': 9, '+': 12, '*': 11, '-': 14, ',': 13, '/': 16, '.': 15, '1': 18, '0': 17, '3': 20, '2': 19, '5': 22, '4': 21, '7': 24, '6': 23, '9': 26, '8': 25, ';': 28, ':': 27, '=': 29, '?': 30, '[': 31, ']': 32, 'a': 33, 'c': 35, 'b': 34, 'e': 37, 'd': 36, 'g': 39, 'f': 38, 'i': 41, 'h': 40, 'k': 43, 'j': 42, 'm': 45, 'l': 44, 'o': 47, 'n': 46, 'q': 49, 'p': 48, 's': 51, 'r': 50, 'u': 53, 't': 52, 'w': 55, 'v': 54, 'y': 57, 'x': 56, '{': 59, 'z': 58, '}': 60}
>>>

where indices_char is https://github.com/MadisonJMyers/deep-learning-language-model/blob/master/code/indices_char.txt
and char_indices is https://github.com/MadisonJMyers/deep-learning-language-model/blob/master/code/char_indices.txt

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions