Skip to content

Commit

Permalink
Enoriega/849 (#864)
Browse files Browse the repository at this point in the history
## Summary of Changes
Updated the TR endpoints to match the current signature of the function
calls

### Related issues

849
  • Loading branch information
enoriega authored Mar 27, 2024
1 parent 5af45a2 commit 066bee4
Showing 1 changed file with 7 additions and 23 deletions.
30 changes: 7 additions & 23 deletions skema/rest/integrated_text_reading_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,13 +416,13 @@ async def integrated_text_extractions(
### Python example
```
params = {
"annotate_skema":True,
"annotate_mit": True
}
"annotate_skema": True,
"annotate_mit": True
files = [("pdfs", ("paper.txt", open("paper.txt", "rb")))]
}
payload = {"texts": [file_text], "amrs": [amr_text]}
response = request.post(f"{URL}/text-reading/integrated-text-extractions", params=params, files=files)
response = requests.post(f"{URL}/text-reading/integrated-text-extractions", params=params, json=payload)
if response.status_code == 200:
data = response.json()
```
Expand Down Expand Up @@ -457,7 +457,7 @@ async def integrated_text_extractions(
text_extractions_file=extractions_ufile)
aligned_amrs.append(aligned_amr)
except Exception as e:
error = TextReadingError(pipeline="AMR Linker", message=f"Error annotating {amr.filename}: {e}")
error = TextReadingError(pipeline="AMR Linker", message=f"Error annotating amr: {e}")
if extractions.generalized_errors is None:
extractions.generalized_errors = [error]
else:
Expand Down Expand Up @@ -489,7 +489,7 @@ async def integrated_pdf_extractions(
"annotate_mit": True
}
files = [("pdfs", ("ijerp.pdf", open("ijerp.pdf", "rb")))]
files = [("pdfs", ("ijerp.pdf", open("ijerp.pdf", "rb"))), ("amrs", ("amr.json", open("amr.json", "rb")))]
response = request.post(f"{URL}/text-reading/integrated-pdf-extractions", params=params, files=files)
if response.status_code == 200:
Expand Down Expand Up @@ -716,22 +716,6 @@ def healthcheck() -> int:
return status_code


@router.get("/eval", response_model=TextReadingEvaluationResults, status_code=200, deprecated=True)
def quantitative_eval() -> TextReadingEvaluationResults:
""" Compares the SIDARTHE paper extractions against ground truth extractions. This path stays for compatibility
with the dashboard, but will be removed in the near future as the dashboard is updated to run dynamically the POST
path"""

# Read ground truth annotations
with (Path(__file__).parents[0] / "data" / "sidarthe_annotations.json").open() as f:
gt_data = json.load(f)

# Read the SKEMA extractions
extractions = AttributeCollection.from_json(Path(__file__).parents[0] / "data" / "extractions_sidarthe_skema.json")

return utils.compute_text_reading_evaluation(gt_data, extractions)


@router.post("/eval", response_model=TextReadingEvaluationResults, status_code=200)
def quantitative_eval(extractions_file: UploadFile,
gt_annotations: UploadFile, json_text: UploadFile) -> TextReadingEvaluationResults:
Expand Down

0 comments on commit 066bee4

Please sign in to comment.