Skip to content

Instantly share code, notes, and snippets.

@xumx
Created June 8, 2016 02:28
Show Gist options
  • Save xumx/08ab08266100659086743ab45ee2933a to your computer and use it in GitHub Desktop.
Save xumx/08ab08266100659086743ab45ee2933a to your computer and use it in GitHub Desktop.
Trick for charRNN to represent capitalization
import re
s = 'Hello World'
re.sub( '([A-Z])', '^\\1', s ).lower()
#reverse
s1 = "^hello ^world"
re.sub( '\^(.)', lambda match: match.group( 1 ).upper(), s1 )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment