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

Sourcery refactored refactor-generate-features-module branch #30

Merged
Show file tree
Hide file tree
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
3 changes: 1 addition & 2 deletions nlp_profiler/numbers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ def gather_whole_numbers(text: str) -> list:
if not isinstance(text, str):
return []

line = re.findall(r'[0-9]+', text)
return line
return re.findall(r'[0-9]+', text)
Copy link
Author

Choose a reason for hiding this comment

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

Function gather_whole_numbers refactored with the following changes:

  • Inline variable that is immediately returned (inline-immediately-returned-variable)



def count_whole_numbers(text: str) -> int:
Expand Down
2 changes: 1 addition & 1 deletion nlp_profiler/sentiment_polarity.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def sentiment_polarity(score: float) -> str:

score = float(score)
score = (score + 1) / 2 # see https://stats.stackexchange.com/questions/70801/how-to-normalize-data-to-0-1-range
score = score * 100
score *= 100
Copy link
Author

Choose a reason for hiding this comment

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

Function sentiment_polarity refactored with the following changes:

  • Replace assignment with augmented assignment (aug-assign)

for _, each_slab in enumerate(sentiment_polarity_to_words_mapping): # pragma: no cover
# pragma: no cover => early termination leads to loss of test coverage info
if (score >= each_slab[1]) and (score <= each_slab[2]):
Expand Down
3 changes: 1 addition & 2 deletions nlp_profiler/stop_words.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ def gather_stop_words(text: str) -> list:
return []

word_tokens = word_tokenize(text)
found_stop_words = [word for _, word in enumerate(word_tokens)
return [word for _, word in enumerate(word_tokens)
if word in STOP_WORDS]
return found_stop_words
Comment on lines -18 to -20
Copy link
Author

Choose a reason for hiding this comment

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

Function gather_stop_words refactored with the following changes:

  • Inline variable that is immediately returned (inline-immediately-returned-variable)



def count_stop_words(text: str) -> int:
Expand Down
2 changes: 1 addition & 1 deletion slow-tests/performance_tests/test_perf_grammar_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ def generate_data() -> list:
text_with_punctuations, text_with_a_date, text_with_dates, text_with_duplicates]

new_data = []
for index in range(1):
for _ in range(1):
Copy link
Author

Choose a reason for hiding this comment

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

Function generate_data refactored with the following changes:

  • Replace unused for index with underscore (for-index-underscore)

new_data.extend(data)
return new_data
2 changes: 1 addition & 1 deletion slow-tests/performance_tests/test_perf_spelling_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ def generate_data() -> list:
text_with_punctuations, text_with_a_date, text_with_dates, text_with_duplicates]

new_data = []
for index in range(1):
for _ in range(1):
Copy link
Author

Choose a reason for hiding this comment

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

Function generate_data refactored with the following changes:

  • Replace unused for index with underscore (for-index-underscore)

new_data.extend(data)
return new_data