Esempio n. 1
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);
        }
Esempio n. 2
0
        private string CleanParagraph(string item)
        {
            var cleaned = HtmlCleaner.StripTags(item);

            return(HtmlCleaner.StripWhitespace(cleaned));
        }