Exemple #1
0
        /// <summary>
        /// Handles the source of the data, and operations relating to fetching the data.
        /// </summary>
        /// <param name="choice">The choice of source.</param>
        /// <returns>The records fetched from the chosen source.</returns>
        private static List <string> HandleSource(int choice)
        {
            var     chosenSource = string.Empty;
            dynamic config;
            var     inputs = new List <string>();

            switch (choice)
            {
            case 1:     // Manually entered
                chosenSource = "Manual Entry";

                inputs.Add(ChoiceHelper.TextInput("Enter the message to be analysed and hit enter:"));
                break;

            case 2:     // Sample data
                chosenSource = "Sample Data";

                _dataSource = new TextFile("sample-data.zip");

                inputs.AddRange(_dataSource.FetchData(
                                    ChoiceHelper.NumericalInput("How many records from the sample data should we analyse? [1-10,000]:", 1, 10000)));
                break;

            case 3:     // Custom data
                chosenSource = "Custom Data";

                _dataSource = new TextFile(ChoiceHelper.FilePathInput("File path of your text file (.txt file, 1 entry per line):"));

                inputs.AddRange(_dataSource.FetchData(
                                    ChoiceHelper.NumericalInput("How many records from the data should we analyse? [1-10,000]:", 1, 10000)));
                break;

            case 4:     // Twitter query
                chosenSource = "Twitter";

                config      = Configuration.FetchConfig <TwitterConfig>();
                _dataSource = new Twitter(config);

                inputs.AddRange(_dataSource.SearchData(
                                    ChoiceHelper.TextInput("Enter a search term to search for on Twitter:"),
                                    ChoiceHelper.NumericalInput("How many Tweets should we fetch? [10-100]", 10, 100)));
                break;

            case 5:     // Speech (Default Mic)
                chosenSource = "Speech";

                config      = Configuration.FetchConfig <VoiceConfig>();
                _dataSource = new Voice(config);

                inputs.AddRange(_dataSource.FetchData());
                break;
            }

            Console.WriteLine("");
            Console.WriteLine($"+ Using {chosenSource} as a source for the data +");
            Console.WriteLine("");

            return(inputs);
        }