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

Create translator options #2145

Merged
merged 2 commits into from
Nov 18, 2022
Merged

Commits on Nov 18, 2022

  1. Create translator options

    This creates a new tool for TranslatorOptions based on the characteristic
    function ((InputClass, OutputClass) -> Translator). Unlike the
    TranslatorFactory, it doesn't require arguments or a model. So, the
    TranslatorFactory is mainly used as part of model loading where the
    TranslatorOptions can be more broad.
    
    In particular, it connects to both Dataset and Translator. Both of them gain a
    new function that will return a TranslatorOptions (matchingTranslatorOptions for
    the Dataset and getExpansions for the translator). Right now, I made both of
    these optional with a default value of null so that users don't have to define
    them, it is just a possibility.
    
    To connect the TranslatorOptions and TranslatorFactory, I created a class
    ExpansionTranslatorFactory. This is used for the common abstraction where we
    have a base translator and multiple "expansions" for it that come before it in
    pre-processing or after it in post-processing. With a way to construct the base
    translator with the options, it works as a TranslatorFactory. With a starting
    Translator, it can become the TranslatorOptions.
    
    Lastly and probably worth calling out, the ExpansionTranslatorFactory creates a
    map of the options. This allows the supported types and the functions to be
    defined in only one place instead of two. In a followup PR, I will make a
    version of this that creates a BaseImageTranslatorFactory matching the
    BaseImageTranslator and will handle all of the repeated code for all of the
    image translator factories.
    zachgk authored and frankfliu committed Nov 18, 2022
    Configuration menu
    Copy the full SHA
    7f0f18f View commit details
    Browse the repository at this point in the history
  2. minor javadoc updates

    frankfliu committed Nov 18, 2022
    Configuration menu
    Copy the full SHA
    6a38960 View commit details
    Browse the repository at this point in the history