public void Execute()
        {
            var analysis = _analyser.Analyse(CannedDrivingData.History);

            Console.Out.WriteLine($"Analysed period: {analysis.AnalysedDuration:g}");
            Console.Out.WriteLine($"Driver rating: {analysis.DriverRating:P}");
        }
Пример #2
0
        public void VaderAnalysis_GivenMessagesAreNegative()
        {
            var negativeMessages = new List <string>
            {
                "This was not what I hoped.",
                "I don't like this at all.",
                "Would not recommend, this is awful."
            };

            var results = _analyser.Analyse(negativeMessages);

            foreach (var result in results)
            {
                Assert.AreEqual(result.SentimentData.Sentiment, "Negative");
            }
        }
Пример #3
0
        public void Execute()
        {
            var analysis = _analyser.Analyse(string.IsNullOrEmpty(DataSourcePath) ? CannedDrivingData.History :
                                             CannedDrivingData.GetPeriods(DataSourcePath), BypassPenlty);

            Console.Out.WriteLine($"Analysed period: {analysis.AnalysedDuration:g}");
            Console.Out.WriteLine($"Driver rating: {analysis.DriverRating:P}");
        }
Пример #4
0
        /// <summary>
        /// Passes the data to to the configured analyser.
        /// </summary>
        /// <param name="input">A list of strings to analyse.</param>
        /// <returns>A list containing all of the results from the tests.</returns>
        public List <AnalysisResult> AnalyseInput(List <string> input)
        {
            var results = new List <AnalysisResult>();

            if (input.Any())
            {
                results.AddRange(_analyser.Analyse(input));
            }

            return(results);
        }
        public void Execute()
        {
            //Get the path of directory in which data files are kept from the configuration file
            //Combine the directory path with the file name provided as input
            string path     = Path.Combine(ConfigurationManager.AppSettings["CannedDataDirectoryPath"], _source);
            var    reader   = ContentReaderLookup.GetContentReader();
            var    parser   = DataParserLookup.GetParser("Csv");
            var    data     = parser.ParseData(reader.ReadData(path));
            var    analysis = _analyser.Analyse(data);

            Console.Out.WriteLine($"Analysed period: {analysis.AnalysedDuration:g}");
            Console.Out.WriteLine($"Driver rating: {analysis.DriverRating:P}");
            Console.Out.WriteLine($"Driver rating after penalty: {analysis.DriverRatingAfterPenalty:P}");
        }
        public void Execute()
        {
            if (string.IsNullOrEmpty(_drivingDataFilePath) || !File.Exists(_drivingDataFilePath))
            {
                throw new FileNotFoundException("Filepath is Empth or does not exist");
            }

            //var analysis = _analyser.Analyse(CannedDrivingData.History, _penalise);
            var analysis = _analyser.Analyse(CannedDrivingData.GetDrivingData(_drivingDataFilePath), _penalise);

            Console.Out.WriteLine($"Analysed period: {analysis.AnalysedDuration:g}");
            Console.Out.WriteLine($"Driver rating: {analysis.DriverRating:P}");
            Console.Out.WriteLine($"Driver penalise: {_penalise}");
            Console.Out.WriteLine($"UnDocumented Period: {analysis.UnDocumentedPeriod}");
        }
        public static HistoryAnalysis Analyse(this IAnalyser analyser, IReadOnlyCollection <Period> history,
                                              bool bypassPenalty, TimeSpan?start = null, TimeSpan?end = null)
        {
            // Note: Assumption here is existing analysers implementation should not be amended
            // It's actually going one step in reverse and some additional computation
            var result = analyser.Analyse(history);

            if (bypassPenalty)
            {
                List <Period> undocumented = null;

                // Assumption is no Stat and End time mentioned
                history.Filter(start ?? TimeSpan.Zero, end ?? TimeSpan.Zero, out undocumented);

                // Double the rating
                result.DriverRating = decimal.Multiply(result.DriverRating, undocumented.Count() > 0 ? 2 : 1);
            }

            return(result);
        }