Thành viên:AlphamaBot/Code sửa lỗi không có chú thích (nháp)

Bách khoa toàn thư mở Wikipedia
 public string ProcessArticle(string ArticleText, string ArticleTitle, int wikiNamespace, out string Summary, out bool Skip)
        {
            Skip = false;
            Summary = "General fixes";
            string originVersion = ArticleText;
 
            // Choose main & category namespaces only
            if (wikiNamespace != 0 && wikiNamespace != 14)
            {
                Skip = true;
                return ArticleText;
            }
 
            #region Common
            ArticleText = Regex.Replace(ArticleText, @"\[\[[Cc]ategory", "[[Thể loại");
            ArticleText = Regex.Replace(ArticleText, @"\{\{[Cc]ite book", "{{chú thích sách");
            ArticleText = Regex.Replace(ArticleText, @"\{\{[Cc]ite web", "{{chú thích web");
            ArticleText = Regex.Replace(ArticleText, @"\{\{[Rr]eflist", "{{tham khảo");
            ArticleText = Regex.Replace(ArticleText, @"\<[Rr]eferences\s*\/\>", "{{tham khảo}}");
            //ArticleText = ArticleText.Replace("\n ", "\n");
            #endregion
 
            #region Punctuation
            // Punctuation
            ArticleText = Regex.Replace(ArticleText, @"\s\.", ".");
            ArticleText = Regex.Replace(ArticleText, @"\s\,", ",");
            ArticleText = Regex.Replace(ArticleText, @"\s\)", ")");
            ArticleText = Regex.Replace(ArticleText, @"\(\s", "(");
            ArticleText = Regex.Replace(ArticleText, @"\s\:", ":");
            ArticleText = Regex.Replace(ArticleText, @"\s\;", ";");
            #endregion
 
            #region Translation
            // Translate English -> Vietnamese
            ArticleText = Regex.Replace(ArticleText, @"==\s*[Ee]xternal\s*links\s*==", "== Liên kết ngoài ==");
            ArticleText = Regex.Replace(ArticleText, @"==\s*[Rr]eferences\s*==", "== Tham khảo ==");
            ArticleText = Regex.Replace(ArticleText, @"==\s*[Ss]ee\s*also\s*==", "== Xem thêm ==");
            ArticleText = Regex.Replace(ArticleText, @"==\s*[Ff]urther\s*reading\s*==", "== Đọc thêm ==");
            ArticleText = Regex.Replace(ArticleText, @"==\s*Notes\s*==", "== Ghi chú ==");
            #endregion
 
            #region Check article status
            // Check header templates in main namespace
            if (wikiNamespace != 14 && !ArticleText.Contains("<ref") && !ArticleText.Contains("{{unreferenced") && !ArticleText.Contains("{{chú thích trong bài") && !ArticleText.Contains("{{thiếu nguồn gốc") && !ArticleText.Contains("{{trang định hướng") && !ArticleText.Contains("{{định hướng"))
            {
                ArticleText = "{{chú thích trong bài}} \r\n" + ArticleText;
 
				Match m = Regex.Match(ArticleText, @"==\s*[Tt]ham\s*khảo\s*==");
				Match m1 = Regex.Match(ArticleText, @"\[\[[Tt]hể\s*[Ll]oại");
				Match m2 = Regex.Match(ArticleText, @"==\s*[Ll]iên\s*[Kk]ết\s*[Nn]goài\s*==");
				Match m3 = Regex.Match(ArticleText, @"\{\{[Ss]ơ\s*[Kk]hai");
				Match m4 = Regex.Match(ArticleText, @"\{\{\s*[Tt]ham\s*[Kk]hảo");
				
				if (!m4.Success)
				{
 
				if (m.Success)
				{
					ArticleText = ArticleText.Insert(m.Index + m.Value.Length, "\r\n{{tham khảo}}");
				}
				else
				{
					if (m2.Success)
					{
						ArticleText = ArticleText.Insert(m2.Index, "==Tham khảo==\r\n{{tham khảo}}\r\n");
					}
					else
					{
					
						if (m3.Success)
						{
							ArticleText = ArticleText.Insert(m3.Index, "==Tham khảo==\r\n{{tham khảo}}\r\n");
						}
						else
						{
							if (m1.Success)
							{
								ArticleText = ArticleText.Insert(m1.Index, "==Tham khảo==\r\n{{tham khảo}}\r\n");
							} 
						}
					}
				}
				}
 
 
            }
 
            #endregion
 
            if (originVersion == ArticleText) Skip = true;
            return ArticleText;
 
        }