generated from OpenPecha/python-project-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
15,882 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from pathlib import Path | ||
|
||
text = Path("four_truths.txt").read_text(encoding="utf-8") | ||
|
||
data = [] | ||
|
||
for line in text.splitlines(): | ||
data.append(line) | ||
|
||
data = [line for line in data if line] | ||
|
||
json_data = [] | ||
char_count = 0 | ||
for idx, line in enumerate(data): | ||
curr_json_data = {} | ||
span = {"start": char_count, "end": len(line) + char_count} | ||
char_count += len(line) | ||
curr_json_data = { | ||
"span": span, | ||
"content": line, | ||
"pecha": "four_truth", | ||
"line_count": idx, | ||
} | ||
json_data.append(curr_json_data) | ||
|
||
|
||
from bo_rag_prep_tool.utils import write_json | ||
|
||
write_json("four_truth.json", json_data) |
Oops, something went wrong.