Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

jaykay9999
Copy link

@jaykay9999 jaykay9999 commented Mar 26, 2022

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

@jaraco jaraco force-pushed the jaykay9999-patch-1 branch 2 times, most recently from 4bf0eda to e01ab1c Compare April 6, 2022 00:52
Copy link
Owner

@jaraco jaraco left a 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?

Comment on lines +3895 to +3901
#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
Copy link
Owner

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):
Copy link
Owner

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):
Copy link
Owner

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?

Comment on lines +3937 to +3941
# 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.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make a docstring please.

@jaraco jaraco added the stale label Jul 9, 2022
@jaraco
Copy link
Owner

jaraco commented Jul 9, 2022

Feel free to re-engage on this issue.

@jaraco jaraco closed this Jul 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

number_to_words() convert and replace all numbers in a sentence instead of giving back only converted numbers
2 participants