Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Issue(#1064) with same Items in parsed_result by Concatenating Each Parsed Result #1066

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions autorag/data/parse/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,16 @@ def run_parser(
module_params,
)
)
list(map(lambda x: x[0].to_parquet(x[1], index=False), zip(results, filepaths)))

_files = {}
for result, filepath in zip(results, filepaths):
_files[filepath].append(result) if filepath in _files.keys() else _files.update(
{filepath: [result]}
)
# Save files with a specific file type as Parquet files.
for filepath, value in _files.items():
pd.concat(value).to_parquet(filepath, index=False)

filenames = list(map(lambda x: os.path.basename(x), filepaths))

summary_df = pd.DataFrame(
Expand All @@ -121,8 +130,9 @@ def run_parser(
summary_df.to_csv(os.path.join(project_dir, "summary.csv"), index=False)

# concat all parquet files here if not all_files.
_filepaths = list(_files.keys())
if not all_files:
dataframes = [pd.read_parquet(file) for file in filepaths]
dataframes = [pd.read_parquet(file) for file in _filepaths]
combined_df = pd.concat(dataframes, ignore_index=True)
combined_df.to_parquet(
os.path.join(project_dir, "parsed_result.parquet"), index=False
Expand Down
Loading