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

            return(HtmlCleaner.StripWhitespace(cleaned));
        }