com3dian commited on
Commit
ce618d6
·
1 Parent(s): 21a35d9

fix filename

Browse files
Files changed (1) hide show
  1. app.py +8 -17
app.py CHANGED
@@ -2,7 +2,6 @@ import streamlit as st
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
 
@@ -23,29 +22,21 @@ if uploaded_file is not None:
23
  st.write(len(bytes_data), "bytes")
24
  saved_file_path = save_uploaded_file(uploaded_file)
25
 
26
- os.makedirs("./grobidoutputs", exist_ok=True)
27
  client = GrobidClient(config_path="./grobidconfig.json")
28
  client.process("processFulltextDocument",
29
  "./uploads/",
30
- output="./grobidoutputs/",
31
  n=20)
32
-
33
- directory = "$HOME/app"
34
-
35
- pattern = os.path.splitext(uploaded_file.name)[0] + ".grobid.tei.xml"
36
- matching_files = glob.glob(f"{directory}/**/{pattern}", recursive=True)
37
 
38
- if matching_files:
39
- st.write("Found matching file(s):")
40
- for file in matching_files:
41
- st.write(file)
42
- else:
43
- st.write("No matching file found.")
44
-
45
- output_file_path = matching_files[0]
46
 
47
  monkeyReader = reader.MonkeyReader('x2d')
48
- outline = monkeyReader.readOutline(output_file_path)
49
 
50
  for pre, fill, node in outline:
51
  st.write("%s%s" % (pre, node.name))
 
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
 
 
22
  st.write(len(bytes_data), "bytes")
23
  saved_file_path = save_uploaded_file(uploaded_file)
24
 
 
25
  client = GrobidClient(config_path="./grobidconfig.json")
26
  client.process("processFulltextDocument",
27
  "./uploads/",
 
28
  n=20)
29
+
30
+ folder_path = '/path/to/uploads'
31
+ files = os.listdir(folder_path)
 
 
32
 
33
+ for file in files:
34
+ if not file.endswith('.pdf'):
35
+ st.write(f"The other file in the 'uploads' folder is: {file}")
36
+ break
 
 
 
 
37
 
38
  monkeyReader = reader.MonkeyReader('x2d')
39
+ outline = monkeyReader.readOutline(file)
40
 
41
  for pre, fill, node in outline:
42
  st.write("%s%s" % (pre, node.name))