Bugfix: [] and {} now conver to () with weights

Bugfix: Brackets convert to weight while properly preserving the token
pull/18/head
blongty 2023-04-24 23:12:37 -07:00
parent 673a6a7f7b
commit 46528b8968
1 changed files with 2 additions and 2 deletions

View File

@ -84,10 +84,10 @@ def token_bracket_to_weight(token:str):
depth = abs(power)
if re.search(r':\d+.?\d*', token):
return token[depth-1:len(token)-1 if depth == 1 else - depth]
return token[depth:len(token)-depth]
weight = 1.1 ** power
return token[depth-1:len(token)-1 if depth == 1 else -depth] + ('' if token[-depth-1:-depth] == ':' else ':') + f'{weight:.2f}' + get_closing(brackets[0])
return '(' + token[depth:len(token)-depth] + ('' if token[-depth-1:-depth] == ':' else ':') + f'{weight:.2f})'
def extract_networks(tokens: list):