Update README.md
Browse files
README.md
CHANGED
@@ -16,17 +16,17 @@ from datasets import load_dataset, Features, Value
|
|
16 |
|
17 |
|
18 |
def clean_up(sentence):
|
19 |
-
# Find the
|
20 |
matches = [match.start() for match in re.finditer(r'<<', sentence)]
|
21 |
|
22 |
for match in matches:
|
23 |
-
# Get the left
|
24 |
left_chars = sentence[match-20:match]
|
|
|
25 |
modified_chars = sentence[match-20:match].replace('x', '*').replace('X', '*')
|
26 |
|
27 |
-
#
|
28 |
if 'x' in left_chars or 'X' in left_chars:
|
29 |
-
# Replace "x" or "X" with "*"
|
30 |
sentence = sentence.replace(left_chars, modified_chars)
|
31 |
|
32 |
##############################################################################################################
|
@@ -54,7 +54,7 @@ def clean_up(sentence):
|
|
54 |
# Find all occurrences of "/"
|
55 |
asterisks = [i for i, char in enumerate(sentence) if char == '/']
|
56 |
|
57 |
-
# Check and add spaces around "
|
58 |
for index in reversed(asterisks):
|
59 |
if index > 0 and index < len(sentence) - 1 and sentence[index - 1] != ' ' and sentence[index + 1] != ' ':
|
60 |
sentence = sentence[:index] + ' ' + sentence[index] + ' ' + sentence[index + 1:]
|
@@ -67,7 +67,7 @@ def clean_up(sentence):
|
|
67 |
# Find all occurrences of "+"
|
68 |
asterisks = [i for i, char in enumerate(sentence) if char == '+']
|
69 |
|
70 |
-
# Check and add spaces around "
|
71 |
for index in reversed(asterisks):
|
72 |
if index > 0 and index < len(sentence) - 1 and sentence[index - 1] != ' ' and sentence[index + 1] != ' ':
|
73 |
sentence = sentence[:index] + ' ' + sentence[index] + ' ' + sentence[index + 1:]
|
@@ -110,7 +110,6 @@ train_set = load_dataset('json', data_files='train.jsonl', split='train', featur
|
|
110 |
|
111 |
data = []
|
112 |
for example in train_set:
|
113 |
-
# Get the label answer --> gsm8k_answers
|
114 |
number = example['answer'].split('#### ')[1]
|
115 |
number = int(number.replace(',', ''))
|
116 |
append = "\nThe answer is: " + str(number)
|
|
|
16 |
|
17 |
|
18 |
def clean_up(sentence):
|
19 |
+
# Find all the locations of "<<"
|
20 |
matches = [match.start() for match in re.finditer(r'<<', sentence)]
|
21 |
|
22 |
for match in matches:
|
23 |
+
# Get the left 20 characters of each "<<"
|
24 |
left_chars = sentence[match-20:match]
|
25 |
+
# Replace "x" or "X" to "*" if they are in the left 20 characters
|
26 |
modified_chars = sentence[match-20:match].replace('x', '*').replace('X', '*')
|
27 |
|
28 |
+
# Modify the original sentence
|
29 |
if 'x' in left_chars or 'X' in left_chars:
|
|
|
30 |
sentence = sentence.replace(left_chars, modified_chars)
|
31 |
|
32 |
##############################################################################################################
|
|
|
54 |
# Find all occurrences of "/"
|
55 |
asterisks = [i for i, char in enumerate(sentence) if char == '/']
|
56 |
|
57 |
+
# Check and add spaces around "/"
|
58 |
for index in reversed(asterisks):
|
59 |
if index > 0 and index < len(sentence) - 1 and sentence[index - 1] != ' ' and sentence[index + 1] != ' ':
|
60 |
sentence = sentence[:index] + ' ' + sentence[index] + ' ' + sentence[index + 1:]
|
|
|
67 |
# Find all occurrences of "+"
|
68 |
asterisks = [i for i, char in enumerate(sentence) if char == '+']
|
69 |
|
70 |
+
# Check and add spaces around "+"
|
71 |
for index in reversed(asterisks):
|
72 |
if index > 0 and index < len(sentence) - 1 and sentence[index - 1] != ' ' and sentence[index + 1] != ' ':
|
73 |
sentence = sentence[:index] + ' ' + sentence[index] + ' ' + sentence[index + 1:]
|
|
|
110 |
|
111 |
data = []
|
112 |
for example in train_set:
|
|
|
113 |
number = example['answer'].split('#### ')[1]
|
114 |
number = int(number.replace(',', ''))
|
115 |
append = "\nThe answer is: " + str(number)
|