diff --git a/generators.html b/generators.html index eeb4d8a..9cd9826 100644 --- a/generators.html +++ b/generators.html @@ -156,8 +156,8 @@ def plural(noun): if matches_rule(noun): return apply_rule(noun)
re.sub() function.
-re.search() function to apply the appropriate pluralization rule.
+re.search() function.
+re.sub() function to apply the appropriate pluralization rule.
plural()) with multiple rules, you have the rules data structure, which is a sequence of pairs of functions.
plural() function can be reduced to a few lines of code. Using a for loop, you can pull out the match and apply rules two at a time (one match, one apply) from the rules structure. On the first iteration of the for loop, matches_rule will get match_sxz, and apply_rule will get apply_sxz. On the second iteration (assuming you get that far), matches_rule will be assigned match_h, and apply_rule will be assigned apply_h. The function is guaranteed to return something eventually, because the final match rule (match_default) simply returns True, meaning the corresponding apply rule (apply_default) will always be applied.