<commit_before># -*- coding: utf-8 -*-
"""
Created on Fri Mar 18 18:27:09 2016

@author: elliott
"""

import pandas as pd
from datetime import datetime as dt
from cl.lib.import_lib import find_person
from cl.corpus_importer.import_columbia.parse_judges import find_judges

#df = pd.read_csv('document_data_5000.sql', sep='\t',header=None)
#df = df[[3,4,17]]
#df.columns = ['date_filed','court_id','judges']
#df.to_csv('/home/elliott/vmware/freelawmachine/flp/columbia_data/judges/fed-judges-test.csv')

df = pd.read_csv('/vagrant/flp/columbia_data/judges/fed-judges-test.csv')

cas = ['ca'+str(n) for n in range(1,12)]

matchcount = 0
panelcount = 0
zerocount = 0

for i, row in df.iterrows():
    #if row.court_id not in cas:
    #    continue
    if pd.isnull(row.judges):
        continue  
    
    judges = find_judges(row.judges)    
    date_filed = dt.strptime(row.date_filed, "%Y-%m-%d")    
    candidates = []
    for judge in judges:        
        candidates.append(find_person(judge, row.court_id, case_date=date_filed))    
    
    candidates = [c for c in candidates if c is not None]
    if len(candidates) == 1:
        matchcount += 1
    if len(candidates) > 1:
        panelcount += 1
    if len(candidates) == 0:
        zerocount += 1
    
        <commit_msg>Judge authorship code. 	modified:   cl/people_db/import_judges/match_federal_cases.py<commit_after># -*- coding: utf-8 -*-
"""
Created on Fri Mar 18 18:27:09 2016

@author: elliott
"""

import pandas as pd
from datetime import datetime as dt
from cl.lib.import_lib import find_person
from cl.corpus_importer.import_columbia.parse_judges import find_judges

#df = pd.read_csv('document_data_5000.sql', sep='\t',header=None)
#df = df[[3,4,17]]
#df.columns = ['date_filed','court_id','judges']
#df.to_csv('/home/elliott/vmware/freelawmachine/flp/columbia_data/judges/fed-judges-test.csv')

df = pd.read_csv('/vagrant/flp/columbia_data/judges/fed-judges-test.csv')

cas = ['ca'+str(n) for n in range(1,12)]

matchcount = 0
panelcount = 0
zerocount = 0

for i, row in df.iterrows():
    #if row.court_id not in cas:
    #    continue
    if pd.isnull(row.judges):
        continue  
    
    judges = find_judges(row.judges)    
    date_filed = dt.strptime(row.date_filed, "%Y-%m-%d")    
    candidates = []
    for judge in judges:        
        candidates.append(find_person(judge, row.court_id, case_date=date_filed))    
    
    candidates = [c for c in candidates if c is not None]
    
    if len(candidates) == 1:
        author = candidates[0]
    if len(candidates) > 1:
        panel = candidates
    
    if len(candidates) == 1:
        matchcount += 1
    if len(candidates) > 1:
        panelcount += 1
    if len(candidates) == 0:
        zerocount += 1
    
        
{'fraction_non_alphanumeric': 0.13335742681604626, 'fraction_numerical': 0.02493675460787857, 'mean_word_length': 3.0174165457184325, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '5929558', 'n_tokens_mistral': 1077, 'n_tokens_neox': 1008, 'n_words': 224}