Spaces:
Sleeping
Sleeping
fix path
Browse files- app.py +15 -6
- requirements.txt +1 -0
app.py
CHANGED
@@ -2,12 +2,13 @@ import streamlit as st
|
|
2 |
import pandas as pd
|
3 |
import numpy as np
|
4 |
import os
|
|
|
5 |
from grobidmonkey import reader
|
6 |
from grobid_client.grobid_client import GrobidClient
|
7 |
|
8 |
def save_uploaded_file(uploaded_file):
|
9 |
-
file_path = os.path.join("uploads", uploaded_file.name)
|
10 |
-
os.makedirs("uploads", exist_ok=True) # Create 'uploads' directory if it doesn't exist
|
11 |
with open(file_path, "wb") as f:
|
12 |
f.write(uploaded_file.getbuffer())
|
13 |
return file_path # Return the file path as a string
|
@@ -25,12 +26,20 @@ if uploaded_file is not None:
|
|
25 |
os.makedirs("grobidoutputs", exist_ok=True)
|
26 |
client = GrobidClient(config_path="./grobidconfig.json")
|
27 |
client.process("processFulltextDocument",
|
28 |
-
"uploads/",
|
29 |
n=20)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
-
|
32 |
-
output_file_path = os.path.join("uploads/", uploaded_file.name + ".tei.xml")
|
33 |
-
|
34 |
|
35 |
monkeyReader = reader.MonkeyReader('x2d')
|
36 |
outline = monkeyReader.readOutline(output_file_path)
|
|
|
2 |
import pandas as pd
|
3 |
import numpy as np
|
4 |
import os
|
5 |
+
import glob
|
6 |
from grobidmonkey import reader
|
7 |
from grobid_client.grobid_client import GrobidClient
|
8 |
|
9 |
def save_uploaded_file(uploaded_file):
|
10 |
+
file_path = os.path.join("./uploads", uploaded_file.name)
|
11 |
+
os.makedirs("./uploads", exist_ok=True) # Create 'uploads' directory if it doesn't exist
|
12 |
with open(file_path, "wb") as f:
|
13 |
f.write(uploaded_file.getbuffer())
|
14 |
return file_path # Return the file path as a string
|
|
|
26 |
os.makedirs("grobidoutputs", exist_ok=True)
|
27 |
client = GrobidClient(config_path="./grobidconfig.json")
|
28 |
client.process("processFulltextDocument",
|
29 |
+
"./uploads/",
|
30 |
n=20)
|
31 |
+
directory = "."
|
32 |
+
pattern = uploaded_file.name + ".tei.xml"
|
33 |
+
matching_files = glob.glob(f"{directory}/**/{pattern}", recursive=True)
|
34 |
+
|
35 |
+
if matching_files:
|
36 |
+
st.write("Found matching file(s):")
|
37 |
+
for file in matching_files:
|
38 |
+
st.write(file)
|
39 |
+
else:
|
40 |
+
st.write("No matching file found.")
|
41 |
|
42 |
+
output_file_path = matching_files
|
|
|
|
|
43 |
|
44 |
monkeyReader = reader.MonkeyReader('x2d')
|
45 |
outline = monkeyReader.readOutline(output_file_path)
|
requirements.txt
CHANGED
@@ -2,3 +2,4 @@ streamlit
|
|
2 |
numpy
|
3 |
pandas
|
4 |
grobidmonkey
|
|
|
|
2 |
numpy
|
3 |
pandas
|
4 |
grobidmonkey
|
5 |
+
glob
|