Skip to content

Commit

Permalink
refine text decode (#657)
Browse files Browse the repository at this point in the history
### What problem does this PR solve?
#651 

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
  • Loading branch information
KevinHuSh committed May 7, 2024
1 parent de839fc commit 7013d7f
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion deepdoc/parser/excel_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def row_number(fnm, binary):

if fnm.split(".")[-1].lower() in ["csv", "txt"]:
encoding = find_codec(binary)
txt = binary.decode(encoding)
txt = binary.decode(encoding, errors="ignore")
return len(txt.split("\n"))


Expand Down
2 changes: 1 addition & 1 deletion rag/app/book.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def chunk(filename, binary=None, from_page=0, to_page=100000,
txt = ""
if binary:
encoding = find_codec(binary)
txt = binary.decode(encoding)
txt = binary.decode(encoding, errors="ignore")
else:
with open(filename, "r") as f:
while True:
Expand Down
2 changes: 1 addition & 1 deletion rag/app/laws.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def chunk(filename, binary=None, from_page=0, to_page=100000,
txt = ""
if binary:
encoding = find_codec(binary)
txt = binary.decode(encoding)
txt = binary.decode(encoding, errors="ignore")
else:
with open(filename, "r") as f:
while True:
Expand Down
2 changes: 1 addition & 1 deletion rag/app/naive.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def chunk(filename, binary=None, from_page=0, to_page=100000,
txt = ""
if binary:
encoding = find_codec(binary)
txt = binary.decode(encoding)
txt = binary.decode(encoding, errors="ignore")
else:
with open(filename, "r") as f:
while True:
Expand Down
2 changes: 1 addition & 1 deletion rag/app/one.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def chunk(filename, binary=None, from_page=0, to_page=100000,
txt = ""
if binary:
encoding = find_codec(binary)
txt = binary.decode(encoding)
txt = binary.decode(encoding, errors="ignore")
else:
with open(filename, "r") as f:
while True:
Expand Down
2 changes: 1 addition & 1 deletion rag/app/qa.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def chunk(filename, binary=None, lang="Chinese", callback=None, **kwargs):
txt = ""
if binary:
encoding = find_codec(binary)
txt = binary.decode(encoding)
txt = binary.decode(encoding, errors="ignore")
else:
with open(filename, "r") as f:
while True:
Expand Down
2 changes: 1 addition & 1 deletion rag/app/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def chunk(filename, binary=None, from_page=0, to_page=10000000000,
txt = ""
if binary:
encoding = find_codec(binary)
txt = binary.decode(encoding)
txt = binary.decode(encoding, errors="ignore")
else:
with open(filename, "r") as f:
while True:
Expand Down

0 comments on commit 7013d7f

Please sign in to comment.