/// <summary> /// In the {{Multiple issues}} template renames unref to BLPunref for living person bio articles /// </summary> /// <param name="articleText">The page text</param> /// <returns>The updated page text</returns> private string MultipleIssuesBLPUnreferenced(string articleText) { articleText = MultipleIssuesDate.Replace(articleText, ""); if (WikiRegexes.MultipleIssues.IsMatch(articleText)) { string aiat = WikiRegexes.MultipleIssues.Match(articleText).Value; // unref to BLPunref for living person bio articles if (Tools.GetTemplateParameterValue(aiat, "unreferenced").Length > 0 && articleText.Contains(CategoryLivingPeople)) { articleText = articleText.Replace(aiat, Tools.RenameTemplateParameter(aiat, "unreferenced", "BLP unsourced")); } else if (Tools.GetTemplateParameterValue(aiat, "unref").Length > 0 && articleText.Contains(CategoryLivingPeople)) { articleText = articleText.Replace(aiat, Tools.RenameTemplateParameter(aiat, "unref", "BLP unsourced")); } string zerothSection = Tools.GetZerothSection(articleText); string restOfArticle = articleText.Substring(zerothSection.Length); articleText = MetaDataSorter.MoveMaintenanceTags(zerothSection) + restOfArticle; } return(articleText); }
/// <summary> /// determines whether the article is about a person by looking for persondata/birth death categories, bio stub etc. for en wiki only /// Should only return true if the article is the principle article about the individual (not early life/career/discography etc.) /// </summary> /// <param name="articleText">The wiki text of the article.</param> /// <param name="articleTitle">Title of the article</param> /// <param name="parseTalkPage"></param> /// <returns></returns> public static bool IsArticleAboutAPerson(string articleText, string articleTitle, bool parseTalkPage) { #if DEBUG || UNITTEST if (Globals.UnitTestMode) parseTalkPage = false; #endif // fix for duplicate living people categories being miscounted as article about multiple people MetaDataSorter MDS = new MetaDataSorter(); string cats = MDS.RemoveCats(ref articleText, articleTitle); articleText += cats; if (!Variables.LangCode.Equals("en") || Namespace.Determine(articleTitle).Equals(Namespace.Category) || articleTitle.StartsWith(@"List of ") || articleTitle.StartsWith(@"Murder of ") || articleTitle.StartsWith(@"Deaths ") || articleTitle.EndsWith("discography") || articleTitle.EndsWith(" murders") || articleText.Contains(@"[[Category:Multiple people]]") || articleText.Contains(@"[[Category:Married couples") || articleText.Contains(@"[[Category:Fictional") || Regex.IsMatch(articleText, @"\[\[Category:\d{4} animal") || articleText.Contains(@"[[fictional character") || InUniverse.IsMatch(articleText) || articleText.Contains(@"[[Category:Presidencies") || articleText.Contains(@"[[Category:Military careers") || Regex.IsMatch(articleText, @"[[Category:[^\[\]\|]*[nN]oble families") || CategoryCharacters.IsMatch(articleText) || Tools.NestedTemplateRegex("Infobox cricketer tour biography").IsMatch(articleText) || WikiRegexes.Disambigs.IsMatch(articleText) || WikiRegexes.DeathsOrLivingCategory.Matches(articleText).Count > 1 || WikiRegexes.InfoBox.Match(articleText).Groups[1].Value.ToLower().Contains("organization") ) return false; string MABackground = Tools.GetTemplateParameterValue(IMA.Match(articleText).Value, "Background", true); if(MABackground.Contains("band") || MABackground.Contains("classical_ensemble") || MABackground.Contains("temporary")) return false; string CLSA = Tools.NestedTemplateRegex(@"Infobox Chinese-language singer and actor").Match(articleText).Value; if(CLSA.Length > 0) { if (Tools.GetTemplateParameterValue(CLSA, "currentmembers").Length > 0 || Tools.GetTemplateParameterValue(CLSA, "pastmembers").Length > 0) return false; } string zerothSection = WikiRegexes.ZerothSection.Match(articleText).Value; // not about a person if it's not the principle article on the subject if (SeeAlsoOrMain.IsMatch(zerothSection)) return false; // not about one person if multiple different birth or death date templates List<string> BD = new List<string>(); foreach(Match m in BirthDate.Matches(articleText)) { if(BD.Count > 0 && !BD.Contains(m.Value)) return false; BD.Add(m.Value); } List<string> DD = new List<string>(); foreach(Match m in DeathDate.Matches(articleText)) { if(DD.Count > 0 && !DD.Contains(m.Value)) return false; DD.Add(m.Value); } if(WikiRegexes.PeopleInfoboxTemplates.Matches(articleText).Count > 1) return false; if (WikiRegexes.Persondata.Matches(articleText).Count == 1 || articleText.Contains(@"-bio-stub}}") || articleText.Contains(@"[[Category:Living people") || WikiRegexes.PeopleInfoboxTemplates.Matches(zerothSection).Count == 1) return true; // articles with bold linking to another article may be linking to the main article on the person the article is about // e.g. '''military career of [[Napoleon Bonaparte]]''' string zerothSectionNoTemplates = WikiRegexes.Template.Replace(zerothSection, ""); foreach(Match m in WikiRegexes.Bold.Matches(zerothSectionNoTemplates)) { if(WikiRegexes.WikiLink.IsMatch(m.Value)) return false; } int dateBirthAndAgeCount =BirthDate.Matches(zerothSection).Count; int dateDeathCount = DeathDate.Matches(zerothSection).Count; if (dateBirthAndAgeCount == 1 || dateDeathCount == 1) return true; return WikiRegexes.DeathsOrLivingCategory.IsMatch(articleText) || WikiRegexes.LivingPeopleRegex2.IsMatch(articleText) || WikiRegexes.BirthsCategory.IsMatch(articleText) || WikiRegexes.BLPSources.IsMatch(BLPUnsourcedSection.Replace(articleText, "")) || RefImproveBLP.IsMatch(articleText); /* || (!string.IsNullOrEmpty(articleTitle) && articleText.Length < 10000 && parseTalkPage && TryGetArticleText(Variables.Namespaces[Namespace.Talk] + articleTitle).Contains(@"{{WPBiography"))*/ }