webClassifierOptions function

Map<String, Object?> webClassifierOptions(
  1. ClassifierOptions? options
)

Maps common classifier filtering options to the web API.

Implementation

Map<String, Object?> webClassifierOptions(ClassifierOptions? options) {
  if (options == null) return <String, Object?>{};
  return <String, Object?>{
    if (options.displayNamesLocale case final String locale) 'displayNamesLocale': locale,
    if (options.maxResults case final int maxResults) 'maxResults': maxResults,
    if (options.scoreThreshold case final double threshold) 'scoreThreshold': threshold,
    if (options.categoryAllowlist.isNotEmpty) 'categoryAllowlist': options.categoryAllowlist,
    if (options.categoryDenylist.isNotEmpty) 'categoryDenylist': options.categoryDenylist,
  };
}