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

Missing String monkeypatch #2

Open
watzon opened this issue Aug 27, 2019 · 3 comments
Open

Missing String monkeypatch #2

watzon opened this issue Aug 27, 2019 · 3 comments
Assignees

Comments

@watzon
Copy link
Member

watzon commented Aug 27, 2019

Looks like the core_ext for String didn't get ported over to this

@watzon watzon changed the title Missing String monkepatch Missing String monkeypatch Aug 27, 2019
@rmarronnier
Copy link
Member

Exactly. And yet the specs pass fine. Including :

 it "should tokenize and stem with String#tokenize_and_stem" do
   "scoring stinks".tokenize_and_stem.should eq(["score", "stink"])
   "SCORING STINKS".tokenize_and_stem.should eq(["score", "stink"])
 end

That's because the core_ext for String is already included in the tokenizer shard, on which the stemmer depends.

Is there a point to port the same code in all the shards ? :-)

@watzon
Copy link
Member Author

watzon commented Aug 27, 2019

Ahh ok. Tbh I think for things like that we should probably have them included directly in the shard that depends on them. I don't mind having each shard have it's own core_ext because it makes things easier to find.

@rmarronnier
Copy link
Member

I totally understand your concern about finding easily the code.

So why not put the core_ext in cadmium_util (because one way or another, all cadmium shards will depend on it) and then point to its location each time we declare a new extension using it, like this :

# Extends cadmium_util/core_ext

module StringExtension
    def stem(stemmer = Cadmium::PorterStemmer)
      stemmer.stem(self)
    end

    def tokenize_and_stem(stemmer = Cadmium::PorterStemmer, keep_stops = false)
      stemmer.tokenize_and_stem(self, keep_stops)
    end
  end

What do you think ?

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

No branches or pull requests

2 participants