<commit_before><commit_msg>Stub, needs more work. Count how many address ranges we have in buildings with no other addresses.<commit_after>from sys import argv
from glob import glob
from merge import merge
from pprint import pprint
import re

def findRanges(buildings):
    for building in buildings['data']:
        pprint(building['properties'])

# Run conversions. Expects an chunks/addresses-[district id].shp for each
# chunks/buildings-[district id].shp. Optinally convert only one election district.
if (len(argv) == 2):
    findRanges(merge(
        'chunks/buildings-%s.shp' % argv[1],
        'chunks/addresses-%s.shp' % argv[1]))
else:
    buildingFiles = glob("chunks/buildings-*.shp")
    for buildingFile in buildingFiles:
        matches = re.match('^.*-(\d+)\.shp$', buildingFile).groups(0)
        findRanges(merge(
            buildingFile,
            'chunks/addresses-%s.shp' % matches[0]))
{'fraction_non_alphanumeric': 0.1251372118551043, 'fraction_numerical': 0.005488474204171241, 'mean_word_length': 3.5829145728643215, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4173845', 'n_tokens_mistral': 280, 'n_tokens_neox': 273, 'n_words': 79}