private void Log_reader_CreateGameEvent(object sender, Parsers.PowerLogParser.CreateGameEventArgs e) { // Reset this.ai_communicator.Stop(); this.AddLog("====== New Game Starts ======"); this.ai_communicator.Start(); }
internal static List<Travelbug> Parse(Parsers.gpx.gc101.Travelbug[] bugs) { List<Travelbug> travelbugs = new List<Travelbug>(); if (bugs == null || bugs.Count() == 0) return travelbugs; foreach (var item in bugs) { travelbugs.Add(new Travelbug() { Name = item.Name, TravelbugId = item.Ref }); } return travelbugs; }
internal static List<Waypoint> Parse(Parsers.gpx.gc101.LogWaypoint[] logWaypoints) { List<Waypoint> waypoints = new List<Waypoint>(); if (logWaypoints == null || logWaypoints.Count() == 0) return waypoints; foreach (var item in logWaypoints) { waypoints.Add(new Waypoint() { Location = GeoPoint.Parse(Double.Parse(item.Latitude), Double.Parse(item.Longitude)), Tags = new List<Tag>() { new Tag() { Text = "LogWaypoint", Type = TagType.System } } }); } return waypoints; }
internal static List<Log> Parse(Parsers.gpx.gc101.Log[] logs) { List<Log> parsedLogs = new List<Log>(); if (logs == null || logs.Count() == 0) return parsedLogs; foreach (var item in logs) { parsedLogs.Add(new Log() { Author = new User() { Name = item.Finder.First().Name, Id = int.Parse(item.Finder.First().Id) }, Date = item.Date, Id = int.Parse(item.Id), Text = item.Text.First().value, Type = item.Type, Waypoints = Waypoint.Parse(item.LogWayPoints) }); } return parsedLogs; }
public static SupportedSourceFile Make(Parsers.IParser parser) { List<string> ext = new List<string>(); foreach (string ex in parser.FilesExtensions) if (ex[ex.Length - 1] != Parsers.Controller.HideParserExtensionPostfixChar) ext.Add(ex); if (ext.Count > 0) return new SupportedSourceFile(ext.ToArray(), parser.Name); return null; }
private Parsers.DataFieldExpression createDataFieldExpression(Parsers.ConditionalOperator @operator, MethodCallExpression expression) { var result = new Parsers.DataFieldExpression() { Operator = @operator }; Type type; object constant = null; string fieldName = getFieldName(expression.Object, out type); constant = getConstantValue(expression.Arguments.First()); result.DataFieldType = type; result.DataFieldName = fieldName; result.Value = constant; return result; }
public LinkReferenceParser(Parsers parsers) { Parsers = parsers; }
public void FixPeopleCategoriesYOBUncertain() { // year of birth uncertain const string u = "\r\n" + @"[[Category:Year of birth uncertain]]"; const string u2 = @"'''Charles Meik''' (born around 1330 in [[Ghent]] - [[22 July]] [[1387]]) {{Persondata}}"; Assert.AreEqual(u2 + u + @" [[Category:1387 deaths]]", Parsers.FixPeopleCategories(u2, "foo")); const string u2a = @"'''Charles Meik''' (born either 1330 or 1331 in [[Ghent]] - [[22 July]] [[1387]]) {{Persondata}}"; Assert.AreEqual(u2a + u + @" [[Category:1387 deaths]]", Parsers.FixPeopleCategories(u2a, "foo")); const string u2b = @"'''Charles Meik''' (born ~1330 in [[Ghent]] - [[22 July]] [[1387]]) {{Persondata}}"; Assert.AreEqual(u2b + u + @" [[Category:1387 deaths]]", Parsers.FixPeopleCategories(u2b, "foo")); const string u3 = @"'''Yusuf Ibn Muhammad Ibn Yusuf al-Fasi''' ([[1530]]/[[1531|31]]{{Fact|date=February 2007}} in [[Ksar-el-Kebir]], [[Morocco]] – 14 August [[1604]] in [[Fes, Morocco]]) {{persondata}}"; Assert.AreEqual(u3 + u + @" [[Category:1604 deaths]]", Parsers.FixPeopleCategories(u3, "foo")); // no matches when approximate year of birth const string b12 = @"'''Judith Victor Grabiner''' (born about 1938) is {{Persondata}}"; Assert.AreEqual(b12 + u, Parsers.FixPeopleCategories(b12, "foo")); const string b13 = @"'''Judith Victor Grabiner''' (born circa 1938) is {{Persondata}}"; Assert.AreEqual(b13 + u, Parsers.FixPeopleCategories(b13, "foo")); const string b14 = @"'''Judith Victor Grabiner''' (born before 1938) is {{Persondata}}"; Assert.AreEqual(b14 + u, Parsers.FixPeopleCategories(b14, "foo")); const string b15 = @"'''Judith Victor Grabiner''' (born 1938 or 1939) is {{Persondata}}"; Assert.AreEqual(b15 + u, Parsers.FixPeopleCategories(b15, "foo")); // born BC const string b16 = @"'''Phillipus Rhodicus''' (born 220 BC) was a {{Persondata}}"; Assert.AreEqual(b16 + "\r\n" + @"[[Category:220 BC births]]", Parsers.FixPeopleCategories(b16, "foo")); // no change: birth date not present so not 'uncertain' const string n1 = @"'''Thomas F. Goreau''' (born in [[Germany]], died 1970 in [[Jamaica]]) was [[Category:1970 deaths]]"; Assert.AreEqual(n1, Parsers.FixPeopleCategories(n1, "foo")); const string n2 = @"'''Charles Meik''' (born? - 1923) was an {{Persondata}}"; Assert.AreEqual(n2, Parsers.FixPeopleCategories(n2, "foo")); const string n2a = @"'''Anatoly Rasskazov''' (born 1960(?)) was {{persondata}}"; Assert.AreEqual(n2a, Parsers.FixPeopleCategories(n2a, "foo")); // no changes const string n3 = @"'''Johannes Widmann''' (born c. 1460 in [[Cheb|Eger]]; died after 1498 in [[Leipzig]]) [[Category:1460s births]]"; Assert.AreEqual(n3, Parsers.FixPeopleCategories(n3, "foo")); const string n4 = @"'''John Hulme''' (born circa 1970) is [[Category:Living people]] [[Category:Year of birth missing (living people)]]"; Assert.AreEqual(n4, Parsers.FixPeopleCategories(n4, "foo")); const string n4a = @"'''John Hulme''' (born c.1970) is [[Category:Living people]] [[Category:Year of birth missing (living people)]]"; Assert.AreEqual(n4a, Parsers.FixPeopleCategories(n4a, "foo")); const string n4b = @"'''John Hulme''' (born C.1970) is [[Category:Living people]] [[Category:Year of birth missing (living people)]]"; Assert.AreEqual(n4b, Parsers.FixPeopleCategories(n4b, "foo")); }
public MissingDefaultsort(Parsers p) { parsers = p; }
/// <summary> /// Processes the inline of the specified <see cref="LeafBlock"/>. /// </summary> /// <param name="leafBlock">The leaf block.</param> public void ProcessInlineLeaf(LeafBlock leafBlock) { if (leafBlock == null) { ThrowHelper.ArgumentNullException_leafBlock(); } // clear parser states Array.Clear(ParserStates, 0, ParserStates.Length); Root = new ContainerInline() { IsClosed = false }; leafBlock.Inline = Root; Inline = null; Block = leafBlock; BlockNew = null; LineIndex = leafBlock.Line; previousSliceOffset = 0; previousLineIndexForSliceOffset = 0; lineOffsets.Clear(); var text = leafBlock.Lines.ToSlice(lineOffsets); leafBlock.Lines.Release(); int previousStart = -1; while (!text.IsEmpty) { // Security check so that the parser can't go into a crazy infinite loop if one extension is messing if (previousStart == text.Start) { ThrowHelper.InvalidOperationException($"The parser is in an invalid infinite loop while trying to parse inlines for block [{leafBlock.GetType().Name}] at position ({leafBlock.ToPositionText()}"); } previousStart = text.Start; var c = text.CurrentChar; var textSaved = text; var parsers = Parsers.GetParsersForOpeningCharacter(c); if (parsers != null) { for (int i = 0; i < parsers.Length; i++) { text = textSaved; if (parsers[i].Match(this, ref text)) { goto done; } } } parsers = Parsers.GlobalParsers; if (parsers != null) { for (int i = 0; i < parsers.Length; i++) { text = textSaved; if (parsers[i].Match(this, ref text)) { goto done; } } } text = textSaved; // Else match using the default literal inline parser LiteralInlineParser.Match(this, ref text); done: var nextInline = Inline; if (nextInline != null) { if (nextInline.Parent == null) { // Get deepest container var container = FindLastContainer(); if (!ReferenceEquals(container, nextInline)) { container.AppendChild(nextInline); } if (container == Root) { if (container.Span.IsEmpty) { container.Span = nextInline.Span; } container.Span.End = nextInline.Span.End; } } } else { // Get deepest container var container = FindLastContainer(); Inline = container.LastChild is LeafInline ? container.LastChild : container; if (Inline == Root) { Inline = null; } } //if (DebugLog != null) //{ // DebugLog.WriteLine($"** Dump: char '{c}"); // leafBlock.Inline.DumpTo(DebugLog); //} } Inline = null; //if (DebugLog != null) //{ // DebugLog.WriteLine("** Dump before Emphasis:"); // leafBlock.Inline.DumpTo(DebugLog); //} // PostProcess all inlines PostProcessInlines(0, Root, null, true); //TransformDelimitersToLiterals(); //if (DebugLog != null) //{ // DebugLog.WriteLine(); // DebugLog.WriteLine("** Dump after Emphasis:"); // leafBlock.Inline.DumpTo(DebugLog); //} }
/// <summary> Scans a non-nestable block comment.</summary> /// <param name="open">the opening pattern. /// </param> /// <param name="close">the closing pattern. /// </param> /// <param name="commented">the commented pattern. /// </param> /// <returns> the Scanner for the block comment. /// </returns> public static Scanner IsBlockComment(Scanner open, Scanner close, Scanner commented) { return(Parsers.Sequence(open, close.Not().Seq(commented).Many_(), close)); }
/// <summary> the haskell style delimiter of tokens. /// whitespace, line comment, block comment. /// </summary> /// <returns> the scanner. /// </returns> public static Scanner IsHaskellDelimiter() { return(Parsers.Plus(IsWhitespaces(), IsHaskellBlockComment(), IsHaskellLineComment()).Many_() .Rename("haskell delimiter")); }
public override bool Check(ArticleInfo article) { Parsers.LivingPeople(article.Text, out Skip); return(!Skip); }
public override bool Check(ArticleInfo article) { Parsers.ChangeToDefaultSort(article.Text, article.Title, out Skip); return(!Skip); }
private void Start() { MakePatterns(); StartTime = new TimeSpan(DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second, DateTime.Now.Millisecond); intLimit = (int)nudLimitResults.Value; List <Scan> s = new List <Scan>(); s.Add(new CheckNamespace(namespaces)); if (chkIgnoreRedirects.Checked) { s.Add(new IsNotRedirect()); } if (chkArticleDoesContain.Checked) { if (ArticleContains != null) // simple search { s.Add(new TextContains(MakeReplacementDictionary(ArticleContains, ArticleCaseSensitive))); } else // regex { s.Add(new TextContainsRegex(ArticleDoesRegex)); } } if (chkArticleDoesNotContain.Checked) { if (ArticleDoesNotContain != null) { s.Add(new TextDoesNotContain(MakeReplacementDictionary(ArticleDoesNotContain, ArticleCaseSensitive))); } else { s.Add(new TextDoesNotContainRegex(ArticleDoesNotRegex)); } } if (chkTitleContains.Checked) { s.Add(new TitleContains(TitleDoesRegex)); } if (chkTitleDoesNotContain.Checked) { s.Add(new TitleDoesNotContain(TitleDoesNotRegex)); } if (chkSearchDates.Checked) { s.Add(new DateRange(dtpFrom.Value, dtpTo.Value)); } if (chkProtection.Checked) { s.Add(new Restriction(MoveDelete.EditProtectionLevel, MoveDelete.MoveProtectionLevel)); } if (cmboLength.SelectedIndex == 1) { s.Add(new CountCharacters(MoreLessThan.MoreThan, (int)nudLength.Value)); } else if (cmboLength.SelectedIndex == 2) { s.Add(new CountCharacters(MoreLessThan.LessThan, (int)nudLength.Value)); } if (cmboLinks.SelectedIndex == 1) { s.Add(new CountLinks(MoreLessThan.MoreThan, (int)nudLinks.Value)); } else if (cmboLinks.SelectedIndex == 2) { s.Add(new CountLinks(MoreLessThan.LessThan, (int)nudLinks.Value)); } if (cmboWords.SelectedIndex == 1) { s.Add(new CountWords(MoreLessThan.MoreThan, (int)nudWords.Value)); } else if (cmboWords.SelectedIndex == 2) { s.Add(new CountWords(MoreLessThan.LessThan, (int)nudWords.Value)); } Parsers parsers = new Parsers(); if (chkBadLinks.Checked) { s.Add(new HasBadLinks()); } if (chkNoBold.Checked) { s.Add(new HasNoBoldTitle(parsers)); } if (chkSimpleLinks.Checked) { s.Add(new HasSimpleLinks()); } if (chkHasHTML.Checked) { s.Add(new HasHTMLEntities(parsers)); } if (chkHeaderError.Checked) { s.Add(new HasSectionError(parsers)); } if (chkUnbulletedLinks.Checked) { s.Add(new HasUnbulletedLinks()); } if (chkTypo.Checked) { s.Add(new Typo()); } if (chkDefaultSort.Checked) { s.Add(new MissingDefaultsort(parsers)); } Main = new MainProcess(s, fileName, Priority, chkIgnoreComments.Checked, txtStartFrom.Text); progressBar.Value = 0; Main.StoppedEvent += Stopped; Main.OutputQueue = Queue; Main.Start(); }
public string ProcessArticle(IAutoWikiBrowser sender, IProcessArticleEventArgs eventargs) { //If menu item is not checked, then return if (!PluginEnabled || Settings.Categories.Count == 0) { eventargs.Skip = false; return(eventargs.ArticleText); } string text = eventargs.ArticleText; string removed = "", replaced = ""; foreach (KeyValuePair <string, string> p in Settings.Categories) { bool noChange; if (p.Value.Length == 0) { text = Parsers.RemoveCategory(p.Key, text, out noChange); if (!noChange) { if (!string.IsNullOrEmpty(removed)) { removed += ", "; } removed += Variables.Namespaces[Namespace.Category] + p.Key; } } else { text = Parsers.ReCategoriser(p.Key, p.Value, text, out noChange); if (!noChange) { if (!string.IsNullOrEmpty(replaced)) { replaced += ", "; } replaced += Variables.Namespaces[Namespace.Category] + p.Key + FindandReplace.Arrow + Variables.Namespaces[Namespace.Category] + p.Value; } } if (!noChange) { text = Regex.Replace(text, "<includeonly>[\\s\\r\\n]*\\</includeonly>", ""); } } string editSummary = ""; if (Settings.AppendToEditSummary) { if (!string.IsNullOrEmpty(replaced)) { editSummary = "replaced: " + replaced.Trim(); } if (!string.IsNullOrEmpty(removed)) { if (!string.IsNullOrEmpty(editSummary)) { editSummary += ", "; } editSummary += "removed: " + removed.Trim(); } } eventargs.EditSummary = editSummary; eventargs.Skip = (text == eventargs.ArticleText) && Settings.Skip; return(text); }
public IEnumerator Load() { if (File.Exists(filePath)) { var csvData = FileManager.ReadCsv(filePath); var grid = CsvParser2.Parse(csvData); string device = ""; // id = Pacient.Loaded.Id; if (scp.IsConnected && !scm.IsConnected && !scc.IsConnected && !sco.IsConnected) // PITACO { Debug.Log("Dispositivo(s): P"); device = "P"; } else { if (!scp.IsConnected && scm.IsConnected && !scc.IsConnected && !sco.IsConnected) // MANO { Debug.Log("Dispositivo(s): M"); device = "M"; } else { if (!scp.IsConnected && !scm.IsConnected && scc.IsConnected && !sco.IsConnected) // CINTA { Debug.Log("Dispositivo(s): C"); device = "C"; } else { if (scp.IsConnected && !scm.IsConnected && scc.IsConnected && !sco.IsConnected) // PITACO + CINTA { Debug.Log("Dispositivo(s): PC"); device = "PC"; } else { if (!scp.IsConnected && scm.IsConnected && scc.IsConnected && !sco.IsConnected) // MANO + CINTA { Debug.Log("Dispositivo(s): MC"); device = "MC"; } else { if (scp.IsConnected && !scm.IsConnected && !scc.IsConnected && sco.IsConnected) // PITACO + OXÍMETRO { Debug.Log("Dispositivo(s): PO"); device = "PO"; } else { if (!scp.IsConnected && scm.IsConnected && !scc.IsConnected && sco.IsConnected) // MANO + OXÍMETRO { Debug.Log("Dispositivo(s): MO"); device = "MO"; } else { if (!scp.IsConnected && !scm.IsConnected && scc.IsConnected && sco.IsConnected) // CINTA + OXÍMETRO { Debug.Log("Dispositivo(s): CO"); device = "CO"; } else { if (scp.IsConnected && !scm.IsConnected && scc.IsConnected && sco.IsConnected) // PITACO + CINTA + OXÍMETRO { Debug.Log("Dispositivo(s): PCO"); device = "PCO"; } else { if (!scp.IsConnected && scm.IsConnected && scc.IsConnected && sco.IsConnected) // MANO + CINTA + OXÍMETRO { Debug.Log("Dispositivo(s): MCO"); device = "MCO"; } else { if (!scp.IsConnected && !scm.IsConnected && !scc.IsConnected && sco.IsConnected) // OXÍMETRO { Debug.Log("Dispositivo(s): O [Combinação incorreta, o dispositivo Oxímetro não pode ser usado sozinho]"); device = "O"; } else { if (scp.IsConnected && scm.IsConnected && !scc.IsConnected && !sco.IsConnected) // PITACO + MANO { Debug.Log("Dispositivo(s): PM [Combinação incorreta, somente Pitaco será considerado]"); device = "P"; } else { if (scp.IsConnected && scm.IsConnected && scc.IsConnected && !sco.IsConnected) // PITACO + MANO + CINTA { Debug.Log("Dispositivo(s): PMC [Combinação incorreta, somente Pitaco e Cinta serão considerados]"); device = "PC"; } else { if (scp.IsConnected && scm.IsConnected && !scc.IsConnected && sco.IsConnected) // PITACO + MANO + OXÍMETRO { Debug.Log("Dispositivo(s): PMO [Combinação incorreta, somente Pitaco e Oxímetro serão considerados]"); device = "PO"; } else { if (scp.IsConnected && scm.IsConnected && scc.IsConnected && sco.IsConnected) // PITACO + MANO + CINTA + OXÍMETRO { Debug.Log("Dispositivo(s): PMCO [Combinação incorreta, somente Pitaco, Cinta e Oxímetro serão considerados]"); device = "PCO"; } } } } } } } } } } } } } } } for (var i = 2; i < 12; i++) { if (string.IsNullOrEmpty(grid[i][0])) { continue; } if (device == grid[i][0]) { parAux = new Parameters { device = grid[i][0], // Dispositivo FusionType = grid[i][1], // Tipo de Fusão FusionSubDevice = grid[i][2], FusionPrefPitaco = Parsers.Float(grid[i][3]), // Porcentagem Preferencial Pitaco FusionPrefMano = Parsers.Float(grid[i][4]), // Porcentagem Preferencial Mano FusionPrefCinta = Parsers.Float(grid[i][5]), // Porcentagem Preferencial Cinta FusionFunctIns = grid[i][6], FusionFunctExp = grid[i][7] }; } } for (var i = 16; i < 26; i++) { if (string.IsNullOrEmpty(grid[i][0])) { continue; } if (device == grid[i][0]) { par = new Parameters { device = parAux.device, // Dispositivo FusionType = parAux.FusionType, // Tipo de Fusão FusionSubDevice = parAux.FusionSubDevice, FusionPrefPitaco = parAux.FusionPrefPitaco, // Porcentagem Preferencial Pitaco FusionPrefMano = parAux.FusionPrefMano, // Porcentagem Preferencial Mano FusionPrefCinta = parAux.FusionPrefCinta, // Porcentagem Preferencial Cinta FusionFunctIns = parAux.FusionFunctIns, FusionFunctExp = parAux.FusionFunctExp, lostWtimes = int.Parse(grid[i][1]), // Perdeu W vezes (Alt. e Tam.) %%%%%%%%%%%%% decreaseHeight = Parsers.Float(grid[i][2]), // Fator de decremento da ALTURA dos Alvos %%%%%%%%%%%%% decreaseSize = Parsers.Float(grid[i][3]), // Fator de decremento do TAMANHO dos Obstáculos %%%%%%%%%%%%% lostXtimes = int.Parse(grid[i][4]), // Perdeu X vezes (Recalibrar disp.) %%%%%%%%%%%%% AdditionalDistance = Parsers.Float(grid[i][5]), // Distância adicional entre Obstáculos %%%%%%%%%%%%% ObjectsSpeedFactor = Parsers.Float(grid[i][6]), // Fator de cálculo da velocidade de movimento dos objetos de jogo (Alvos e Obstáculos) ScoreCalculationFactor = Parsers.Float(grid[i][7]), // Fator de Cálculo da Pontuação %%%%%%%%%%%%% MinimumExtensionBelt = Parsers.Float(grid[i][8]), // Valor mínimo exigido da Cinta de Pressão MinimumNormalOxygenation = int.Parse(grid[i][9]), // Oxigenação Normal Mínima MinimumRegularOxygenation = int.Parse(grid[i][10]) // Oxigenação Regular Mínima }; } } parameters = par; yield return(new WaitForSeconds(10f)); // Tenta carregar os parâmetros a cada 10 segundos LoadParameters(); } }
public string GetTokenString(Parsers.Position position) { return new String(buffer, position.FirstOffset, position.LastOffset - position.FirstOffset + 1); }
/// <summary> Any delimiter with whitespace, non-nested block comment and line comment.</summary> /// <param name="lcomment">line comment starting string. /// </param> /// <param name="openc">block comment opening string. /// </param> /// <param name="closec">block comment closing string. /// </param> /// <returns> the scanner. /// </returns> public static Scanner IsStdDelimiter(string lcomment, string openc, string closec) { return(Parsers.Plus(IsWhitespaces(), IsLineComment(lcomment), IsBlockComment(openc, closec)).Many_() .Rename("delimiter")); }
public override bool Check(ArticleInfo article) { string articleTextAfter = Parsers.ReorderReferences(article.Text); return(!articleTextAfter.Equals(article.Text)); }
public LivingPerson(Parsers p) { parsers = p; }
/// <summary> scans a quoted string that is opened by c1 and closed by c2.</summary> /// <param name="open">the opening character. /// </param> /// <param name="close">the closing character. /// </param> /// <param name="quoted_scanner">the scanner quoted character. This scanner will be repeated until the close pattern is met.</param> /// <returns> the scanner. /// </returns> public static Scanner IsQuotedBy(Scanner open, Scanner close, Scanner quoted_scanner) { return(Parsers.Sequence(open, quoted_scanner.Many_(), close).Rename("quoted")); }
public override bool Check(ArticleInfo article) { int bracketLength; return(Parsers.UnbalancedBrackets(article.Text, out bracketLength) != -1); }
/// <summary> the T-SQL style delimiter of tokens. /// whitespace and line comment. /// </summary> /// <returns> the scanner. /// </returns> public static Scanner IsSqlDelimiter() { return(Parsers.Plus(IsWhitespaces(), IsSqlLineComment(), IsJavaBlockComment()).Many_() .Rename("sql delimiter")); }
public override bool Check(ArticleInfo article) { Parsers.FixHeadings(article.Text, article.Title, out Skip); return(!Skip); }
public LinkParser(Parsers parsers) { Parsers = parsers; }
public override bool Check(ArticleInfo article) { return(Parsers.MissingDefaultSort(article.Text, article.Title)); }
public RequiresParser2() { parser2 = new Parsers(); }
/// <summary> /// Performs numerous minor improvements to the page text /// </summary> /// <param name="parsers">A parser object</param> /// <param name="removeText"></param> /// <param name="skip">Skip options</param> /// <param name="replaceReferenceTags">If true, <div class="references-small"><references/></div> and so on /// <param name="restrictDefaultsortAddition"></param> /// will be replaced with {{reflist}}</param> public void PerformGeneralFixes(Parsers parsers, HideText removeText, ISkipOptions skip, bool replaceReferenceTags, bool restrictDefaultsortAddition, bool noMOSComplianceFixes) { //TODO: 2009-01-28 review which of the genfixes below should be labelled 'significant' BeforeGeneralFixesTextChanged(); HideText(removeText); Variables.Profiler.Profile("HideText"); // call this before FixHeaderErrors so that Parsers.Conversions cleans up from ArticleIssues AWBChangeArticleText("Fixes for {{article issues}}", parsers.ArticleIssues(ArticleText), true); Variables.Profiler.Profile("ArticleIssues"); FixHeaderErrors(parsers, Variables.LangCode, skip.SkipNoHeaderError); Variables.Profiler.Profile("FixHeaderErrors"); FixPeopleCategories(parsers, skip.SkipNoPeopleCategoriesFixed); Variables.Profiler.Profile("FixPeopleCategories"); SetDefaultSort(Variables.LangCode, skip.SkipNoDefaultSortAdded, restrictDefaultsortAddition); Variables.Profiler.Profile("SetDefaultSort"); AWBChangeArticleText("Fix categories", Parsers.FixCategories(ArticleText, Namespace.IsMainSpace(Name)), true); Variables.Profiler.Profile("FixCategories"); AWBChangeArticleText("Fix images", Parsers.FixImages(ArticleText), true); Variables.Profiler.Profile("FixImages"); AWBChangeArticleText("Fix whitespace in links", Parsers.FixLinkWhitespace(ArticleText, Name), true); Variables.Profiler.Profile("FixLinkWhitespace"); // does significant fixes AWBChangeArticleText("Fix syntax", Parsers.FixSyntax(ArticleText), true, true); Variables.Profiler.Profile("FixSyntax"); AWBChangeArticleText("Fix citation templates", Parsers.FixCitationTemplates(ArticleText), true, false); Variables.Profiler.Profile("FixCitationTemplates"); AWBChangeArticleText("Fix temperatures", Parsers.FixTemperatures(ArticleText), true); Variables.Profiler.Profile("FixTemperatures"); AWBChangeArticleText("Fix non-breaking spaces", parsers.FixNonBreakingSpaces(ArticleText), true); Variables.Profiler.Profile("FixNonBreakingSpaces"); AWBChangeArticleText("Fix main article", Parsers.FixMainArticle(ArticleText), true); Variables.Profiler.Profile("FixMainArticle"); if (replaceReferenceTags) { AWBChangeArticleText("Fix reference tags", Parsers.FixReferenceListTags(ArticleText), true); Variables.Profiler.Profile("FixReferenceListTags"); } AWBChangeArticleText("Fix empty links and templates", Parsers.FixEmptyLinksAndTemplates(ArticleText), true); Variables.Profiler.Profile("FixEmptyLinksAndTemplates"); AWBChangeArticleText("FixReferenceTags", Parsers.FixReferenceTags(ArticleText), true); Variables.Profiler.Profile("FixReferenceTags"); AWBChangeArticleText("DuplicateUnnamedReferences", Parsers.DuplicateUnnamedReferences(ArticleText), true); Variables.Profiler.Profile("DuplicateUnnamedReferences"); AWBChangeArticleText("DuplicateNamedReferences", Parsers.DuplicateNamedReferences(ArticleText), true); Variables.Profiler.Profile("DuplicateNamedReferences"); AWBChangeArticleText("ReorderReferences", Parsers.ReorderReferences(ArticleText), true); Variables.Profiler.Profile("ReorderReferences"); AWBChangeArticleText("Fix empty references", Parsers.SimplifyReferenceTags(ArticleText), true); Variables.Profiler.Profile("FixEmptyReferences"); // does significant fixes if (IsMissingReferencesDisplay) { AWBChangeArticleText("Add missing {{reflist}}", Parsers.AddMissingReflist(ArticleText), true, true); Variables.Profiler.Profile("AddMissingReflist"); } AWBChangeArticleText("Mdashes", parsers.Mdashes(ArticleText, Name, NameSpaceKey), true); Variables.Profiler.Profile("Mdashes"); CiteTemplateDates(parsers, skip.SkipNoCiteTemplateDatesFixed); Variables.Profiler.Profile("CiteTemplateDates"); //Just a bit broken/Some unwanted fixes (moving of <ref> tags around) //AWBChangeArticleText("Fix Footnotes", parsers.FixFootnotes(articleText), true); //Variables.Profiler.Profile("FixFootnotes"); BulletExternalLinks(skip.SkipNoBulletedLink); Variables.Profiler.Profile("BulletExternalLinks"); AWBChangeArticleText("Remove empty comments", Parsers.RemoveEmptyComments(ArticleText), false); Variables.Profiler.Profile("RemoveEmptyComments"); if (!noMOSComplianceFixes) { AWBChangeArticleText("Fix Date Ordinals/Of", parsers.FixDateOrdinalsAndOf(ArticleText, Name), true, true); Variables.Profiler.Profile("FixDateOrdinalsAndOf"); } //if (Variables.IsWikimediaProject) //{ // AWBChangeArticleText("External to internal links", Parsers.ExternalURLToInternalLink(articleText), true); // Variables.Profiler.Profile("ExternalURLToInternalLink"); //} Variables.Profiler.Profile("Links"); if (!Globals.UnitTestMode) // disable to avoid ssslow network requests { // pass unhidden text to MetaDataSorter so that it can allow for comments around persondata, categories etc. UnHideText(removeText); AWBChangeArticleText("Sort meta data", parsers.SortMetaData(ArticleText, Name), true); HideText(removeText); Variables.Profiler.Profile("Metadata"); } // must call EmboldenTitles before calling FixLinks EmboldenTitles(parsers, skip.SkipNoBoldTitle); FixLinks(skip.SkipNoBadLink); Variables.Profiler.Profile("FixLinks"); AWBChangeArticleText("Format sticky links", Parsers.StickyLinks(Parsers.SimplifyLinks(ArticleText)), true); //AWBChangeArticleText("Remove duplicate wikilink", parsers.RemoveDuplicateWikiLinks(articleText), true); UnHideText(removeText); AfterGeneralFixesTextChanged(); Variables.Profiler.Profile("End of general fixes"); }
public void FixPeopleCategoriesUncat() { const string a1 = @"'''Fred Smith''' (born 1960) is a bloke. {{Persondata}} {{Uncat|date=May 2010}}"; const string b2 = @"[[Category:1960 births]]"; Assert.AreEqual(a1.Replace("Uncat", "Improve categories") + "\r\n" + b2, Parsers.FixPeopleCategories(a1, "foo"), "renames uncat to cat improve when cats added"); Assert.AreEqual(a1 + b2, Parsers.FixPeopleCategories(a1 + b2, "foo"), "no uncat renaming when cats not added"); Assert.AreEqual(a1.Replace(@" {{Uncat|date=May 2010}}", "") + "{{Cat improve}}" + "\r\n" + b2, Parsers.FixPeopleCategories(a1.Replace(@" {{Uncat|date=May 2010}}", "") + "{{Cat improve}}", "foo"), "no Cat improve change when cat improve already there"); }
/// <summary> /// Checks the article text for unbalanced brackets, either square or curly /// </summary> /// <param name="bracketLength">integer to hold length of unbalanced bracket found</param> /// <returns>Index of any unbalanced brackets found</returns> public int UnbalancedBrackets(ref int bracketLength) { return(Parsers.UnbalancedBrackets(ArticleText, ref bracketLength)); }
public void FixPeopleCategoriesLimits() { const string b2 = @"[[Category:1960 births]]"; const string u = "\r\n" + @"[[Category:Year of birth uncertain]]"; // don't use born info if after died info in text const string n5 = @"'''Alexander II''' ({{lang-ka|ალექსანდრე II, '''''Aleksandre II'''''}}) (died [[April 1]], [[1510]]) was a. * Prince David (born 1505) [[Category:1510 deaths]]"; Assert.AreEqual(n5, Parsers.FixPeopleCategories(@"'''Alexander II''' ({{lang-ka|ალექსანდრე II, '''''Aleksandre II'''''}}) (died [[April 1]], [[1510]]) was a. * Prince David (born 1505) [[Category:1510 deaths]]", "foo")); // don't pick up outside of zeroth section const string n6 = @"foo {{persondata}} == hello == {{birth date and age|1960|01|9}}"; Assert.AreEqual(n6, Parsers.FixPeopleCategories(n6, "foo")); // don't grab a number out of a reference const string n7 = @"'''Buck Peterson''' (born in [[Minnesota, United States]]<ref name=extreme_1970/>) {{persondata}}"; Assert.AreEqual(n7, Parsers.FixPeopleCategories(n7, "foo")); // don't accept if dash before year: could be death date const string n8 = @"'''Wilhem Heinrich Kramer''' (born [[Dresden]] – 1765) {{persondata}}"; Assert.AreEqual(n8, Parsers.FixPeopleCategories(n8, "foo")); // date of death too far from bold name to be correct const string n9 = @"'''Æthelstan''' was king of [[East Anglia]] in the 9th century. As with the other kings of East Anglia, there is very little textual information available. He did, however, leave an extensive coinage of both portrait and non-portrait type (for example, Coins of England and the United Kingdom, Spink and Son, London, 2005 and the Fitzwilliam Museum database of early medieval coins. [http://www.fitzmuseum.cam.ac.uk/coins/emc] It is suggested that Æthelstan was probably the king who defeated and killed the Mercian kings [[Beornwulf of Mercia|Beornwulf]] (killed 826) and [[Ludeca of Mercia|Ludeca]] (killed 827). He may have attempted to seize power in [[East Anglia]] on the death of [[Coenwulf of Mercia]] (died 821). If this"; // date of death over newline – too far away to be correct Assert.AreEqual(n9, Parsers.FixPeopleCategories(n9, "foo")); const string n10 = @"'''Fred''' blah died 2002 {{persondata}}"; Assert.AreEqual(n10, Parsers.FixPeopleCategories(n10, "foo")); // don't grab numbers out of long wikilinks const string n11 = @"'''Marcus Caecilius Metellus''' was a son of [[Lucius Caecilius Metellus (died 221 BC)|Lucius Caecilius Metellus]]. Deported {{persondata}}"; Assert.AreEqual(n11, Parsers.FixPeopleCategories(n11, "foo")); // birth and death const string bd1 = @"''Foo''' (8 May 1920 - 11 June 2004) was {{persondata}}"; const string bd1a = @" [[Category:1920 births]]", bd1b = @" [[Category:2004 deaths]]"; Assert.AreEqual(bd1 + bd1a + bd1b, Parsers.FixPeopleCategories(bd1, "foo")); Assert.AreEqual(bd1 + bd1a + bd1b, Parsers.FixPeopleCategories(bd1 + bd1a, "foo")); Assert.AreEqual(bd1 + bd1b + bd1a, Parsers.FixPeopleCategories(bd1 + bd1b, "foo")); const string image = @"[[File:long text here.jpg|thumb|250px|Long text here as well to make sure it is over 100 in total length [[this is a long wilikink]]]] "; Assert.AreEqual(image + bd1 + bd1a + bd1b, Parsers.FixPeopleCategories(image + bd1, "foo"), "Ignore File link at start of page"); const string bd2 = @"''Foo''' (8 May 1920 – 11 June 2004) was {{persondata}}"; Assert.AreEqual(bd2 + bd1a + bd1b, Parsers.FixPeopleCategories(bd2, "foo")); const string bd3 = @"'''Foo''' (8 May 1920 somewhere –11 June 2004) was {{persondata}}"; Assert.AreEqual(bd3 + bd1a + bd1b, Parsers.FixPeopleCategories(bd3, "foo")); // approximate date check still applied string bd4 = @"''Foo''' (Circa 8 May 1920 – 11 June 2004) was {{persondata}}"; Assert.AreEqual(bd4 + u + @" [[Category:2004 deaths]]", Parsers.FixPeopleCategories(bd4, "foo")); const string bd5 = @"'''Autpert Ambrose (Ambroise)''' (ca. 730 – 784) {{persondata}} [[Category:778 deaths]]"; Assert.AreEqual(bd5 + u, Parsers.FixPeopleCategories(bd5, "foo")); const string bd6 = @"'''Saint Bruno of Querfurt''' (c. 970 – February 14 1009) (also known as ''Brun'' and ''Boniface'' {{persondata}} [[Category:1009 deaths]]"; Assert.AreEqual(bd6 + u, Parsers.FixPeopleCategories(bd6, "foo")); // all correct already const string bd7 = @"'''Agapetus II''' (born in [[Rome]]; died October, 955) was {{persondata}} [[Category:955 deaths]]"; Assert.AreEqual(bd7, Parsers.FixPeopleCategories(bd7, "foo")); // no change const string bd8 = @"'''Husain''' (d. April or May 1382) was a [[Jalayirids|Jalayirid]] ruler (1374-1382). He was the son of [[Shaikh Uvais]]. {{persondata}} [[Category:1382 deaths]]"; // add death and uncertain birth Assert.AreEqual(bd8, Parsers.FixPeopleCategories(bd8, "foo")); const string bd9 = @"'''Mannalargenna''' (ca. 1770-1835), a [[Tasmanian Aborigine]], was the chief of the Ben Lomond tribe (Plangermaireener). {{persondata}}"; Assert.AreEqual(bd9 + @" [[Category:Year of birth uncertain]] [[Category:1835 deaths]]", Parsers.FixPeopleCategories(bd9, "foo")); const string bd9b = @"'''Mannalargenna''' (c 1770-1835), a [[Tasmanian Aborigine]], was the chief of the Ben Lomond tribe (Plangermaireener). {{persondata}}"; Assert.AreEqual(bd9b + @" [[Category:Year of birth uncertain]] [[Category:1835 deaths]]", Parsers.FixPeopleCategories(bd9b, "foo")); const string bd10 = @"'''King Godfred''' (ruled 804 - 810) {{persondata}}"; Assert.AreEqual(bd10, Parsers.FixPeopleCategories(bd10, "foo")); const string bd11 = @"'''Rabat I''' (1616/7 - 1644/5) {{persondata}}"; Assert.AreEqual(bd11 + u, Parsers.FixPeopleCategories(bd11, "foo")); const string bd12 = @"'''Lorenzo Monaco''' (born '''Piero di Giovanni''' [[Circa|c.]]1370-1425) {{persondata}} [[Category:1425 deaths]]"; Assert.AreEqual(bd12 + u, Parsers.FixPeopleCategories(bd12, "foo")); const string bd13 = @"'''Mocius''' ('''Mucius''', died 288-295), also kno [[Category:3rd-century deaths]]"; Assert.AreEqual(bd13, Parsers.FixPeopleCategories(bd13, "foo")); // with flourit both dates are uncertain const string bd14 = @"'''Asclepigenia''' (fl. 430 – 485 AD) was {{persondata}}"; Assert.AreEqual(bd14, Parsers.FixPeopleCategories(bd14, "foo")); const string bd14a = @"'''Asclepigenia''' ([[floruit|fl]]. 430 – 485 AD) was {{persondata}}"; Assert.AreEqual(bd14a, Parsers.FixPeopleCategories(bd14a, "foo")); const string bd14b = @"'''Asclepigenia''' (flourished 430 – 485 AD) was {{persondata}}"; Assert.AreEqual(bd14b, Parsers.FixPeopleCategories(bd14b, "foo")); const string bd14c = @"'''Asclepigenia''' ({{fl}} 430) was {{persondata}}"; Assert.AreEqual(bd14c, Parsers.FixPeopleCategories(bd14c, "foo")); // no data to use here const string no1 = @"'''Bahram I''' (also spelled ''Varahran'' or ''Vahram'', ''r.'' 273–276) {{persondata}}"; Assert.AreEqual(no1, Parsers.FixPeopleCategories(no1, "foo")); const string no2 = @"'''Trebellianus''' (d. 260-268), also {{persondata}}"; Assert.AreEqual(no2, Parsers.FixPeopleCategories(no2, "foo")); const string no3 = @"'''[[Grand Ayatollah]] {{unicode|Muhammad Sādiq as-Sadr}}''' ([[Arabic]] محمّد صادق الصدر ) is an [[Iraq]]i [[Twelver]] [[Shi'a]] cleric of high rank. He is the father of [[Muqtada al-Sadr]] (born 1973). Sometimes the son is called by his father's name. He is the cousin of Grand Ayatollah [[Muhammad Baqir al-Sadr]] (died 1980). The al-Sadr family are considered [[Sayyid]], which is used among the Shia to denote persons descending directly from [[Muhammad]]. The family's lineage is traced through Imam [[Jafar al-Sadiq]] and his son Imam [[Musa al-Kazim]] the sixth and seventh Shia Imams respectively."; Assert.AreEqual(no3, Parsers.FixPeopleCategories(no3, "foo")); const string no4 = @"'''Bahram I''' (also spelled ''Varahran'' or ''Vahram'', ''r.'' 273–276) {{persondata}}"; Assert.AreEqual(no4, Parsers.FixPeopleCategories(no4, "foo")); const string no5 = @"'''John Coggeshall''' (chr. December 9, 1601) Charles [[Category:1835 deaths]]"; Assert.AreEqual(no5, Parsers.FixPeopleCategories(no5, "foo")); const string ISO1 = @"'''Ben Moon''' (born [[1960-06-13]]) is a {{persondata}}"; Assert.AreEqual(ISO1 + "\r\n" + b2, Parsers.FixPeopleCategories(ISO1, "foo")); const string bd15 = @"'''Kristina of Norway''' (born in [[1234]] in [[Bergen]] – circa [[1262]]), sometimes {{persondata}}"; Assert.AreEqual(bd15 + @" [[Category:1234 births]]", Parsers.FixPeopleCategories(bd15, "foo")); // sortkey usage const string s1 = @"'''Claire Hazel Weekes''' (1903—1990) was {{persondata}} [[Category:1990 deaths|Weekes, Claire]]"; Assert.AreEqual(s1 + @" [[Category:1903 births|Weekes, Claire]]", Parsers.FixPeopleCategories(s1, "foo")); const string m1 = @"'''Hans G Helms''' (born [[8 June]] [[1960]] in [[Teterow]]; full name: ''Hans Günter Helms''; the bearer of the name does not use a full stop after the initial for his middle name) is a [[Germany|German]] experimental writer, composer, and social and economic analyst and critic. {{persondata}}"; Assert.AreEqual(m1 + "\r\n" + b2, Parsers.FixPeopleCategories(m1, "foo")); // uncertain year of death const string m2 = @"'''Arthur Paunzen''' (born [[4 February]] [[1890]], died ?[[9 August]] [[1940]]) [[Category:1890 births]]"; Assert.AreEqual(m2, Parsers.FixPeopleCategories(m2, "foo")); const string m3 = @"Foo {{death date and age|2008|8|21|1942|7|13|mf=y}} {{persondata}}"; const string m3a = @" [[Category:1942 births]] [[Category:2008 deaths]]"; Assert.AreEqual(m3 + m3a, Parsers.FixPeopleCategories(m3, "foo")); const string bug1 = @"'''Jane Borghesi''' (born 17 June{{Fact|date=January 2009}}, [[Melbourne]]) {{persondata}}"; Assert.AreEqual(bug1, Parsers.FixPeopleCategories(bug1, "foo"), "Don't take year from date param of template e.g. maintenance tag"); const string miss1 = @"'''Alonza J. White''' (ca 1836 – [[August 29]] [[1912]]) {{persondata}} {{DEFAULTSORT:White, Alonza J}} [[Category:1912 deaths]] [[Category:People from St. John's, Newfoundland and Labrador]]", miss2 = @"[[Category:Year of birth missing]]"; Assert.AreEqual(miss1 + u, Parsers.FixPeopleCategories(miss1 + "\r\n" + miss2, "foo")); const string both1 = @"'''Mary Ellen Wilson''' (1864–1956)<ref name=""amhum"">{{foo}}</ref> {{persondata}}", both2 = @"[[Category:1864 births]] [[Category:1956 deaths]]"; Assert.AreEqual(both1 + "\r\n" + both2, Parsers.FixPeopleCategories(both1, "foo")); const string bug2 = @"'''Foo''' (born {{circa}} 1925) was {{persondata}}"; Assert.AreEqual(bug2 + u, Parsers.FixPeopleCategories(bug2, "foo")); const string bug3 = @"'''Joshua William Allen, 6th Viscount Allen''' [[Master of Arts (Oxbridge)|MA]] ({{circa}} [[1782]]–[[21 September]] [[1845]]) was an [[Irish peerage|Irish peer]]. {{DEFAULTSORT:Allen, Joshua Allen, 6th Viscount}} [[Category:1845 deaths]] [[Category:Viscounts in the Peerage of Ireland]] [[Category:Year of birth uncertain]]"; Assert.AreEqual(bug3, Parsers.FixPeopleCategories(bug3, "foo")); const string bug4 = @" {{infobox person | birth_date = {{Birth date based on age at death |49 |1994|02|25}} }} {{DEFAULTSORT:Goldberg, Robert P.}} [[Category:American computer businesspeople]] [[Category:American computer scientists]] [[Category:Harvard University faculty]] [[Category:1994 deaths]] [[Category:Harvard University alumni]] [[Category:Year of birth missing]]"; Assert.AreEqual(bug4, Parsers.FixPeopleCategories(bug4, "foo"), "No birth year available in {{Birth date based on age at death}}"); }
public Fast() : base(Parsers.Lines().Int().ToArray()) { }
public ActionStartEventArgs(Parsers.PowerLogParser.ActionStartEventArgs e, GameState game) : base(e) { this.game = game; }
public BruteForce() : base(Parsers.Lines().Int().ToArray()) { }
private Parsers.DataFieldExpression createDataFieldExpression(Parsers.ConditionalOperator @operator, BinaryExpression expression) { var result = new Parsers.DataFieldExpression() { Operator = @operator }; Type type; object constant = null; string fieldName = getFieldName(expression.Left, out type); if (fieldName == null) { fieldName = getFieldName(expression.Right, out type); constant = getConstantValue(expression.Left); } else { constant = getConstantValue(expression.Right); } result.DataFieldType = type; result.DataFieldName = fieldName; result.Value = constant; return result; }
public VersaTransVehicleRepository() { _vehiclesWithDrivers = new Dictionary <int, List <int> >(); _employeesWithVehicles = new Dictionary <int, List <int> >(); _vehicles = new Dictionary <int, VersaTransVehicle>(); using (SqlConnection connection = new SqlConnection(Settings.DBConnectionString_VersaTrans)) { // Drivers using (SqlCommand sqlCommand = new SqlCommand() { Connection = connection, CommandType = CommandType.Text, CommandText = "SELECT VehicleID, EmployeeID FROM VehicleDriver" }) { sqlCommand.Connection.Open(); SqlDataReader dbDataReader = sqlCommand.ExecuteReader(); if (dbDataReader.HasRows) { while (dbDataReader.Read()) { int vehicleID = Parsers.ParseInt(dbDataReader["VehicleID"].ToString().Trim()); int employeeID = Parsers.ParseInt(dbDataReader["EmployeeID"].ToString().Trim()); if (!_vehiclesWithDrivers.ContainsKey(vehicleID)) { _vehiclesWithDrivers.Add(vehicleID, new List <int>()); } if (!_vehiclesWithDrivers[vehicleID].Contains(employeeID)) { _vehiclesWithDrivers[vehicleID].Add(employeeID); } if (!_employeesWithVehicles.ContainsKey(employeeID)) { _employeesWithVehicles.Add(employeeID, new List <int>()); } if (!_employeesWithVehicles[employeeID].Contains(vehicleID)) { _employeesWithVehicles[employeeID].Add(vehicleID); } } } sqlCommand.Connection.Close(); } // Vehicles using (SqlCommand sqlCommand = new SqlCommand() { Connection = connection, CommandType = CommandType.Text, CommandText = "SELECT RecordID, vehicle, VIN, plate1 FROM Vehicles" }) { sqlCommand.Connection.Open(); SqlDataReader dbDataReader = sqlCommand.ExecuteReader(); if (dbDataReader.HasRows) { while (dbDataReader.Read()) { VersaTransVehicle vehicle = dataReaderToVehicle(dbDataReader); if (vehicle != null) { _vehicles.Add(vehicle.RecordID, vehicle); } } } sqlCommand.Connection.Close(); } } }
public StringValue(Parsers.Quote.Info quote) { m_Quote = quote; m_Value = ""; m_Expressions = new List<INode>(); }
/// <summary> scanner for c++/java style block comment. </summary> /// <returns> the scanner. /// </returns> public static Scanner IsJavaBlockComment() { //return isBlockComment("/*", "*/"); return(Parsers.Sequence(IsString("/*"), p_javaBlockCommented(), IsString("*/"))); //isNestableBlockComment("/*", "*/"); }
/// <summary> scanner for haskell style block comment. ({- -})</summary> /// <returns> the scanner. /// </returns> public static Scanner IsHaskellBlockComment() { return(Parsers.Seq(IsString("{-"), p_haskellBlockCommented(), IsString("-}"))); }
public abstract void Parse(ErrorSink/*!*/ errors, IReductionsSink/*!*/ reductionsSink, Parsers.Position initialPosition, LanguageFeatures features);