예제 #1
0
        /// <summary>
        /// Analyzes a single post in search of problems
        /// </summary>
        /// <param name="post">Post to be analyzed, in the form of object from the API</param>
        /// <returns>List of possible problems found, with their probabilities</returns>
        public List <PostProblems> Analyze(CoyoteApi.Post post)
        {
            var output      = new List <PostProblems>();
            var unformatted = CheckForUnformattedCode(post);

            if (unformatted != null)
            {
                output.Add(unformatted);
            }

            return(output);
        }
예제 #2
0
        private NotFormattedCodeFound CheckForUnformattedCode(CoyoteApi.Post post)
        {
            var text = HtmlCleaner.RemoveProperCode(post.html);

            text = HtmlCleaner.RemoveDownloadLinks(text);
            text = HtmlCleaner.RemoveHTMLContent(text);

            foreach (var para in text.Split("</p>").Select(CleanParagraph))
            {
                var result = codeDetector.Predict(para);

                if (result.Prediction && result.Probability > codeDetectorTreshold)
                {
                    return(new NotFormattedCodeFound {
                        Probability = result.Probability, Paragraph = para
                    });
                }
            }

            return(null);
        }