コード例 #1
0
        public static void DrawCloud(WordsCollectionBuilder wcbuilder, WordNormalizator normalizator, IEnumerable<string> words, CloudBuilder cloudBuilder, WordRenderer renderer, RenderTarget target)
        {
            if (wcbuilder == null)
                throw new ArgumentNullException(nameof(wcbuilder));
            if (normalizator == null)
                throw new ArgumentNullException(nameof(normalizator));

            var wordsSorted = wcbuilder(normalizator, words);
            DrawCloud(wordsSorted, cloudBuilder, renderer, target);
        }
コード例 #2
0
        public void Init()
        {
            var path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? "";
            Environment.CurrentDirectory = path;

            var asm = Assembly.GetAssembly(typeof(Hunspell));
            var type = asm.GetType("NHunspell.MarshalHunspellDll", true);
            var field = type.GetField("nativeDLLPath", BindingFlags.NonPublic | BindingFlags.Static);
            // ReSharper disable once PossibleNullReferenceException
            field.SetValue(null, path);

            var di = new StandardKernel();
            di.Bind<Func<string, Word>>().ToConstant<Func<string, Word>>(s => new Word(s));
            di.Bind<WordNormalizator>().To<SimpleNormalizator>();
            di.Bind<Hunspell>().ToConstant(new Hunspell("ru_RU.aff", "ru_RU.dic"));

            _normalizator = di.Get<WordNormalizator>();
        }
コード例 #3
0
 public static WordsCollection BuildWordCollection(WordNormalizator normalizator, IEnumerable<string> words)
     => new WordsCollection(words.Select(normalizator.Normalize)
         .Where(normalizator.IsWordSuitable)
         .GroupBy(s => s)
         .Select(g => new Word(g.Key) {Weight = g.Count()}));