<commit_before>import csv
from pymongo import MongoClient
from datetime import datetime
import json

client = MongoClient()

incidents = client.acab_db.incidents

"""
Things to check:
- Compile types of incidents
- Aggregate stuff, idfk, just get the things in a db first
"""

def do_stuff(year):
    police_file = csv.DictReader(open('sfpd/sfpd_incident_with_zip_%d.csv' % year))
    for incident in police_file:
        time = incident.pop('Time',None)
        incident['Date'] = datetime.strptime('%s %s' % (incident['Date'], time), '%m/%d/%Y %H:%M' )
        incidents.insert(incident)

#[do_stuff(year) for year in [2003,2004,2005,2006,2007,2008,2009,2010,2011,2012,2013,2014]]

def incident_types(year):
    return incidents.aggregate([
        { '$match' : {'ZIP':'94110', 'Date': {'$gte':datetime(year,1,1),'$lte':datetime(year,12,31)} } },
        { '$group' : {"_id":"$Resolution", "count":{"$sum":1} } },
        { '$sort' : {'count':-1} }<commit_msg>fixed dumb comment<commit_after>import csv
from pymongo import MongoClient
from datetime import datetime
import json

client = MongoClient()

incidents = client.acab_db.incidents

def incident_types(year):
    return incidents.aggregate([
        { '$match' : {'ZIP':'94110', 'Date': {'$gte':datetime(year,1,1),'$lte':datetime(year,12,31)} } },
        { '$group' : {"_id":"$Resolution", "count":{"$sum":1} } },
        { '$sort' : {'count':-1} }
{'fraction_non_alphanumeric': 0.1875, 'fraction_numerical': 0.052556818181818184, 'mean_word_length': 4.591269841269841, 'pattern_counts': {'":': 6, '<': 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': '3039118', 'n_tokens_mistral': 542, 'n_tokens_neox': 486, 'n_words': 102}