INNER CODE UNIT · Python

build_rows

Zverik/every_door · tools/add_taginfo.py:67

    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.
    usage = {f'{row[0]}={row[1]}': row[2] for row in tcur}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…