Last active
March 31, 2017 07:21
-
-
Save sethbunke/6aa0c144baaf08acb53db91331eed285 to your computer and use it in GitHub Desktop.
Create text to integer and integer to text mappings
This file contains hidden or 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
| create_text_lookup_tables = lambda text: ({c: i for i, c in enumerate(set(text))}, dict(enumerate(set(text)))) | |
| vocab_to_int, int_to_vocab = create_text_lookup_tables(['this','is','my','test']) | |
| print(vocab_to_int) | |
| #{'is': 0, 'my': 1, 'this': 2, 'test': 3} | |
| print(int_to_vocab) | |
| #{0: 'is', 1: 'my', 2: 'this', 3: 'test'} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment