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

API Set parameters with the builder pattern #57

Merged
merged 12 commits into from
Jul 22, 2019
Merged

API Set parameters with the builder pattern #57

merged 12 commits into from
Jul 22, 2019

Conversation

rth
Copy link
Owner

@rth rth commented Jul 22, 2019

This refactors the API to enable setting parameters with the builder pattern, e.g.

let tokenizer = VTextTokenizerParams::default()
     .lang("en")
     .build()
     .unwrap();

which in this case is equivalent to VTextTokenizer::default().

Vectorizers can similarly be intialized with,

let vect = CountVectorizerParams::default()
           .tokenizer(tokenizer.clone())
           .n_jobs(4)
           .build()
           .unwrap();

with the default implementations with e.g. CountVectorizer::<VTextTokenizer>::default(). The API may still change somewhat in this latter part.

Model parameters are now consistently stored as,

struct Model {
  params: ModelParams,
  // + weights etc
}

I have not used derive_builder so far, so this does add some boilerplate in the code.

@rth rth changed the title API Setting parameters with the builder pattern API Set parameters with the builder pattern Jul 22, 2019
@rth rth merged commit c6e20a9 into master Jul 22, 2019
@rth rth deleted the builder-config branch July 22, 2019 13:07
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.

None yet

1 participant