classifierSettingsJson function

Map<String, Object?> classifierSettingsJson(
  1. ClassifierSettings settings
)

settings named as in Google's JavaScript API, for the browser adapters.

The threshold is always sent, as Google's Python and C APIs apply it: left unset, its JavaScript API applies the model's own threshold (the language detector's drops all but the top language), so the same options would answer differently from the native runtime. A count of zero or less is left unset, which Google reads as every category.

Implementation

Map<String, Object?> classifierSettingsJson(ClassifierSettings settings) => {
  'displayNamesLocale': ?settings.displayNamesLocale,
  if (settings.maxResults > 0) 'maxResults': settings.maxResults,
  'scoreThreshold': settings.scoreThreshold,
  if (settings.categoryAllowlist.isNotEmpty)
    'categoryAllowlist': settings.categoryAllowlist,
  if (settings.categoryDenylist.isNotEmpty)
    'categoryDenylist': settings.categoryDenylist,
};