Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions text_processing2.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#######################
# Test Processing II #
# Test Processing II #11
#######################


Expand Down Expand Up @@ -28,7 +28,14 @@ def digits_to_words(input_string):
>>> tp2.digits_to_words(digits_str2)
'three one four one five'
"""
digit_string = None
digit_string = ""
digit_table = {"1": "one", "2": "two", "3": "three", "4": "four", "5": "five", "6": "six", "7": "seven", "8": "eight", "9": "nine", "0": "zero"}

for string in input_string :
if string.isdigit():
digit_string += digit_table[string] + " "
digit_string = digit_string[:-1]

return digit_string


Expand Down Expand Up @@ -64,5 +71,22 @@ def to_camel_case(underscore_str):
>>> tp2.to_camel_case(underscore_str3)
"alreadyCamel"
"""
camelcase_str = None
camelcase_str = ""
underscore_str = underscore_str.strip("_")

if underscore_str.count("_") > 0 :
underscore_str = underscore_str.lower()
no_undersocre_strings = underscore_str.split("_")

if no_undersocre_strings != "":
for i, word in enumerate(no_undersocre_strings):
if word != "":
for j, string in enumerate(word):
if i !=0 and j == 0:
string = string.upper()
camelcase_str += string

else:
camelcase_str = underscore_str

return camelcase_str