Skip to content

Commit

Permalink
Merge pull request #159 from hellofinch/main
Browse files Browse the repository at this point in the history
修复腾讯翻译遇到空字符报错的问题。
  • Loading branch information
Byaidu authored Dec 2, 2024
2 parents f811571 + a903dc6 commit a603f1c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pdf2zh/translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,13 @@ def translate(self, text):
# 2. Result test
try:
result = result["Response"]["TargetText"]
return result
# return result
except KeyError:
result = ""
raise ValueError("No valid key in Tencent's response")
# 3. Result length check
if len(result) == 0:
raise ValueError("Empty translation result")
# raise ValueError("No valid key in Tencent's response")
# # 3. Result length check
# if len(result) == 0:
# raise ValueError("Empty translation result")
return result


Expand Down

0 comments on commit a603f1c

Please sign in to comment.