コード例 #1
0
 public Result <HashSet <string> > InitializeBoringWords(TagCloudCreationOptions options)
 {
     if (options.PathToBoringWords.HasNoValue)
     {
         return(Result.Fail <HashSet <string> >("No path was given"));
     }
     return(boringWords == null?ReadWords(options.PathToBoringWords.Value) : Result.Ok(boringWords));
 }
コード例 #2
0
 public string PrepareWord(string word, TagCloudCreationOptions options)
 {
     if (options.PathToBoringWords == null)
     {
         return(word);
     }
     if (!boringWords.IsValueCreated)
     {
         path = options.PathToBoringWords;
     }
     return(boringWords.Value.Contains(word) ? null : word);
 }
コード例 #3
0
ファイル: ConsoleUserInterface.cs プロジェクト: FunFunFine/fp
        public override void Run(string[] startupArgs)
        {
            parser.Parse(startupArgs);
            if (isHelpShown)
            {
                End();
                return;
            }

            var options = new TagCloudCreationOptions(new ImageCreatingOptions(brush, font, center));

            Read(wordsFile)
            .Then(ws => Creator.CreateImage(ws, options))
            .Then(i => i.Save(outputPath))
            .Then(none => End($"Here you go{Environment.NewLine}\tFile is saved successfully into {outputPath}"))
            .OnFail(err => End(error: err));
        }
コード例 #4
0
ファイル: ConsoleUserInterface.cs プロジェクト: FunFunFine/di
        public override void Run(string[] startupArgs)
        {
            parser.Parse(startupArgs);
            if (isHelpShown)
            {
                End();
                return;
            }

            var options = new TagCloudCreationOptions(new ImageCreatingOptions(brush, font, center));

            if (!TryRead(wordsFile, out var words))
            {
                Console.Error.WriteLine("Can not read given file");
                End();
                return;
            }

            using (var image = Creator.CreateImage(words, options)) image.Save(outputPath);

            Console.Out.WriteLine($"Here you go{Environment.NewLine}\tFile is saved successfully into {outputPath}");
            End();
        }
コード例 #5
0
 public override string PrepareWord(string word, TagCloudCreationOptions options) =>
 ProcessWordByTag(word, (tag, w) => tag == PartOfSpeech.Preposition ? null : w);
コード例 #6
0
 public Result <Maybe <string> > PrepareWord(string word, TagCloudCreationOptions options)
 {
     return(InitializeBoringWords(options)
            .Then(r => r.Contains(word) ? Maybe <string> .None : word));
 }
コード例 #7
0
        /// <inheritdoc cref="IWordPreparer" />
        public string PrepareWord(string word, TagCloudCreationOptions _)
        {
            var preparedWord = word.ToLowerInvariant();

            return(word == string.Empty ? null : preparedWord);
        }