public List<TextUnitScore> GetImportantTextUnits(List<Sentence> Sentences)
        {
            var textUnitFrequencyGrader = new Dictionary<TextUnit, long>();
            foreach (var tu in Sentences.SelectMany(s => s.TextUnits))
            {
                if (m_Rules.UnimportantWords.Contains(tu.FormattedValue))
                {
                    continue;
                }

                if (textUnitFrequencyGrader.ContainsKey(tu))
                {
                    textUnitFrequencyGrader[tu]++;
                }
                else
                {
                    textUnitFrequencyGrader.Add(tu, 1);
                }
            }

            return
                textUnitFrequencyGrader.OrderByDescending(kvp => kvp.Value)
                    .Select(kvp => new TextUnitScore {ScoredTextUnit = kvp.Key, Score = kvp.Value})
                    .ToList();
        }
Пример #2
0
 private static Dictionary<string, string> LoadKeyValueRule(XElement doc, string section, string container)
 {
     var dictionary = new Dictionary<string, string>();
     var step1Pre = doc.Elements(section).Elements(container);
     foreach (
         var keyvalue in
             step1Pre.Elements()
                 .Select(x => x.Value)
                 .Select(rule => rule.Split('|'))
                 .Where(keyvalue => !dictionary.ContainsKey(keyvalue[0])))
     {
         dictionary.Add(keyvalue[0], keyvalue[1]);
     }
     return dictionary;
 }