neomatrix369 / nlp_profiler

A simple NLP library allows profiling datasets with one or more text columns. When given a dataset and a column name containing text data, NLP Profiler will return either high-level insights or low-level/granular statistical information about the text in that column.
Other
241 stars 37 forks source link

Refactor granular features #32

Closed neomatrix369 closed 3 years ago

neomatrix369 commented 3 years ago

Inspired by PR #29, related to #28 and partially resolves it (reduces complexity)

sourcery-ai[bot] commented 3 years ago

Sourcery Code Quality Report

❌  Merging this PR will decrease code quality in the affected files by 0.26%.

Quality metrics Before After Change
Complexity 0.00 0.04 ⭐ 0.04 👎
Method Length 25.48 ⭐ 25.96 ⭐ 0.48 👎
Working memory 5.41 ⭐ 5.48 ⭐ 0.07 👎
Quality 91.38% 91.12% -0.26% 👎
Other metrics Before After Change
Lines 523 550 27
Changed files Quality Before Quality After Quality Change
nlp_profiler/generate_features/init.py 85.18% ⭐
tests/granular/test_alphanumeric.py 88.96% ⭐ 88.96% ⭐ 0.00%
tests/granular/test_chars_and_spaces.py 95.62% ⭐ 95.62% ⭐ 0.00%
tests/granular/test_dates.py 91.72% ⭐ 91.72% ⭐ 0.00%
tests/granular/test_duplicates.py 92.53% ⭐ 92.53% ⭐ 0.00%
tests/granular/test_emojis.py 93.46% ⭐ 93.46% ⭐ 0.00%
tests/granular/test_non_alphanumeric.py 91.43% ⭐ 91.43% ⭐ 0.00%
tests/granular/test_numbers.py 93.50% ⭐ 93.50% ⭐ 0.00%
tests/granular/test_punctuations.py 90.75% ⭐ 90.75% ⭐ 0.00%
tests/granular/test_sentences.py 81.39% ⭐ 81.39% ⭐ 0.00%
tests/granular/test_stop_words.py 93.46% ⭐ 93.46% ⭐ 0.00%
tests/granular/test_words.py 92.03% ⭐ 92.03% ⭐ 0.00%

Here are some functions in these files that still need a tune-up:

File Function Complexity Length Working Memory Quality Recommendation
tests/granular/test_sentences.py test_given_a_text_with_sentences_when_counted_then_return_the_count_of_sentences 0 58 ⭐ 18 ⛔ 64.36% 🙂 Extract out complex expressions
nlp_profiler/generate_features/init.py generate_features 2 ⭐ 62 🙂 11 😞 70.70% 🙂 Extract out complex expressions

Legend and Explanation

The emojis denote the absolute quality of the code:

The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request.


Please see our documentation here for details on how these metrics are calculated.

We are actively working on this report - lots more documentation and extra metrics to come!

Let us know what you think of it by mentioning @sourcery-ai in a comment.

codecov-io commented 3 years ago

Codecov Report

Merging #32 into master will not change coverage. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master       #32   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           20        21    +1     
  Lines          358       360    +2     
  Branches        51        51           
=========================================
+ Hits           358       360    +2     
Impacted Files Coverage Δ
nlp_profiler/granular_features/alphanumeric.py 100.00% <ø> (ø)
nlp_profiler/granular_features/chars_and_spaces.py 100.00% <ø> (ø)
nlp_profiler/granular_features/dates.py 100.00% <ø> (ø)
nlp_profiler/granular_features/duplicates.py 100.00% <ø> (ø)
nlp_profiler/granular_features/emojis.py 100.00% <ø> (ø)
nlp_profiler/granular_features/non_alphanumeric.py 100.00% <ø> (ø)
nlp_profiler/granular_features/numbers.py 100.00% <ø> (ø)
nlp_profiler/granular_features/punctuations.py 100.00% <ø> (ø)
nlp_profiler/granular_features/sentences.py 100.00% <ø> (ø)
nlp_profiler/granular_features/stop_words.py 100.00% <ø> (ø)
... and 5 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 5ad0271...affbc44. Read the comment docs.

neomatrix369 commented 3 years ago

Merging, for now, will use the @sourcery-ai generated PRs as guidance to refractor further