예제 #1
0
        private string FindAndApply(string name, Case @case, RuleSet ruleSet, Dictionary<string, bool> features)
        {
            Rule rule = FindRulesFor(name, ruleSet, features);

            if (rule == null)
                return name;

            return Apply(name, @case, rule);
        }
예제 #2
0
        private string InflectTo(string name, Case @case, RuleSet ruleSet)
        {
            var nameChunks = name.Split('-').ToList();

            return string.Join("-", nameChunks.Select((chunk, index) =>
                {
                    bool firstWord = index == 0 && nameChunks.Count > 1;
                    return FindAndApply(chunk, @case, ruleSet, new Dictionary<string, bool> { { "first_word", firstWord } });
                }));
        }
예제 #3
0
        private Rule FindRulesFor(string name, RuleSet ruleSet, Dictionary<string, bool> features)
        {
            HashSet<string> tags = ExtractTags(features);

            Rule rule;
            if (ruleSet.Exceptions != null)
            {
                rule = Find(name, ruleSet.Exceptions, true, tags);
                if (rule != null)
                    return rule;
            }

            return Find(name, ruleSet.Suffixes, false, tags);
        }