-
-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added extract_replace() #149
Conversation
4bf0eda
to
e01ab1c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you create some tests and also fix the failing checks?
#this function takes a string and returns an array with indexes of every first and last digit in the sentence. | ||
#example : test_array = find_num_index("In 2019, mark saved $15 thousand, for a total savings of 54 thousand over eight years." ) | ||
#print(test_array) | ||
#output : [3, 6, 21, 22, 57, 58] | ||
# 3 and 6 are the indexes of 2 and 9 of "2019" | ||
# 21 and 22 are the indexes of 1 and 5 of "15" | ||
#and it keeps going |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Documentation for a function should be implemented as a docstring.
# 21 and 22 are the indexes of 1 and 5 of "15" | ||
#and it keeps going | ||
|
||
def find_num_index(entry_string): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This "function" is implemented as a method of "engine", but it's not marked as a staticmethod nor does it take "self" as the first parameter. Do you want an instance method or function? How have you invoked this?
# 21 and 22 are the indexes of 1 and 5 of "15" | ||
#and it keeps going | ||
|
||
def find_num_index(entry_string): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you expect this function to be public or an internal implementation detail?
# extract_replace function takes a sentence with numbers to return a sentence with all its numbers to words. | ||
#this function uses both number_to_words function and find_num_index function | ||
#example : test_sentence = extract_replace("In 2019, mark saved $15 thousand, for a total savings of 54 thousand over eight years." ) | ||
#print(test_sentence) | ||
#output : In two thousand and nineteen, mark saved $fifteen thousand, for a total savings of fifty-four thousand over eight years. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make a docstring please.
Feel free to re-engage on this issue. |
i added two functions : extract_replace() that takes a sentence string and returns the same string with all the number changed to words.
second function is find_num_index() which is only used by extract_replace function, it takes a sentence string and returns an array with indexes of every first and last digits of all numbers in a sentence.
If anything has to be changed or fixed to meet the repository governance please let me know :)
Closes #148