filtering the issues
Browse files
app.py
CHANGED
|
@@ -5,7 +5,7 @@ import gradio as gr
|
|
| 5 |
import tempfile
|
| 6 |
|
| 7 |
# Set JAVA_HOME environment variable
|
| 8 |
-
os.environ['JAVA_HOME'] = '/usr/lib/jvm/java-11-openjdk-amd64'
|
| 9 |
|
| 10 |
def grade_pdf(input_pdf, pdffigures2_jar):
|
| 11 |
"""
|
|
@@ -52,12 +52,31 @@ def grade_pdf(input_pdf, pdffigures2_jar):
|
|
| 52 |
with open(output_json_file, "r") as f:
|
| 53 |
regions = json.load(f)
|
| 54 |
|
|
|
|
|
|
|
| 55 |
for region in regions:
|
|
|
|
| 56 |
if(region["captionBoundary"]["y1"]>region["regionBoundary"]["y1"]):
|
| 57 |
region["captionLocation"]="Below"
|
| 58 |
else:
|
| 59 |
region["captionLocation"]="Above"
|
| 60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
|
| 62 |
else:
|
| 63 |
raise Exception(f"JSON output file not found: {output_json_file}")
|
|
|
|
| 5 |
import tempfile
|
| 6 |
|
| 7 |
# Set JAVA_HOME environment variable
|
| 8 |
+
# os.environ['JAVA_HOME'] = '/usr/lib/jvm/java-11-openjdk-amd64'
|
| 9 |
|
| 10 |
def grade_pdf(input_pdf, pdffigures2_jar):
|
| 11 |
"""
|
|
|
|
| 52 |
with open(output_json_file, "r") as f:
|
| 53 |
regions = json.load(f)
|
| 54 |
|
| 55 |
+
issueList = list()
|
| 56 |
+
|
| 57 |
for region in regions:
|
| 58 |
+
issues = dict()
|
| 59 |
if(region["captionBoundary"]["y1"]>region["regionBoundary"]["y1"]):
|
| 60 |
region["captionLocation"]="Below"
|
| 61 |
else:
|
| 62 |
region["captionLocation"]="Above"
|
| 63 |
+
|
| 64 |
+
if(region["captionLocation"]=="Below" and region["figType"] == "Table"):
|
| 65 |
+
issues["page_number"]=region["page"]
|
| 66 |
+
issues["caption_coordinate"]=region["captionBoundary"]
|
| 67 |
+
issues["fig_type"] = region["figType"]
|
| 68 |
+
issues["caption_location"] = region["captionLocation"]
|
| 69 |
+
issues["description"]="Location of the caption for tables must be above the table."
|
| 70 |
+
issueList.append(issues)
|
| 71 |
+
|
| 72 |
+
if(region["captionLocation"]=="Above" and region["figType"] == "Figure"):
|
| 73 |
+
issues["page_number"]=region["page"]
|
| 74 |
+
issues["caption_coordinate"]=region["captionBoundary"]
|
| 75 |
+
issues["fig_type"] = region["figType"]
|
| 76 |
+
issues["description"]="Location of the caption for figures must be below the table."
|
| 77 |
+
issueList.append(issues)
|
| 78 |
+
|
| 79 |
+
return issueList
|
| 80 |
|
| 81 |
else:
|
| 82 |
raise Exception(f"JSON output file not found: {output_json_file}")
|