normalizeReasons static method

List<NormalizedReason> normalizeReasons(
  1. dynamic reasons
)

Sort variants per reason.

Implementation

static List<NormalizedReason> normalizeReasons(reasons) {
  List<NormalizedReason> normalizedReasons = [];
  for (MapEntry<String, List<DeinflectRule>> reasons
      in deinflectRules.entries) {
    List<Variant> variants = reasons.value
        .map((rule) => Variant(
            kanaIn: rule.kanaIn,
            kanaOut: rule.kanaOut,
            rulesIn: rulesToRuleFlags(rule.rulesIn),
            rulesOut: rulesToRuleFlags(rule.rulesOut)))
        .toList();
    normalizedReasons
        .add(NormalizedReason(reason: reasons.key, variants: variants));
  }
  return normalizedReasons;
}