Skip to content
Open
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.DS_Store

out/
__pycache__/
results/
2 changes: 0 additions & 2 deletions twix-ui/backend/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ def process_phrase():
phrases, cost = twix.extract_phrase(pdf_paths, result_folder)
print(cost)


# Define paths for the bounding box files
bb_path = os.path.join(result_folder, 'merged_phrases_bounding_box_page_number.json')
bb_txt_path = os.path.join(os.path.dirname(result_folder), 'merged_raw_phrases_bounding_box_page_number.txt')
Expand All @@ -67,7 +66,6 @@ def process_phrase():
# Create both txt and json versions in each location
txt_dest = os.path.join(dest_path, 'merged_raw_phrases_bounding_box_page_number.txt')
json_dest = os.path.join(dest_path, 'merged_raw_phrases_bounding_box_page_number.json')

if os.path.exists(source_path):
# Copy TXT file as-is
shutil.copy(source_path, txt_dest)
Expand Down
9 changes: 6 additions & 3 deletions twix-ui/src/services/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ async function predictFields(files) {
}

const data = await response.json();
// Create and trigger download of content as text file
const blob = new Blob([data.content], { type: 'text/plain' });
// Create and trigger download of fields as text file
const blob = new Blob([data.fields], { type: 'text/plain' });
const url = window.URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
Expand Down Expand Up @@ -595,11 +595,14 @@ export function stringifyOrderedJSON(obj) {
// Build object string with keys in original order
let result = '{';
result += allKeys.map(key => {
// Stringify the key
const keyStr = JSON.stringify(key);
// Get the value
const value = obj[key];
// Recursively stringify the value
const valueStr = stringifyOrderedJSON(value);
// Return the key-value pair
return `"${key}":${valueStr}`;
return `${keyStr}:${valueStr}`;
}).join(',');
result += '}';

Expand Down
Loading