MCPcopy Create free account
hub / github.com/PaddlePaddle/Research / str_to_num

Function str_to_num

NLP/Text2SQL-BASELINE/text2sql/utils/text_utils.py:129–138  ·  view source on GitHub ↗

str to num

(string)

Source from the content-addressed store, hash-verified

127
128
129def str_to_num(string):
130 """str to num"""
131 try:
132 float_val = float(cn_to_an(string))
133 if int(float_val) == float_val:
134 return str(int(float_val))
135 else:
136 return str(float_val)
137 except ValueError:
138 return None
139
140
141def str_to_year(string):

Callers 2

extract_num_from_textMethod · 0.85
_extract_num_spanFunction · 0.85

Calls 1

cn_to_anFunction · 0.85

Tested by

no test coverage detected