예제 #1
0
        public Analysis GetAnalysis()
        {
            var analysis = new Analysis();

            if (!string.IsNullOrEmpty(FocusKeyword) && FocusKeyword != "undefined")
            {
                FocusKeyword = FocusKeyword.ToLower();

                var wordOccurenceService = new WordOccurenceService();

                var topwords = wordOccurenceService.GetKeywords(_htmlResult);

                var information = new AnalysisInformation {
                    Alias = "keywordanalyzer_top_words"
                };
                information.Tokens.Add(FocusKeyword);
                foreach (var word in topwords)
                {
                    information.Tokens.Add(word.Key);
                    information.Tokens.Add(word.Value.ToString());
                }

                analysis.Information.Add(information);


                var keywordTitleAnalyzer = new KeywordTitleAnalyzer();
                analysis.Results.Add(keywordTitleAnalyzer.Analyse(_htmlResult.Document, FocusKeyword));

                var keywordMetaDescriptionAnalyzer = new KeywordMetaDescriptionAnalyzer();
                analysis.Results.Add(keywordMetaDescriptionAnalyzer.Analyse(_htmlResult.Document, FocusKeyword));

                var keywordUrlAnalyzer = new KeywordUrlAnalyzer();
                analysis.Results.Add(keywordUrlAnalyzer.Analyse(_htmlResult.Document, FocusKeyword, _htmlResult.Url));

                var keywordContentAnalyzer = new KeywordContentAnalyzer();
                analysis.Results.Add(keywordContentAnalyzer.Analyse(_htmlResult.Document, FocusKeyword));

                var keywordHeadingAnalyzer = new KeywordHeadingAnalyzer();
                analysis.Results.Add(keywordHeadingAnalyzer.Analyse(_htmlResult.Document, FocusKeyword));
            }
            else
            {
                var information = new AnalysisInformation {
                    Alias = "keywordanalyzer_focus_keyword_not_set"
                };
                analysis.Information.Add(information);
            }

            return(analysis);
        }
예제 #2
0
        public void Analyse_OnExecuteWithKeywordPresentInH3_SetsAnalyzeResult()
        {
            var doc = new HtmlDocument();

            doc.LoadHtml("<body><h3>focus</h3></body>");

            var pageData = new PageData()
            {
                Document     = doc.DocumentNode,
                Focuskeyword = "focus",
                Url          = "http://www.google.com"
            };

            var analyzer = new KeywordHeadingAnalyzer();

            analyzer.Analyse(pageData);
            var result = analyzer.AnalyzeResult;

            Assert.IsNotNull(result);
            Assert.IsTrue(result.ResultRules.Count == 1);
            Assert.AreEqual(ResultType.Success, result.ResultRules.First().Type);
            Assert.AreEqual("1", result.ResultRules.First().Tokens.First());
            Assert.AreEqual("keyword_used_in_heading", result.ResultRules.First().Alias);
        }
예제 #3
0
        public void Analyse_OnExecuteWithNullParameter_ThrowArgumentNullException()
        {
            var analyzer = new KeywordHeadingAnalyzer();

            analyzer.Analyse(null);
        }