Page MenuHomePhabricator

Consider revising the fallback translation approach
Open, Needs TriagePublic

Description

The current approach implies:

  • A translation template requires a minimum of (force-required[1]) translation fields, corresponding to Citoid API's required fields: itemType and title (we do not currently have a template field for url, which is filled in with the translation target's url).
  • If no translation template applies for a translation target, a predefined "fallback template" is used. This fallback template also has (at least) the same minimum force-required translation fields. The current approach dictates that this fallback template is one with all supported template fields set to Citoid selection + no transformation steps.
  • If a user wants to reuse one of Citoid outputs in a template field, they have to explicitly use a Citoid selection step. This may presumably save requests to the Citoid service.
  • If a non-required template field output is invalid, the template is still applicable, but the citation field to which this output would have mapped will be undefined.

This approach saves requests to the Citoid service, because we would only reach them in these two cases:

  1. One of the translation template tried has one or more Citoid selection steps.
  2. There are no applicable templates and the fallback (all-Citoid) template is used.

A possible alternative approach (an "use Citoid except for"-approach) to consider would imply:

  • The concept of force-required fields disappears and translation templates require a minimum of one (any) template fields (a template without any template fields would be a useless template).
  • Just like in the current approach, for a given translation target, translation templates are tried in order and the first applicable template is used. However, if no applicable templates are found, no fallback template is used.
  • The undefined fields of the resulting citation (whether because: 1. a template applies but some template field outputs are invalid, 2. no template applies, or 3. we do not have template fields mapping to these citation fields) are automatically filled in with the corresponding Citoid response.
  • Users can still explicitly use and transform Citoid responses by explicitly using the Citoid selection.

This alternative would imply making one obligatory Citoid request per Web2Cit request, but in many cases this request would have been made anyway (see above).

This alternative may encourage using Web2Cit as it would provide the benefits of both Web2Cit and Citoid translation.

[1] A "required" template field is one whose output must be "valid" for the template to which it belongs to be "applicable".

Event Timeline

Consider cases where Citoid may fail for a given target webpage. If we switch to the "use Citoid except for"-approach, we may need to use fallback values for some main fields (e.g., itemType and title) in case a Citoid response is not available.

A slight variation may be: for any given translation template, use a fallback template field (with predefined translation procedures) for translation fields where no translation procedures have been defined.

This way, if one or more translation procedures have been defined for a given translation field, these procedures will be used even if their output is invalid for the corresponding translation field, and even if this invalid output makes the translation template non-applicable.

To support this approach, we could replace our current fallback template with a template with no template fields (i.e., a template with no translation procedures defined for any translation field). This way, a fallback template field would be used for all translation templates.

We should also have a list of all translation fields supported, and the predefined fallback template field (i.e., the predefined list of procedures) corresponding to each translation field.

This could be implemented in the Web2Cit-Editor this way: for a given translation field, if there is a translation goal defined for that field (tests.json) but there are no translation procedures defined for that field (templates.json), show the fallback template field. Otherwise, if there is no translation goal (and no translation procedures), do not show the fallback template field, to avoid cluttering the editor. Nonetheless, use the fallback template field to return an citation.