/**************************************************************************/ public List <KeyValuePair <string, KEYWORD_STATUS> > AnalyzeKeywordPresence(MacroscopeDocument msDoc) { string Keywords = msDoc.GetKeywords().ToLower(); string BodyText = msDoc.GetDocumentTextCleaned().ToLower(); List <string> KeywordsList = new List <string>(); List <KeyValuePair <string, KEYWORD_STATUS> > KeywordPresence = new List <KeyValuePair <string, KEYWORD_STATUS> >(); bool KeywordsMetatagEmpty = false; foreach (string Keyword in Keywords.Split(',')) { string KeywordCleaned = MacroscopeStringTools.CleanWhiteSpace(Keyword); KeywordsList.Add(KeywordCleaned); KeywordsMetatagEmpty = true; } if (KeywordsMetatagEmpty) { foreach (string Keyword in KeywordsList) { string kw = this.GetPatternForLanguage(msDoc: msDoc, Keyword: Keyword); if (Regex.IsMatch(BodyText, kw)) { KeywordPresence.Add(new KeyValuePair <string, KEYWORD_STATUS>(Keyword, KEYWORD_STATUS.PRESENT_IN_BODY_TEXT)); } else { KeywordPresence.Add(new KeyValuePair <string, KEYWORD_STATUS>(Keyword, KEYWORD_STATUS.MISSING_IN_BODY_TEXT)); } } } else { KeywordPresence.Add(new KeyValuePair <string, KEYWORD_STATUS>("", KEYWORD_STATUS.KEYWORDS_METATAG_EMPTY)); } return(KeywordPresence); }
/**************************************************************************/ public List <KeyValuePair <string, KEYWORD_STATUS> > AnalyzeKeywordPresence(MacroscopeDocument msDoc) { string Keywords = msDoc.GetKeywords().ToLower(); string TitleText = msDoc.GetTitle().ToLower(); string DescriptionText = msDoc.GetDescription().ToLower(); string BodyText = msDoc.GetDocumentTextCleaned().ToLower(); List <string> KeywordsList = new List <string>(); List <KeyValuePair <string, KEYWORD_STATUS> > KeywordPresence = new List <KeyValuePair <string, KEYWORD_STATUS> >(); bool KeywordsMetatagFilled = false; foreach (string Keyword in Keywords.Split(',')) { string KeywordCleaned = MacroscopeStringTools.CleanWhiteSpace(Keyword); if (KeywordCleaned.Length > 0) { KeywordsList.Add(KeywordCleaned); KeywordsMetatagFilled = true; } } if (KeywordsMetatagFilled) { foreach (string Keyword in KeywordsList) { try { string kw = this.GetPatternForLanguage(msDoc: msDoc, Keyword: Keyword); if (Regex.IsMatch(TitleText, kw)) { KeywordPresence.Add(new KeyValuePair <string, KEYWORD_STATUS>(Keyword, KEYWORD_STATUS.PRESENT_IN_TITLE)); } else { KeywordPresence.Add(new KeyValuePair <string, KEYWORD_STATUS>(Keyword, KEYWORD_STATUS.MISSING_IN_TITLE)); } if (Regex.IsMatch(DescriptionText, kw)) { KeywordPresence.Add(new KeyValuePair <string, KEYWORD_STATUS>(Keyword, KEYWORD_STATUS.PRESENT_IN_DESCRIPTION)); } else { KeywordPresence.Add(new KeyValuePair <string, KEYWORD_STATUS>(Keyword, KEYWORD_STATUS.MISSING_IN_DESCRIPTION)); } if (Regex.IsMatch(BodyText, kw)) { KeywordPresence.Add(new KeyValuePair <string, KEYWORD_STATUS>(Keyword, KEYWORD_STATUS.PRESENT_IN_BODY)); } else { KeywordPresence.Add(new KeyValuePair <string, KEYWORD_STATUS>(Keyword, KEYWORD_STATUS.MISSING_IN_BODY)); } } catch (Exception ex) { this.DebugMsg(ex.Message); KeywordPresence.Add(new KeyValuePair <string, KEYWORD_STATUS>(Keyword, KEYWORD_STATUS.MALFORMED_KEYWORDS_METATAG)); } } } else { KeywordPresence.Add(new KeyValuePair <string, KEYWORD_STATUS>("", KEYWORD_STATUS.KEYWORDS_METATAG_EMPTY)); } return(KeywordPresence); }