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

Function get_char_list

NLP/Text2SQL-BASELINE/script/schema_linking.py:47–91  ·  view source on GitHub ↗

Args: sentence (TYPE): NULL Returns: tuple Raises: NULL

(sentence)

Source from the content-addressed store, hash-verified

45g_date_patt = re.compile(r'(([0-9]{2})[0-9]{2}年)?[0-9]{1,2}月[0-9]{2}日|([0-9]{2})[0-9]{2}年[0-9]{1,2}月')
46
47def get_char_list(sentence):
48 """
49
50 Args:
51 sentence (TYPE): NULL
52
53 Returns: tuple
54
55 Raises: NULL
56 """
57 def is_ascii(s):
58 """check if s is English album or number
59 Args:
60 s (str): NULL
61 Returns: bool
62 """
63 return ord(s) < 128
64 ##return s.isalnum() and ord(s) < 128
65
66 if len(sentence) == 0:
67 return []
68
69 lst_result = [sentence[0]]
70 last_is_ascii = lst_result[-1].isalnum()
71 for char in sentence[1:]:
72 if char == ' ':
73 last_is_ascii = False
74 continue
75 elif char == '-':
76 last_is_ascii = False
77 lst_result.append(char)
78 continue
79
80 if is_ascii(char) and last_is_ascii:
81 lst_result[-1] += char
82 continue
83
84 if is_ascii(char):
85 last_is_ascii = True
86 else:
87 last_is_ascii = False
88
89 lst_result.append(char)
90
91 return tuple(lst_result)
92
93
94def _format_date_cell(old_cell):

Callers 2

_buildFunction · 0.85
search_valuesFunction · 0.85

Calls 2

is_asciiFunction · 0.85
appendMethod · 0.45

Tested by

no test coverage detected