TerraHarmonize package

Module contents

class TerraHarmonize.POC_matching(comp, check_list)

Bases: object

Args:

comp: str

The survey number that needs to be looked for a match.

to_check_list: list

List containing survey number from our database for POC

Note

Make sure it is a list and not a string list. Import ast and use ast.literal_eval(<list>) to convert string-list to list.

D1D2_cold()

This method prevents one-to-many matches (one-D1 and many-D2) in D1-D2 matching

Return:

list containing the index of the correct survey number

Example:

>>> string = '13/1'
>>> comparing_list = ['13 (s)','14/1 (s)','13/2 (p)','13/1/1 (p)','13/1/2 (p)']
    # correct index is [0] i.e ['13 (s)']
>>> print(POC_matching(string,comparing_list).D1D2_cold())
    [0]
static best_val(actual_val, group_val, region='Tel', split_pat='\\/|\\-')

If you have one-to-many matches and want to select the first bigger parcel (survey number) amongst the list

Args:

actual_val: str

The survey number (provided by the client) based on which parcel needs to be selected

group_val: list

The list of survey number amongst which you want to know the best parcel to retain

region: str

the char to be replaced with. Supports Hi, Tel (default), Ka, and Od. If survey_number is in english than use Hi.

split_pat: str

The pattern (regex prefered) based on which the text has to split. The default is /|- i.e. split is based on either ‘/’ or ‘-’.

Return:

The function will return the index of the best parcel from the list

static char_assasin(eng_name, region='Tel')

converts the village names with regional character to english.

Args:

eng_name: str

The name (regional) that needs to be converted to english.

region: str

the char to be replaced with. Supports Hi, Tel (default), Ka, and Od.

Return:

string

Example:

>>> string = '12/अ/1'
>>> print(POC_matching.char_assasin(string,'Hi'))
    '12/A/1'
right_choice()

Applicabe to states like MP, MH, OD, and RJ if survey number does not have regional/english alphabet. Here the survey number is split based on /. but if you find ‘-’ or ‘\’ as a split, go for right_choice_AP.

Return:

list containing the index of the correct survey number

Note

This method is used for states that do not have regional language issues and the client data format matches the DB format of the survey number

Example:

>>> string = '13/1'
>>> comparing_list = ['13/1 (s)','14/1 (s)','13/2 (p)','13/1/1 (p)']
    # correct index is [0,3] i.e ['13/1 (s)','13/1/1 (p)']
>>> print(POC_matching(string,comparing_list).right_choice())
    [0,3]
right_choice_AP(include='normal', state=None, split_pat='\\/|\\-')

Used for matching states that have regional/english alphabet in survey_no. This can also be used if the survey_number has different pattern for spliting.

Args:

include: str

It includes normal (default) which is used when you want to match without changing the characters i.e the english alphabet will not be converted to Regional character for matching and both, which is first matched without changing alphabets and then matched by changing alphabets.

state: str

The state you are working with. By default state is None. The state can be anything if include is normal, but if include is both, the state has to be mentioned. It takes TS, AP, MH, RJ, OD or KA

split_pat: str

The pattern (regex prefered) based on which the text has to split. The default is /|- i.e. split is based on either ‘/’ or ‘-’.

Return:

list containing the index of the correct survey number

Example:

>>> string = '13/A1'
>>> comparing_list = ['13/A1','14/A/1','12/A/1','13/అ','13-అ/1']
    #correct matching is [0,3,4] index i.e. '13/A1','13/అ','13-అ/1'
>>> print(POC_matching(string,comparing_list).right_choice_AP(include='normal'))
    [0]
>>> print(POC_matching(string,comparing_list).right_choice_AP(include='both',state='AP'))
    [0, 3, 4]
static string_updation(string, pattern='En')

This method adds ‘/’ inbetween an alphabet and a digit, if alphabet is preceded or succeeded by a digit.

Args:

string: str

string you want to change

pattern: str

the string you are passing has to refer which pattern; supports En (default), Hi, Tel, Ka, and Od

Return:

string

Example:

>>> data = '13/1AA/BB1/E'
>>> updated_data = string_updation(data,'En')
>>> print(updated_data)
    '13/1/AA/BB/1/E'