Saving progress
This commit is contained in:
parent
f817021f51
commit
8fcd54beb3
@ -18,7 +18,8 @@ def findrule1_1(rawstring, special_character):
|
|||||||
else:
|
else:
|
||||||
False
|
False
|
||||||
|
|
||||||
'''rawstring = "Create Smart Contract with the name swap-rupee-bioscope@ of the type continuous-event* at the address oRRCHWouTpMSPuL6yZRwFCuh87ZhuHoL78$ with contract-conditions :(1) subtype = tokenswap (2) accepting_token=rupee# (3) selling_token = bioscope# (4) price = '15' (5) priceType = ‘predetermined’ (6) direction = oneway"
|
'''
|
||||||
|
rawstring = "Create Smart Contract with the name swap-rupee-bioscope@ of the type continuous-event* at the address oRRCHWouTpMSPuL6yZRwFCuh87ZhuHoL78$ with contract-conditions :(1) subtype = tokenswap (2) accepting_token=rupee# (3) selling_token = bioscope# (4) price = '15' (5) priceType = ‘predetermined’ (6) direction = oneway"
|
||||||
rawstring1 = "send 500 rmt1# rmt2# rmt3#"
|
rawstring1 = "send 500 rmt1# rmt2# rmt3#"
|
||||||
|
|
||||||
response = findrule1(rawstring1, '#')
|
response = findrule1(rawstring1, '#')
|
||||||
@ -27,8 +28,8 @@ print(response)
|
|||||||
|
|
||||||
response = findrule1(rawstring, '#')
|
response = findrule1(rawstring, '#')
|
||||||
print(f"\n\nResponse for rawstring searching #")
|
print(f"\n\nResponse for rawstring searching #")
|
||||||
print(response) '''
|
print(response)
|
||||||
|
'''
|
||||||
|
|
||||||
inputstring = " : rmt3# "
|
inputstring = " : rmt3# "
|
||||||
special_character = "#"
|
special_character = "#"
|
||||||
@ -86,9 +87,6 @@ def findrule3(text):
|
|||||||
|
|
||||||
##########
|
##########
|
||||||
|
|
||||||
denied_list = ['transfer', 'send', 'give'] # keep everything lowercase
|
|
||||||
permitted_list = ['incorporate', 'create', 'start'] # keep everything lowercase
|
|
||||||
|
|
||||||
def findWholeWord(w):
|
def findWholeWord(w):
|
||||||
return re.compile(r'\b({0})\b'.format(w), flags=re.IGNORECASE).search
|
return re.compile(r'\b({0})\b'.format(w), flags=re.IGNORECASE).search
|
||||||
|
|
||||||
@ -116,17 +114,30 @@ def truefalse_rule2(rawstring, permitted_list, denied_list):
|
|||||||
response = truefalse_rule2(teststring, permitted_list, denied_list)
|
response = truefalse_rule2(teststring, permitted_list, denied_list)
|
||||||
print(response)'''
|
print(response)'''
|
||||||
|
|
||||||
|
|
||||||
# Token incorporation operation
|
# Token incorporation operation
|
||||||
## Existance of keyword
|
## Existance of keyword
|
||||||
|
|
||||||
rawstring = "create 5 million rmt#"
|
def apply_rule1(*argv):
|
||||||
operation = truefalse_rule2(rawstring, permitted_list, denied_list)
|
a = argv[0](*argv[1:])
|
||||||
if not operation:
|
if a is False:
|
||||||
formatOutput("noise")
|
return None
|
||||||
tokenName = findrule1_1(rawstring, "#")
|
else:
|
||||||
if not tokenName:
|
return a
|
||||||
formatOutput("noise")
|
|
||||||
transferamount = findrule3(rawstring)
|
|
||||||
pdb.set_trace()
|
|
||||||
|
|
||||||
|
|
||||||
|
rawstring = "create 5 million rmt# transfer"
|
||||||
|
|
||||||
|
# desired output format - outputreturn('token_incorporation',f"{flodata}", f"{tokenname}", f"{tokenamount}")
|
||||||
|
tokenname = apply_rule1(findrule1_1,rawstring,"#")
|
||||||
|
print(tokenname)
|
||||||
|
denied_list = ['transfer', 'send', 'give'] # keep everything lowercase
|
||||||
|
permitted_list = ['incorporate', 'create', 'start'] # keep everything lowercase
|
||||||
|
if tokenname is not None:
|
||||||
|
isIncorporate = apply_rule1(truefalse_rule2, rawstring, permitted_list, denied_list)
|
||||||
|
|
||||||
|
operationname = apply_rule1(truefalse_rule2, rawstring, permitted_list, denied_list)
|
||||||
|
if not operation:
|
||||||
|
formatOutput("noise")
|
||||||
|
|
||||||
|
#response_string = outputreturn('token_incorporation','create 5000 rmt#', 'rmt', 5000.0)
|
||||||
|
#print(response_string)
|
||||||
149
planning.py
Normal file
149
planning.py
Normal file
@ -0,0 +1,149 @@
|
|||||||
|
'''
|
||||||
|
The problem we are facing:
|
||||||
|
|
||||||
|
* Token transactions don't have * or @ symbols
|
||||||
|
|
||||||
|
* Smart Contract transactions have * , @ , # symbols
|
||||||
|
|
||||||
|
* Smart Contract transaction of the type one time event have 1 # before colon
|
||||||
|
|
||||||
|
* Smart Contract transaction of the type continuous event has 2 # after colon
|
||||||
|
|
||||||
|
* So we are checking for hashes based on the type of smart contract(identified by *)
|
||||||
|
|
||||||
|
* But the above check disregards checking hashes in token transactions
|
||||||
|
'''
|
||||||
|
|
||||||
|
# Write down all the possible flodata( with all combinations possible) for
|
||||||
|
'''
|
||||||
|
Token creation
|
||||||
|
create 500 million rmt#
|
||||||
|
['#']
|
||||||
|
|
||||||
|
Token transfer
|
||||||
|
transfer 200 rmt#
|
||||||
|
['#']
|
||||||
|
|
||||||
|
One time event userchoice creation
|
||||||
|
Create Smart Contract with the name India-elections-2019@ of the type one-time-event* using the asset rmt# at the address F7osBpjDDV1mSSnMNrLudEQQ3cwDJ2dPR1$ with contract-conditions: (1) contractAmount=0.001rmt (2) userChoices=Narendra Modi wins| Narendra Modi loses (3) expiryTime= Wed May 22 2019 21:00:00 GMT+0530
|
||||||
|
['@','*','#','$',':']
|
||||||
|
['@','*','#','$',':','#']
|
||||||
|
|
||||||
|
One time event userchoice participation
|
||||||
|
send 0.001 rmt# to india-elections-2019@ to FLO address F7osBpjDDV1mSSnMNrLudEQQ3cwDJ2dPR1 with the userchoice:'narendra modi wins'
|
||||||
|
['#','@',':']
|
||||||
|
['#','@','$',':']
|
||||||
|
|
||||||
|
One time event userchoice trigger
|
||||||
|
india-elections-2019@ winning-choice:'narendra modi wins'
|
||||||
|
['@',':']
|
||||||
|
|
||||||
|
One time event timeevent creation
|
||||||
|
Create Smart Contract with the name India-elections-2019@ of the type one-time-event* using the asset rmt# at the address F7osBpjDDV1mSSnMNrLudEQQ3cwDJ2dPR1$ with contract-conditions: (1) contractAmount=0.001rmt (2) expiryTime= Wed May 22 2019 21:00:00 GMT+0530
|
||||||
|
['@','*','#','$',':']
|
||||||
|
['@','*','#','$',':','#']
|
||||||
|
|
||||||
|
One time event timeevent participation
|
||||||
|
send 0.001 rmt# to india-elections-2019@ to FLO address F7osBpjDDV1mSSnMNrLudEQQ3cwDJ2dPR1
|
||||||
|
['#','@']
|
||||||
|
['#','@','$']
|
||||||
|
|
||||||
|
Continuos event token swap creation
|
||||||
|
Create Smart Contract with the name swap-rupee-bioscope@ of the type continuous-event* at the address oRRCHWouTpMSPuL6yZRwFCuh87ZhuHoL78$ with contract-conditions :
|
||||||
|
(1) subtype = tokenswap
|
||||||
|
(2) accepting_token = rupee#
|
||||||
|
(3) selling_token = bioscope#
|
||||||
|
(4) price = '15'
|
||||||
|
(5) priceType = ‘predetermined’
|
||||||
|
(6) direction = oneway
|
||||||
|
|
||||||
|
['@','*','$',':','#','#']
|
||||||
|
|
||||||
|
Continuos event tokenswap deposit
|
||||||
|
Deposit 15 bioscope# to swap-rupee-bioscope@ its FLO address being oRRCHWouTpMSPuL6yZRwFCuh87ZhuHoL78$ with deposit-conditions: (1) expiryTime= Wed Nov 17 2021 21:00:00 GMT+0530
|
||||||
|
['#','@',':']
|
||||||
|
['#','@','$',':']
|
||||||
|
|
||||||
|
Continuos event tokenswap participation
|
||||||
|
Send 15 rupee# to swap-rupee-article@ its FLO address being FJXw6QGVVaZVvqpyF422Aj4FWQ6jm8p2dL$
|
||||||
|
['#','@']
|
||||||
|
['#','@','$']
|
||||||
|
'''
|
||||||
|
|
||||||
|
'''
|
||||||
|
|
||||||
|
['#'] - Token creation
|
||||||
|
|
||||||
|
['#'] - Token particiation
|
||||||
|
|
||||||
|
|
||||||
|
['@','*','#','$',':'] - Smart contract creation user-choice
|
||||||
|
['@','*','#','$',':','#']
|
||||||
|
|
||||||
|
['#','@',':'] - Smart contract participation user-choice
|
||||||
|
['#','@','$',':']
|
||||||
|
|
||||||
|
['@',':'] - Smart contract trigger user-choice
|
||||||
|
|
||||||
|
|
||||||
|
['@','*','#','$',':'] - Smart contract creation - ote-timebased
|
||||||
|
['@','*','#','$',':','#']
|
||||||
|
|
||||||
|
['#','@'] - Smart contract particiation - ote-timebased
|
||||||
|
['#','@','$']
|
||||||
|
|
||||||
|
|
||||||
|
['@','*','$',':','#','#'] - Smart contract creation - continuos event - tokenswap
|
||||||
|
|
||||||
|
['#','@',':'] - Smart contract deposit - continuos event - tokenswap
|
||||||
|
['#','@','$',':']
|
||||||
|
|
||||||
|
['#','@'] - Smart contract participation - continuos event - tokenswap
|
||||||
|
['#','@','$'] - Smart contract participation - continuos event - tokenswap
|
||||||
|
|
||||||
|
'''
|
||||||
|
|
||||||
|
'''
|
||||||
|
|
||||||
|
['#'] - Token creation
|
||||||
|
|
||||||
|
['#'] - Token particiation
|
||||||
|
|
||||||
|
|
||||||
|
['@','*','#','$',':'] - Smart contract creation user-choice
|
||||||
|
['@','*','#','$',':','#']
|
||||||
|
|
||||||
|
['@','*','#','$',':'] - Smart contract creation - ote-timebased
|
||||||
|
['@','*','#','$',':','#']
|
||||||
|
|
||||||
|
|
||||||
|
['#','@',':'] - Smart contract participation user-choice
|
||||||
|
['#','@','$',':']
|
||||||
|
|
||||||
|
['#','@',':'] - Smart contract deposit - continuos event - tokenswap
|
||||||
|
['#','@','$',':']
|
||||||
|
|
||||||
|
|
||||||
|
['@',':'] - Smart contract trigger user-choice
|
||||||
|
|
||||||
|
|
||||||
|
['#','@'] - Smart contract particiation - ote-timebased
|
||||||
|
['#','@','$']
|
||||||
|
|
||||||
|
['#','@'] - Smart contract participation - continuos event - tokenswap
|
||||||
|
['#','@','$'] - Smart contract participation - continuos event - tokenswap
|
||||||
|
|
||||||
|
|
||||||
|
['@','*','$',':','#','#'] - Smart contract creation - continuos event - tokenswap
|
||||||
|
|
||||||
|
'''
|
||||||
|
|
||||||
|
'''
|
||||||
|
Conflicts -
|
||||||
|
|
||||||
|
1. Token creation | Token participation
|
||||||
|
2. Smart contract CREATION of the type one-time-event-userchoice | one-time-event-timebased
|
||||||
|
3. Smart contract PARTICIPATION user-choice | Smart contract DEPOSIT continuos-event token-swap
|
||||||
|
4. Smart contract PARTICIPATION one-time-event-timebased | Smart contract participation - continuos event - tokenswap
|
||||||
|
|
||||||
|
'''
|
||||||
117
test.py
Normal file
117
test.py
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
import pdb
|
||||||
|
|
||||||
|
"""
|
||||||
|
Find make lists of #, *, @ words
|
||||||
|
|
||||||
|
If only 1 hash word and nothing else, then it is token related ( tokencreation or tokentransfer )
|
||||||
|
|
||||||
|
If @ is present, then we know it is smart contract related
|
||||||
|
@ (#)pre: - participation , deposit
|
||||||
|
@ * (#)pre: - one time event creation
|
||||||
|
@ * (# #)post: - token swap creation
|
||||||
|
@ - trigger
|
||||||
|
|
||||||
|
Check for 1 @ only
|
||||||
|
Check for 1 # only
|
||||||
|
Check for @ (#)pre:
|
||||||
|
Check for @ * (#)pre:
|
||||||
|
Check for @ * (# #)post:
|
||||||
|
|
||||||
|
special_character_frequency = {
|
||||||
|
'precolon': {
|
||||||
|
'#':0,
|
||||||
|
'*':0,
|
||||||
|
'@':0,
|
||||||
|
':':0
|
||||||
|
}
|
||||||
|
|
||||||
|
for word in allList:
|
||||||
|
if word.endswith('#'):
|
||||||
|
special_character_frequency['#'] = special_character_frequency['#'] + 1
|
||||||
|
elif word.endswith('*'):
|
||||||
|
special_character_frequency['*'] = special_character_frequency['*'] + 1
|
||||||
|
elif word.endswith('@'):
|
||||||
|
special_character_frequency['@'] = special_character_frequency['@'] + 1
|
||||||
|
elif word.endswith(':'):
|
||||||
|
special_character_frequency[':'] = special_character_frequency[':'] + 1
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
def findrules(rawstring, special_characters):
|
||||||
|
wordList = []
|
||||||
|
for word in rawstring.split(' '):
|
||||||
|
if word[-1] in special_characters and (len(word) != 1 or word==":"):
|
||||||
|
wordList.append(word)
|
||||||
|
return wordList
|
||||||
|
|
||||||
|
|
||||||
|
def checkSearchPattern1(parsed_list, searchpatterns):
|
||||||
|
for firstCategorization in searchpatterns.keys():
|
||||||
|
counter = 0
|
||||||
|
for key in searchpatterns[firstCategorization].keys():
|
||||||
|
if len(parsed_list) != len(searchpatterns[firstCategorization][key]):
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
pdb.set_trace()
|
||||||
|
for idx,val in enumerate(parsed_list):
|
||||||
|
if not parsed_list[idx].endswith(searchpatterns[firstCategorization][key][idx]):
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
if counter >= 1:
|
||||||
|
return firstCategorization
|
||||||
|
return 'noise'
|
||||||
|
|
||||||
|
|
||||||
|
def checkSearchPattern(parsed_list, searchpattern):
|
||||||
|
if len(parsed_list)!=len(searchpattern):
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
for idx,val in enumerate(parsed_list):
|
||||||
|
if not parsed_list[idx].endswith(searchpattern[idx]):
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def className(rawstring):
|
||||||
|
# Create a list that contains @ , # , * and : ; in actual order of occurence with their words. Only : is allowed to exist without a word in front of it.
|
||||||
|
# Check for 1 @ only followed by :, and the class is trigger
|
||||||
|
# Check for 1 # only, then the class is tokensystem
|
||||||
|
# Check for @ in the first position, * in the second position, # in the third position and : in the fourth position, then class is one time event creation
|
||||||
|
# Check for @ in the first position, * in the second position and : in the third position, then hash is in 4th position, then hash in 5th position | Token swap creation
|
||||||
|
|
||||||
|
allList = findrules(rawstring,['#','*','@',':'])
|
||||||
|
|
||||||
|
allList = ['rmt@','rmt*',':',"rmt#","rmt#"]
|
||||||
|
allList1 = ['rmt#',':',"rmt@"]
|
||||||
|
|
||||||
|
search_patterns = {
|
||||||
|
'tokensystem-C':{
|
||||||
|
1:['#']
|
||||||
|
},
|
||||||
|
'smart-contract-creation-C':{
|
||||||
|
1:['@','*','#','$',':'],
|
||||||
|
2:['@','*','#','$',':','#']
|
||||||
|
},
|
||||||
|
'smart-contract-participation-deposit-C':{
|
||||||
|
1:['#','@',':'],
|
||||||
|
2:['#','@','$',':']
|
||||||
|
},
|
||||||
|
'userchoice-trigger':{
|
||||||
|
1:['@',':']
|
||||||
|
},
|
||||||
|
'smart-contract-participation-ote-ce-C':{
|
||||||
|
1:['#','@'],
|
||||||
|
2:['#','@','$']
|
||||||
|
},
|
||||||
|
'smart-contract-creation-ce-tokenswap':{
|
||||||
|
1:['@','*','$',':','#','#']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
patternmatch = checkSearchPattern(allList1, ['#',':','@','@'])
|
||||||
|
print(f"Patternmatch is {patternmatch}")
|
||||||
|
|
||||||
|
|
||||||
|
rawstring = "test rmt# rmt@ rmt* : rmt# rmt# test"
|
||||||
|
className(rawstring)
|
||||||
Loading…
Reference in New Issue
Block a user