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

Minor refactor #8

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Minor refactor #8

wants to merge 2 commits into from

Conversation

cmantas
Copy link
Contributor

@cmantas cmantas commented Oct 5, 2016

Minor refactor of the stem method.

Methods `noun_suffix_machine` and `derivational_suffix_machine`
 did not need to take a block (containing a single word) and yield.
They weree refactored to take the word as an argument.
@cmantas cmantas force-pushed the minor_refactor branch 6 times, most recently from 1560434 to 5cafb32 Compare October 5, 2016 13:53
All the stem candidates are appended to the list and uniq! is called once.

# Postprocess
# set of stem candidates
stems = [original_word, *nominal_verbs_suffix_machine(original_word.dup)]
Copy link
Member

Choose a reason for hiding this comment

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

While I agree that this code can be simplified, I'm not sure I agree with this approach:

  • I like the step by step approach of the original. I think it enhances readability.
  • I agree that calls to flatten! can be replaced, though I prefer the + array operator to splatting.
  • Calling uniq! before mapping the array to the noun_suffix_machine method makes sense.
  • I think calls to &method is a bit of a code smell (and I think hinder performance a bit as well, see here).

As a final thought I don't like the need for using dup on the original before calling methods that are not explicitly mutating. Ideally I think these methods should call dup themselves on their arguments. Otherwise I think they should have a bang ! operator in their names.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants