<jupyter_start><jupyter_text>Getting Fielding Data (unmapped)<jupyter_code>team1={}   # Match id: [(player id, dismissal)]
team2={}
data_keys = list(data.keys())
for i in data_keys:
        if(data[i]!=None):
            for j in range(0,len(data[i]['BATTING1'])):
                team2.setdefault(i,[]).append((j,data[i]['BATTING1'][j][1].lower()))
            for k in range(0,len(data[i]['BATTING2'])):
                team1.setdefault(i,[]).append((k,data[i]['BATTING2'][k][1].lower()))
len(team1)
len(team2)
team1_keys=team1.keys()
team2_keys=team2.keys()
fielders={}
for i in team2_keys:
    
    for j in team2[i]:
        search_in=j[1].replace('\u2020','')
        pattern_catch = re.search('^c\s+',search_in)
        pattern_st = re.search('^st\s+',search_in)
        
        if pattern_catch:
            
            splitted = re.split('c\s+|\s+b\s+',search_in)
            catch_list = list(filter(None, splitted))
            if (len(catch_list)<2):
                catch_list.append(catch_list[0])
            if (catch_list[0]=='&'):
                catch_list[0]=catch_list[1]
            fielders.setdefault(i,[]).append((j[0],{'c2':catch_list[0],'b2':catch_list[1]}))
            
            pattern_catch=None
            
        elif pattern_st:
            splitted = re.split('st\s+|\s+b\s+',search_in)
            st_list = list(filter(None, splitted))
            if (len(st_list)<2):
                st_list.append(st_list[0])
            if (st_list[0]=='&'):
                st_list[0]=st_list[1]
            fielders.setdefault(i,[]).append((j[0],{'st2':st_list[0],'b2':st_list[1]}))
                
            pattern_st=None
for i in team1_keys:
    
    for j in team1[i]:
        search_in=j[1].replace('\u2020','')
        pattern_catch = re.search('^c\s+',search_in)
        pattern_st = re.search('^st\s+',search_in)
        
        if pattern_catch:
            
            splitted = re.split('c\s+|\s+b\s+',search_in)
            catch_list = list(filter(None, splitted))
            if (len(catch_list)<2):
                catch_list.append(catch_list[0])
            if (catch_list[0]=='&'):
                catch_list[0]=catch_list[1]
            fielders.setdefault(i,[]).append((j[0],{'c1':catch_list[0],'b1':catch_list[1]}))
            
            pattern_catch=None
            
        elif pattern_st:
            splitted = re.split('st\s+|\s+b\s+',search_in)
            st_list = list(filter(None, splitted))
            if (len(st_list)<2):
                st_list.append(st_list[0])
            if (st_list[0]=='&'):
                st_list[0]=st_list[1]
            fielders.setdefault(i,[]).append((j[0],{'st1':st_list[0],'b1':st_list[1]}))
                
            pattern_st=None
with open('fielder1.json', 'w') as fp:
    json.dump(fielders, fp, indent = 4)<jupyter_output><empty_output><jupyter_text>Mapped<jupyter_code>attr= pd.read_csv('Data/attributes.csv')
attr.head()
len(attr['Full Name'].unique())
len(attr)
attr['Full Name'].value_counts()
attr.columns = ['FullName','Born','Bats' ,'Bowls','Code']
attr['FullName']=attr['FullName'].str.lower()
fielders={} # Match id : [(player id of player dismissed, c/st, b)]
data_keys = list(data.keys())
for i in data_keys:
    
    for j in data[i]:
        search_in=j[1].replace('\u2020','')
        pattern_catch = re.search('^c\s+',search_in)
        pattern_st = re.search('^st\s+',search_in)
        
        if pattern_catch:
            
            splitted = re.split('c\s+|\s+b\s+',search_in)
            catch_list = list(filter(None, splitted))
            if (len(catch_list)<2):
                catch_list.append(catch_list[0])
            if (catch_list[0]=='&'):
                catch_list[0]=catch_list[1]
            c_id=attr[attr['FullName'].str.contains(catch_list[0].lower())]['PlayerId']
            b_id=attr[attr['FullName'].str.contains(catch_list[1].lower())]['PlayerId']
            
            if (len(c_id)==1 and len(b_id)==1):
                fielders.setdefault(i,[]).append((j[0],{'c':int(c_id.iloc[0]),'b':int(b_id.iloc[0])}))
            else:
                if(len(c_id)>1):
                    id1=[pl for pl in c_id if pl in players[i]]
                    if(len(id1)==1):
                        catch_list[0]=id1
                   
                if(len(b_id)>1):
                    id2=[pl for pl in b_id if pl in players[i]]
                    if(len(id2)==1):
                        catch_list[1]=id2
                
                if(len(c_id)==1):
                    catch_list[0]=int(c_id.iloc[0])
                
                if(len(b_id)==1):
                    catch_list[1]=int(b_id.iloc[0])
                        
            fielders.setdefault(i,[]).append((j[0],{'c2':catch_list[0],'b2':catch_list[1]}))
            
            pattern_catch=None
            
        elif pattern_st:
            splitted = re.split('st\s+|\s+b\s+',search_in)
            st_list = list(filter(None, splitted))
            if (len(st_list)<2):
                st_list.append(st_list[0])
            if (st_list[0]=='&'):
                st_list[0]=st_list[1]
            st_id=attr[attr['FullName'].str.contains(st_list[0].lower())]['PlayerId']
            b1_id=attr[attr['FullName'].str.contains(st_list[1].lower())]['PlayerId']
            
            if (len(st_id)==1 and len(b1_id)==1):
                fielders.setdefault(i,[]).append((j[0],{'st':int(st_id.iloc[0]),'b':int(b1_id.iloc[0])}))
                
            else:
                if(len(st_id)>1):
                    id1=[pl for pl in st_id if pl in players[i]]
                    if(len(id1)==1):
                        st_list[0]=id1
                   
                if(len(b1_id)>1):
                    id2=[pl for pl in b1_id if pl in players[i]]
                    if(len(id2)==1):
                        st_list[1]=id2
                
                if(len(st_id)==1):
                    st_list[0]=int(st_id.iloc[0])
                
                if(len(b1_id)==1):
                    st_list[1]=int(b1_id.iloc[0])
                        
            fielders.setdefault(i,[]).append((j[0],{'st2':st_list[0],'b2':st_list[1]}))
                
            pattern_st=None
with open('fielders.json', 'w') as fp:
    json.dump(fielders, fp,indent=4)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1757203589985829, 'fraction_numerical': 0.024720516454101716, 'mean_word_length': 1.838248436103664, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 13, '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}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '605475', 'license': 'MIT', 'n_tokens_mistral': 2282, 'n_tokens_neox': 2201, 'n_words': 272, 'path': 'CreatingFielders(Json).ipynb', 'repo_name': 'someshsingh22/TeamEleven', 'size': '6351'}