INNER CODE UNIT · Python

prepare_tag_lists

Zverik/every_door · tools/add_taginfo.py:66

def prepare_tag_lists(cur, tcur, wcur):
    def build_rows(tags: set[str], usage: dict[str, int]) -> Generator[tuple]:
        # We duplicate rows for multi-word values.
        for kv in tags:
            count = usage[kv]
            k, v = kv.split('=', 1)
            words = v.split('_')
            for i, word in enumerate(words):
                yield (word.lower(), k, v, count if i == 0 else count // 2)

    # Query all tags for POI keys with enough usage.
    ph = ','.join('?' * len(POI_KEYS))
    tcur.execute(
        "select key, value, count_all from tags "
        f"where key in ({ph}) and count_nodes >= 100 "
        "and value not in ('yes', 'no', 'fixme')",
        POI_KEYS)
    # Under 1000 results, no point in memory management.

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…