SUSYUSTC / MathTranslate

translate scientific papers in latex, especially arxiv papers
https://github.com/SUSYUSTC/MathTranslate
Apache License 2.0
1.04k stars 69 forks source link

RecursionError: maximum recursion depth exceeded while calling a Python object #80

Open rotcx opened 9 months ago

rotcx commented 9 months ago

case:https://arxiv.org/abs/1904.09237

image

74%|████████████████████████████▊ | 34/46 [00:00<00:00, 257412.16it/s] Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/mathtranslate/translate.py", line 256, in translate_full_latex latex_translated_paragraphs = list(tqdm.auto.tqdm(executor.map(self.worker, latex_original_paragraphs), total=len(latex_original_paragraphs))) File "/usr/local/lib/python3.7/site-packages/tqdm/std.py", line 1166, in iter for obj in iterable: File "/usr/local/Cellar/python@3.7/3.7.12/Frameworks/Python.framework/Versions/3.7/lib/python3.7/concurrent/futures/_base.py", line 598, in result_iterator yield fs.pop().result() File "/usr/local/Cellar/python@3.7/3.7.12/Frameworks/Python.framework/Versions/3.7/lib/python3.7/concurrent/futures/_base.py", line 428, in result return self.get_result() File "/usr/local/Cellar/python@3.7/3.7.12/Frameworks/Python.framework/Versions/3.7/lib/python3.7/concurrent/futures/_base.py", line 384, in get_result raise self._exception File "/usr/local/Cellar/python@3.7/3.7.12/Frameworks/Python.framework/Versions/3.7/lib/python3.7/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) File "/usr/local/lib/python3.7/site-packages/mathtranslate/translate.py", line 203, in worker raise e File "/usr/local/lib/python3.7/site-packages/mathtranslate/translate.py", line 193, in worker latex_translated_paragraph = self.translate_paragraph_latex(latex_original_paragraph) File "/usr/local/lib/python3.7/site-packages/mathtranslate/translate.py", line 172, in translate_paragraph_latex latex_translated_paragraph = self.translate_text_in_paragraph_latex_and_leading_brace(latex_original_paragraph) File "/usr/local/lib/python3.7/site-packages/mathtranslate/translate.py", line 167, in translate_text_in_paragraph_latex_and_leading_brace latex_translated_paragraph = self.translate_text_in_paragraph_latex(latex_original_paragraph) File "/usr/local/lib/python3.7/site-packages/mathtranslate/translate.py", line 144, in translate_text_in_paragraph_latex result += self._translate_text_in_paragraph_latex(split) + ' ' + sep + ' ' File "/usr/local/lib/python3.7/site-packages/mathtranslate/translate.py", line 119, in _translate_text_in_paragraph_latex text_original_paragraph = process_text.split_too_long_paragraphs(text_original_paragraph) File "/usr/local/lib/python3.7/site-packages/mathtranslate/process_text.py", line 47, in split_too_long_paragraphs par2 = split_too_long_paragraphs('.'.join(lines[position:])) File "/usr/local/lib/python3.7/site-packages/mathtranslate/process_text.py", line 47, in split_too_long_paragraphs par2 = split_too_long_paragraphs('.'.join(lines[position:])) File "/usr/local/lib/python3.7/site-packages/mathtranslate/process_text.py", line 47, in split_too_long_paragraphs par2 = split_too_long_paragraphs('.'.join(lines[position:])) [Previous line repeated 982 more times] File "/usr/local/lib/python3.7/site-packages/mathtranslate/process_text.py", line 42, in split_too_long_paragraphs first_words = [get_first_word(line) for line in lines] File "/usr/local/lib/python3.7/site-packages/mathtranslate/process_text.py", line 42, in first_words = [get_first_word(line) for line in lines] File "/usr/local/lib/python3.7/site-packages/mathtranslate/process_text.py", line 26, in get_first_word words = line.split(' ') RecursionError: maximum recursion depth exceeded while calling a Python object

rotcx commented 8 months ago

case: https://arxiv.org/abs/2302.03169v3

image

rotcx commented 8 months ago

case: https://arxiv.org/abs/2302.03169v3

image

caused by unsual tex command: lstlisting image

temp solution: regexp it and del it

lstlisting_pattern = r"(\\begin\{lstlisting\}.*?\\end\{lstlisting\})"