Update parsing.py
Made the functions more modular
This commit is contained in:
parent
4febedb1d2
commit
a93e6633ef
61
parsing.py
61
parsing.py
@ -1021,24 +1021,8 @@ stream_handler.setFormatter(formatter)
|
|||||||
logger.addHandler(file_handler)
|
logger.addHandler(file_handler)
|
||||||
logger.addHandler(stream_handler)
|
logger.addHandler(stream_handler)
|
||||||
|
|
||||||
def parse_flodata(text, blockinfo, net):
|
# Processing functions for each categorization
|
||||||
if net == 'testnet':
|
def process_tokensystem_C(first_classification, processed_text, clean_text, stateF_mapping, is_testnet):
|
||||||
is_testnet = True
|
|
||||||
else:
|
|
||||||
is_testnet = False
|
|
||||||
|
|
||||||
if text == '':
|
|
||||||
return outputreturn('noise')
|
|
||||||
|
|
||||||
clean_text, processed_text = text_preprocessing(text)
|
|
||||||
# System state
|
|
||||||
print("Processing stateF")
|
|
||||||
stateF_mapping = isStateF(processed_text)
|
|
||||||
first_classification = firstclassification_rawstring(processed_text)
|
|
||||||
parsed_data = None
|
|
||||||
|
|
||||||
|
|
||||||
if first_classification['categorization'] == 'tokensystem-C':
|
|
||||||
# Resolving conflict for 'tokensystem-C'
|
# Resolving conflict for 'tokensystem-C'
|
||||||
tokenname = first_classification['wordlist'][0][:-1]
|
tokenname = first_classification['wordlist'][0][:-1]
|
||||||
if not check_regex("^[A-Za-z][A-Za-z0-9_-]*[A-Za-z0-9]$", tokenname):
|
if not check_regex("^[A-Za-z][A-Za-z0-9_-]*[A-Za-z0-9]$", tokenname):
|
||||||
@ -1081,7 +1065,8 @@ def parse_flodata(text, blockinfo, net):
|
|||||||
else:
|
else:
|
||||||
return outputreturn('noise')
|
return outputreturn('noise')
|
||||||
|
|
||||||
if first_classification['categorization'] == 'smart-contract-creation-C':
|
|
||||||
|
def process_smart_contract_creation_C(first_classification, processed_text, clean_text, blockinfo, stateF_mapping, is_testnet):
|
||||||
# Resolving conflict for 'smart-contract-creation-C'
|
# Resolving conflict for 'smart-contract-creation-C'
|
||||||
operation = apply_rule1(selectCategory, processed_text, create_category, send_category+deposit_category)
|
operation = apply_rule1(selectCategory, processed_text, create_category, send_category+deposit_category)
|
||||||
if not operation:
|
if not operation:
|
||||||
@ -1184,7 +1169,8 @@ def parse_flodata(text, blockinfo, net):
|
|||||||
contract_conditions['payeeAddress'] = {f"{contract_conditions['payeeAddress']}":100}
|
contract_conditions['payeeAddress'] = {f"{contract_conditions['payeeAddress']}":100}
|
||||||
return outputreturn('one-time-event-time-smartcontract-incorporation',f"{contract_token}", f"{contract_name}", f"{contract_address}", f"{clean_text}", f"{contractAmount}", f"{minimum_subscription_amount}" , f"{maximum_subscription_amount}", contract_conditions['payeeAddress'], f"{contract_conditions['expiryTime']}", contract_conditions['unix_expiryTime'], stateF_mapping)
|
return outputreturn('one-time-event-time-smartcontract-incorporation',f"{contract_token}", f"{contract_name}", f"{contract_address}", f"{clean_text}", f"{contractAmount}", f"{minimum_subscription_amount}" , f"{maximum_subscription_amount}", contract_conditions['payeeAddress'], f"{contract_conditions['expiryTime']}", contract_conditions['unix_expiryTime'], stateF_mapping)
|
||||||
|
|
||||||
if first_classification['categorization'] == 'smart-contract-participation-deposit-C':
|
|
||||||
|
def process_smart_contract_participation_deposit_C(first_classification, processed_text, clean_text, blockinfo, stateF_mapping, is_testnet):
|
||||||
# either participation of one-time-event contract or
|
# either participation of one-time-event contract or
|
||||||
operation = apply_rule1(select_category_reject, processed_text, send_category, deposit_category, create_category)
|
operation = apply_rule1(select_category_reject, processed_text, send_category, deposit_category, create_category)
|
||||||
if not operation:
|
if not operation:
|
||||||
@ -1236,7 +1222,9 @@ def parse_flodata(text, blockinfo, net):
|
|||||||
return outputreturn("noise")
|
return outputreturn("noise")
|
||||||
return outputreturn('continuos-event-token-swap-deposit', f"{tokenname}", tokenamount, f"{contract_name}", f"{clean_text}", f"{deposit_conditions['expiryTime']}", stateF_mapping)
|
return outputreturn('continuos-event-token-swap-deposit', f"{tokenname}", tokenamount, f"{contract_name}", f"{clean_text}", f"{deposit_conditions['expiryTime']}", stateF_mapping)
|
||||||
|
|
||||||
if first_classification['categorization'] == 'smart-contract-participation-ote-ce-C':
|
|
||||||
|
|
||||||
|
def process_smart_contract_participation_ote_ce_C(first_classification, processed_text, clean_text, stateF_mapping, is_testnet):
|
||||||
# There is no way to properly differentiate between one-time-event-time-trigger participation and token swap participation
|
# There is no way to properly differentiate between one-time-event-time-trigger participation and token swap participation
|
||||||
# so we merge them in output return
|
# so we merge them in output return
|
||||||
tokenname = first_classification['wordlist'][0][:-1]
|
tokenname = first_classification['wordlist'][0][:-1]
|
||||||
@ -1266,7 +1254,8 @@ def parse_flodata(text, blockinfo, net):
|
|||||||
|
|
||||||
return outputreturn('smart-contract-one-time-event-continuos-event-participation', f"{clean_text}", f"{tokenname}", tokenamount, f"{contract_name}", f"{contract_address}", stateF_mapping)
|
return outputreturn('smart-contract-one-time-event-continuos-event-participation', f"{clean_text}", f"{tokenname}", tokenamount, f"{contract_name}", f"{contract_address}", stateF_mapping)
|
||||||
|
|
||||||
if first_classification['categorization'] == 'userchoice-trigger':
|
|
||||||
|
def process_userchoice_trigger(first_classification, processed_text, stateF_mapping):
|
||||||
contract_name = extract_special_character_word(first_classification['wordlist'],'@')
|
contract_name = extract_special_character_word(first_classification['wordlist'],'@')
|
||||||
if not check_regex("^[A-Za-z][A-Za-z0-9_-]*[A-Za-z0-9]$", contract_name):
|
if not check_regex("^[A-Za-z][A-Za-z0-9_-]*[A-Za-z0-9]$", contract_name):
|
||||||
return outputreturn('noise')
|
return outputreturn('noise')
|
||||||
@ -1276,7 +1265,8 @@ def parse_flodata(text, blockinfo, net):
|
|||||||
return outputreturn('noise')
|
return outputreturn('noise')
|
||||||
return outputreturn('one-time-event-userchoice-smartcontract-trigger', f"{contract_name}", f"{trigger_condition}", stateF_mapping)
|
return outputreturn('one-time-event-userchoice-smartcontract-trigger', f"{contract_name}", f"{trigger_condition}", stateF_mapping)
|
||||||
|
|
||||||
if first_classification['categorization'] == 'smart-contract-creation-ce-tokenswap':
|
|
||||||
|
def process_smart_contract_creation_ce_tokenswap(first_classification, processed_text, clean_text, blockinfo, stateF_mapping, is_testnet):
|
||||||
operation = apply_rule1(selectCategory, processed_text, create_category, send_category+deposit_category)
|
operation = apply_rule1(selectCategory, processed_text, create_category, send_category+deposit_category)
|
||||||
if operation != 'category1':
|
if operation != 'category1':
|
||||||
return outputreturn('noise')
|
return outputreturn('noise')
|
||||||
@ -1322,4 +1312,29 @@ def parse_flodata(text, blockinfo, net):
|
|||||||
|
|
||||||
return outputreturn('continuos-event-token-swap-incorporation', f"{contract_token}", f"{contract_name}", f"{contract_address}", f"{clean_text}", f"{contract_conditions['subtype']}", f"{contract_conditions['accepting_token']}", f"{contract_conditions['selling_token']}", f"{contract_conditions['priceType']}", f"{contract_conditions['price']}", stateF_mapping, f"{contract_conditions['oracle_address']}")
|
return outputreturn('continuos-event-token-swap-incorporation', f"{contract_token}", f"{contract_name}", f"{contract_address}", f"{clean_text}", f"{contract_conditions['subtype']}", f"{contract_conditions['accepting_token']}", f"{contract_conditions['selling_token']}", f"{contract_conditions['priceType']}", f"{contract_conditions['price']}", stateF_mapping, f"{contract_conditions['oracle_address']}")
|
||||||
|
|
||||||
|
def parse_flodata(text, blockinfo, net):
|
||||||
|
is_testnet = net == 'testnet'
|
||||||
|
|
||||||
|
if text == '':
|
||||||
|
return outputreturn('noise')
|
||||||
|
|
||||||
|
clean_text, processed_text = text_preprocessing(text)
|
||||||
|
print("Processing stateF")
|
||||||
|
stateF_mapping = isStateF(processed_text)
|
||||||
|
first_classification = firstclassification_rawstring(processed_text)
|
||||||
|
|
||||||
|
categorization = first_classification['categorization']
|
||||||
|
if categorization == 'tokensystem-C':
|
||||||
|
return process_tokensystem_C(first_classification, processed_text, clean_text, stateF_mapping, is_testnet)
|
||||||
|
elif categorization == 'smart-contract-creation-C':
|
||||||
|
return process_smart_contract_creation_C(first_classification, processed_text, clean_text, blockinfo, stateF_mapping, is_testnet)
|
||||||
|
elif categorization == 'smart-contract-participation-deposit-C':
|
||||||
|
return process_smart_contract_participation_deposit_C(first_classification, processed_text, clean_text, blockinfo, stateF_mapping, is_testnet)
|
||||||
|
elif categorization == 'smart-contract-participation-ote-ce-C':
|
||||||
|
return process_smart_contract_participation_ote_ce_C(first_classification, processed_text, clean_text, stateF_mapping, is_testnet)
|
||||||
|
elif categorization == 'userchoice-trigger':
|
||||||
|
return process_userchoice_trigger(first_classification, processed_text, stateF_mapping)
|
||||||
|
elif categorization == 'smart-contract-creation-ce-tokenswap':
|
||||||
|
return process_smart_contract_creation_ce_tokenswap(first_classification, processed_text, clean_text, blockinfo, stateF_mapping, is_testnet)
|
||||||
|
else:
|
||||||
return outputreturn('noise')
|
return outputreturn('noise')
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user