Skip to content

Commit

Permalink
fixed bug in tags with multiple citations appearing as several tags i…
Browse files Browse the repository at this point in the history
…n the results
  • Loading branch information
HerrKnarz committed Sep 28, 2024
1 parent d20e240 commit 7ceec67
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Metadata/WikipediaMetadata/Resources.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public static class Resources
/// <summary>
/// Templates that will be removed from the results.
/// </summary>
public static readonly string[] UnwantedTemplateNames = { "efn", "cite web" };
public static readonly string[] UnwantedTemplateNames = { "efn", "cite web", "cite tweet", "cite video game" };

/// <summary>
/// Possible names for video game release templates. Is needed to remove the country value from the list of platforms.
Expand Down
14 changes: 6 additions & 8 deletions Metadata/WikipediaMetadata/WikitextParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -477,21 +477,19 @@ internal List<MetadataProperty> GetValues(Template infoBox, string field, bool r
internal TemplateArgument StripUnwantedElements(TemplateArgument argument)
{
// First we remove every template we don't want.
foreach (var x in argument.EnumDescendants().OfType<Template>()
.Where(t => Resources.UnwantedTemplateNames.Contains(CleanTemplateName(MwParserUtility.NormalizeTemplateArgumentName(t.Name)))))
foreach (var item in argument.EnumDescendants().OfType<Template>().Where(t =>
Resources.UnwantedTemplateNames.Contains(
CleanTemplateName(MwParserUtility.NormalizeTemplateArgumentName(t.Name)))).ToList())
{
x.Remove();
item.Remove();
}

// Now we also remove <ref> tags, because those contain footnotes etc., we don't need.
foreach (var line in argument.Value.Lines)
{
foreach (var inline in line.EnumDescendants())
foreach (var item in line.EnumDescendants().Where(t => t.ToString().StartsWith("<ref")).ToList())
{
if (inline.ToString().StartsWith("<ref"))
{
inline.Remove();
}
item.Remove();
}
}

Expand Down

0 comments on commit 7ceec67

Please sign in to comment.