Mechanical Edits/Mateusz Konieczny - bot account/remove history tags recording revert as an object tag/

From OpenStreetMap Wiki
Jump to navigation Jump to search

Page content created as advised on Automated_Edits_code_of_conduct#Document_and_discuss_your_plans.

This edit will remove unneded and confusing history=* tags, remains of old software.

Why

Most values of this tag are pointless, confusing, unwelcome. Removing it manually (either in organized fashion or while editing affected objects) is a pointless waste of time when it is possible to automate it.

Checking what that is by mappers encountering it and learning about it is a pointless waste of time. Removing this tags from current object version would mostly eliminate this.

Making it a discardable key is not viable as some values can have some potential use (history=monument and similar mistaggings of historic=*), mass removing them silently is not OK.

Removing via JOSM validator is also sometimes that would involve precious human attention that can be used far more beneficially than handling (semi)manual removal of worthless tags.

Yes, making an edit requires modifying objects. The same would happen if mapper would remove them manually.


Also, removal of this values would make history=monument and similar mistaggings of historic=* more visible (for example on taginfo), making rescue of that data easier.

Who

I, Mateusz Konieczny using my bot account

contact

message via OSM I will respond also to PMs to the bot account, though messaging my main account is preferable as I will get notifications in OSM editors.

English and Polish languages are preferable, for other I need to use an automatic translator.

What

Removing

Also merges of such values

  • history=Retrieved from v7;Retrieved from v3

Untouched

All tags not listed above, such as

will not be modified.

Numbers

Around 40 000 objects.

How

https://www.openstreetmap.org/way/174085512:
state before a mechanical edit:

state after a mechanical edit:

Changeset would be described and tagged with tags that mark it as automatic, provide link to discussion approving edit etc

Source code =

import re
from osm_bot_abstraction_layer.generic_bot_retagging import run_simple_retagging_task
import wikimedia_connection.wikimedia_connection as wikimedia_connection
import wikibrain.wikimedia_link_issue_reporter
import osm_handling_config.global_config as osm_handling_config

def edit_element(tags):
    if tags.get('history') == None:
        return tags
    if is_history_tag_for_removal(tags.get('history')):
        tags.pop('history', None)
        #tags["operator:wikidata"] = tags.get('wikidata')
    return tags

def is_history_tag_for_removal(history_tag_value):
    if ";" in history_tag_value:
        for part in history_tag_value.split(";"):
            if not is_history_tag_part_what_i_remove(part):
                return False
            return True
    else:
        return is_history_tag_part_what_i_remove(history_tag_value)
    
def is_history_tag_part_what_i_remove(part):
    if part == "retrieved using undelete JOSM plugin":
        return True
    if re.search(r'^Retrieved from v\d+$', part) != None:
        return True
    return False
    

def main():
    if is_history_tag_for_removal("memorial"):
        raise "unexpected"
    if is_history_tag_for_removal("memorial;Retrieved from v1"):
        raise "unexpected"
    if is_history_tag_for_removal("Retrieved from v1") == False:
        raise "unexpected"
    if is_history_tag_for_removal("Retrieved from v1;Retrieved from v110101010") == False:
        raise "unexpected"
    if is_history_tag_for_removal("Retrieved from v;Retrieved from v110101010"):
        raise "unexpected"
    wikimedia_connection.set_cache_location(osm_handling_config.get_wikimedia_connection_cache_location())
    run_simple_retagging_task(
        max_count_of_elements_in_one_changeset=500,
        objects_to_consider_query="""
[out:xml][timeout:25000];
(
  nwr["history"];
);
out body;
>;
out skel qt;
""",
        objects_to_consider_query_storage_file='/media/mateusz/OSM_cache/osm_bot_cache/tags_for_retagging_history.osm',
        is_in_manual_mode=True,
        changeset_comment='remove useless history tags left by an ancient editing software',
        discussion_url="https://lists.openstreetmap.org/pipermail/talk/2021-April/thread.html#86453",
        osm_wiki_documentation_page='https://wiki.openstreetmap.org/wiki/Mechanical_Edits/Mateusz_Konieczny_-_bot_account/remove_history_tags_recording_revert_as_an_object_tag/',
        edit_element_function=edit_element,
    )

main()

Discussion

https://lists.openstreetmap.org/pipermail/talk/2021-April/thread.html#86453

Repetition

This is a single run that will not be repeated.

Opt-out

Please write at bot approval thread . Note that in case of opt-out exactly the same edit will be made manually for objects where bot opt-out was used.