Mechanical Edits/Mateusz Konieczny - bot account/unquote names in Poland

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.

Who

I, Mateusz Konieczny using my bot account

contact

message via OSM I will respond also to PMs to the bot account. In both cases I will be notified about incoming PMs via email and notifications in OSM editors.

What

Remover spurious quotes around names.

Names are quoted within text in some cases, but in name=*

Only cases where only exactly two " signs are present, one at start of name=* and one at end will be edited.

Edits will happen only in Poland.

Why

name=* with quotes wrapped around actual name are wrong, removing such quotes fixes name tag.

Numbers

Depends on how many new matches appear - depends on editing activity in OSM.

How

  • Editing is limited to objects in Poland with exactly two " signs - at the start and end of a name.

state before a mechanical edit:

state after a mechanical edit:


Bot source code

Bot is using https://github.com/matkoniecz/osm_bot_abstraction_layer library, this code is GNU GPLv3 licensed

from osm_bot_abstraction_layer.generic_bot_retagging import run_simple_retagging_task

def edit_element(tags):
    if tags.get('name') == None:
        return tags
    if tags.get('name')[0] != '"':
        return tags
    if tags.get('name')[-1] != '"':
        return tags
    modified_name = tags.get('name')[1:-1]
    if modified_name.find('"') != -1:
        # przypadki typu
        # name = "PKP Intercity" Zakład Południowy "Kraków Główny"
        # http://www.openstreetmap.org/way/1243731574
        return tags
    tags["name"] = modified_name
    return tags

def main():
    query = """
[out:xml][timeout:1800];
area[name="Polska"]->.a;
(
  nwr["name"~"^\\".*\\"$"](area.a);
);
out body;
>;
out skel qt;
"""
    run_simple_retagging_task( # (area.a)
        max_count_of_elements_in_one_changeset=500,
        objects_to_consider_query=query,
        cache_folder_filepath='/media/mateusz/OSM_cache/osm_bot_cache',
        is_in_manual_mode=True,
        changeset_comment='name=* nie potrzebuje cudzysłowu, cudzysłów jest czasem gdy nazwa jest w tekście',
        discussion_url=None,
        osm_wiki_documentation_page=None,
        edit_element_function=edit_element,
    )

main()

Discussion

https://community.openstreetmap.org/t/odcudzyslowienie-nazw-propozycja-automatycznej-edycji/111205


Repetition

This is reoccurring edit and may be made as soon as new matching elements appear. At this moment triggering new edit requires human intervention so exact schedule is not predictable and bot may stop running at any moment.

This can change in a future. If bot is abandoned and does not run, feel free to ping me. If I am unable to run it any more feel free to use my code. Note that it may require going through bot approval process again and that code is on specific license.

https://codeberg.org/matkoniecz/OpenStreetMap_cleanup_scripts/src/branch/master/recurrent_bot_edits may have more up to date code version that what is listed on this page

Opt-out

Please write at forum topic where it was discussed .

Note that in case of opt-out exactly the same edit will be made manually.