2021-12-26 14:57:34
def Identifier2(input_address):
    # input_address=preprocessor.preprocessing(input_address)
    # input_address=input_address.lower()
    # input_address=synonym.preprocess_string(input_address)
    result_list=[]
    result_list2=[]
    for district_key,district_info in DSU.items():
      find_subdistrict="None"
      find_union="None"
      result_dictionary={}
      c_area=[]
      tag=0
      try:
        #district_info['area_regex']=district_info['area_regex'].strip('\s+')
        if re.search('\s+'+district_info['District_regex']+'\s+',' '+input_address+' '):
          #print('area_regex')
          rd=district_key
          c_area.append(district_key)
      except:
        pass
 
      for subdistrict_key,subdistrict_info in district_info['Sub District'].items():
 
        find=0
        if ' '+subdistrict_key.lower()+' ' in ' '+input_address.lower()+' ' and len(subdistrict_key)!=0:
            find_subdistrict=subdistrict_key
            x=subdistrict_info['Union']
            if len(x)!=0:
              for o in x:
                if finalresult(o,input_address)==True:
                  find_union=o
                  #print("Yes",find_union)
                  break
        if find_subdistrict=="None":
          try:
            if re.search('\s+'+subdistrict_info['Subdistrict_regex']+'\s+',' '+input_address+' ') and len(subdistrict_key)!=0:
              find_subdistrict=subdistrict_key
              x=subdistrict_info['Union']             
              if len(x)!=0:
                for o in x:
                  if finalresult(o,input_address)==True:
                    find_union=o
                    break
                find+=1
              #break
          except Exception:
            pass
        # if find_subdistrict=="None":
        #   if finalresult(subdistrict_key.lower(),input_address)==True and 'block' not in subdistrict_key.lower() and len(subdistrict_key)!=0:
        #     find_subdistrict=subdistrict_key
        #     x=subdistrict_info['superfind_subdistrict']
        #     if len(x)!=0:
        #       for o in x:
        #         if finalresult(o,input_address)==True and 'Block' not in o and 'Sector' not in o:
        #           find_union=o
        #           break
 
 
      if find_subdistrict!="None" and find_union!="None" and len(find_subdistrict)!=0 and find_subdistrict not in area_as_ds:
        result_dictionary["district"]=district_key
        result_dictionary["sub_district"]=find_subdistrict
        result_dictionary["union"]=find_union
        result_dictionary['tag']=tag
        result_list.append(result_dictionary)
 
      if find_subdistrict!="None" and len(find_subdistrict)!=0 and find_subdistrict not in area_as_ds:
        result_dictionary["district"]=district_key
        result_dictionary["sub_district"]=find_subdistrict
        result_dictionary["union"]=find_union
        result_dictionary['tag']=tag
        result_list2.append(result_dictionary)
 
    if len(result_list)==0 and len(result_list2)==1:
      result_list=result_list2
 
    if len(c_area)!=0 and len(result_list)==0:
      result_dictionary["district"]=c_area[0]
      result_dictionary["sub_district"]="None"
      result_dictionary["union"]="None"
      result_dictionary['tag']=1
      result_list.append(result_dictionary)
    return result_list
Invalid Email or Password