Created
October 24, 2018 06:27
-
-
Save kingspp/78e8d2de92b3e3baf51772b31ea86bdd to your computer and use it in GitHub Desktop.
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
import re | |
def generate_label_from_name(name: str): | |
""" | |
:param name: Name for which label has to be generate | |
:return: | |
""" | |
caps_split = sum([list(match) for match in re.findall('([A-Z][^A-Z][a-z]*)|([0-9][A-Z][^A-Z][a-z]*)|([0-9][A-Z][a-z]*)', name)], []) | |
print(caps_split) | |
# exit() | |
if "." in name: | |
return name.split('.')[-1].title() | |
elif '_' in name: | |
return ' '.join(name.split('_')).title() | |
elif ' ' not in name and len(caps_split) > 1: | |
return ' '.join([cap for cap in caps_split if cap!='']) | |
else: | |
return name.title() | |
name = 'Convolution3DLayer' | |
print(generate_label_from_name(name)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment