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

Builders for engines and readers #429

Open
reckart opened this issue Dec 12, 2024 · 0 comments
Open

Builders for engines and readers #429

reckart opened this issue Dec 12, 2024 · 0 comments

Comments

@reckart
Copy link
Member

reckart commented Dec 12, 2024

Is your feature request related to a problem? Please describe.
We have the createEngineDescription and friends methods in uimaFIT. However, their parameters can be a bit confusing. For simple cases, we have a class and then the parameter/value combinations as pairs. However, if we want to add in a type system, type priorities or other stuff, it either becomes a bit fragile to not accidentally intermix those with the parameters or it is plain to possible because no createEngineDescription signature with the respective item exists.

Describe the solution you'd like
It would be nice to have a builder which would allow stuff like this:

var engineDescription = AnalysisEngineDescription.builder(MyAnalsisEngine.class) //
    .withTypeSystem(TypeSystemDescriptionFactory.createTypeSystemDescription()) // can probably be omitted in most cases
    .withParameter(MyAnalsisEngine.PARAM_BLAH, "blub") // single parameter
    .withParameters( // multiples as pairs because it is convenient to not have to repeat "withParameter" all the time
         MyAnalsisEngine.PARAM_FOO, "foo", //
         MyAnalsisEngine.PARAM_BAR, "bar")
    .withTypePriorities(...) //
    .build();

Describe alternatives you've considered
Instead of a normal builder pattern, a customizer pattern could also be used. That might make working with nested elements in the description more convenient. E.g.

var engineDescription = AnalysisEngineDescription.builder(MyAnalsisEngine.class)
    .metadata(md -> md
        .name("My Analysis Engine")
        .vendor("ACME")
        .typeSystem(TypeSystemDescriptionFactory.createTypeSystemDescription()))
    .parameters(params -> params
        .set(MyAnalsisEngine.PARAM_FOO, "foo")
        .set(MyAnalsisEngine.PARAM_BAR, "bar")))
    .build();

Additional context
Important: the new approach should not auto-scan for type system descriptions or similar metadata. Scanning can be slow in certain environments and doing that for every analysis engine etc. is not necesssary. If a CAS needs to be created with a scanned type system, CasFactory.createCas() should be used. It is sufficient if the CAS knows the type system. It is should not be necessary for each and every component to know it (unless you build a pipeline from a bunch of components that each come with their own local partial type system which then needs to be merged into the pipeline system).

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

1 participant