Skip to content

Commit

Permalink
fix: underscore replace ignore case
Browse files Browse the repository at this point in the history
  • Loading branch information
sogladev committed Mar 4, 2024
1 parent d5fd9b5 commit 2226fe4
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions english/format.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@
" def _replace(e):\n",
" if word not in e:\n",
" return e \n",
" if not re.match(f\"^{word}.*?$\", e):\n",
" if not re.match(f\"^{word}.*?$\", e, re.IGNORECASE):\n",
" return e\n",
" return e.replace(word, '_')\n",
" example_split_replaced = list(map(lambda e: _replace(e), example_split))\n",
Expand All @@ -228,7 +228,7 @@
"html = style.to_html()\n",
"filename = DATASET + '_alphabetical'\n",
"with open(f'output/{filename}.html', 'w') as f:\n",
" f.write(html)\n",
" f.write('<meta charset=\"UTF-8\">'+html)\n",
"\n",
"cmd = f'pandoc -f html -t pdf output/{filename}.html -t html5 -o output/{filename}.pdf --metadata pagetitle=\"{filename}\" -V margin-top=2 -V margin-bottom=2 -V margin-left=2 -V margin-right=2 -c format/table.css --pdf-engine-opt=--enable-local-file-access'\n",
"os.system(cmd)"
Expand Down Expand Up @@ -281,7 +281,7 @@
"html = style.to_html()\n",
"filename = DATASET + '_underscore_alphabetical'\n",
"with open(f'output/{filename}.html', 'w') as f:\n",
" f.write(html)\n",
" f.write('<meta charset=\"UTF-8\">'+html)\n",
"\n",
"cmd = f'pandoc -f html -t pdf output/{filename}.html -t html5 -o output/{filename}.pdf --metadata pagetitle=\"{filename}\" -V margin-top=2 -V margin-bottom=2 -V margin-left=2 -V margin-right=2 -c format/table.css --pdf-engine-opt=--enable-local-file-access'\n",
"os.system(cmd)"
Expand Down Expand Up @@ -10492,7 +10492,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.4"
"version": "3.10.12"
},
"vscode": {
"interpreter": {
Expand Down
4 changes: 2 additions & 2 deletions english/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def replace_word_in_example_with_underscore(word, example):
def _replace(e):
if word not in e:
return e
if not re.match(f"^{word}.*?$", e):
if not re.match(f"^{word}.*?$", e, re.IGNORECASE):
return e
return e.replace(word, '_')
example_split_replaced = list(map(lambda e: _replace(e), example_split))
Expand Down Expand Up @@ -343,4 +343,4 @@ def fix_latex_line(line):
#
## Run terminal cd format latexmk oxford*.tex to finish build pdfs
#cmd_build = f"latexmk -pdf -cd format/{DATASET}*.tex -outdir=../output"
#os.system(cmd_build)
#os.system(cmd_build)
2 changes: 1 addition & 1 deletion spanish/format.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@
" def _replace(e):\n",
" if word not in e:\n",
" return e\n",
" if not re.match(f\"^{word}.*?$\", e):\n",
" if not re.match(f\"^{word}.*?$\", e, re.IGNORECASE):\n",
" return e\n",
" return e.replace(word, '_')\n",
" field_split_replaced = list(map(lambda e: _replace(e), field_split))\n",
Expand Down
2 changes: 1 addition & 1 deletion spanish/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def replace_word_in_field_with_underscore(word, field):
def _replace(e):
if word not in e:
return e
if not re.match(f"^{word}.*?$", e):
if not re.match(f"^{word}.*?$", e, re.IGNORECASE):
return e
return e.replace(word, '_')
field_split_replaced = list(map(lambda e: _replace(e), field_split))
Expand Down

0 comments on commit 2226fe4

Please sign in to comment.