|
|
@@ -174,6 +174,7 @@ def parse_args(args: Optional[List[str]]) -> argparse.Namespace:
|
|
|
|
|
|
return parsed_args
|
|
|
|
|
|
+
|
|
|
def find_all_files_in_directory(directory_path):
|
|
|
"""
|
|
|
Recursively search all PDF files in the given directory and return their paths as a list.
|
|
|
@@ -191,12 +192,13 @@ def find_all_files_in_directory(directory_path):
|
|
|
for root, _, files in os.walk(directory_path):
|
|
|
for file in files:
|
|
|
# Check if the file is a PDF
|
|
|
- if file.lower().endswith('.pdf'):
|
|
|
+ if file.lower().endswith(".pdf"):
|
|
|
# Append the full file path to the list
|
|
|
file_paths.append(os.path.join(root, file))
|
|
|
|
|
|
return file_paths
|
|
|
|
|
|
+
|
|
|
def main(args: Optional[List[str]] = None) -> int:
|
|
|
logging.basicConfig()
|
|
|
|
|
|
@@ -235,7 +237,7 @@ def main(args: Optional[List[str]] = None) -> int:
|
|
|
parsed_args.prompt = Template(content)
|
|
|
except Exception:
|
|
|
raise ValueError("prompt error.")
|
|
|
-
|
|
|
+
|
|
|
model = None
|
|
|
if parsed_args.onnx:
|
|
|
model = OnnxModel(parsed_args.onnx)
|
|
|
@@ -243,10 +245,10 @@ def main(args: Optional[List[str]] = None) -> int:
|
|
|
model = OnnxModel.load_available()
|
|
|
|
|
|
if parsed_args.dir:
|
|
|
- untranlate_file=find_all_files_in_directory(parsed_args.files[0])
|
|
|
+ untranlate_file = find_all_files_in_directory(parsed_args.files[0])
|
|
|
parsed_args.files = untranlate_file
|
|
|
print(parsed_args)
|
|
|
- translate(model=model,**vars(parsed_args))
|
|
|
+ translate(model=model, **vars(parsed_args))
|
|
|
return 0
|
|
|
# print(parsed_args)
|
|
|
translate(model=model, **vars(parsed_args))
|