Spaces:
Sleeping
Sleeping
Create ingest/citations.py
Browse files- ingest/citations.py +10 -15
ingest/citations.py
CHANGED
|
@@ -1,16 +1,11 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
-
|
| 6 |
-
styles = getSampleStyleSheet()
|
| 7 |
-
tmp = tempfile.NamedTemporaryFile(delete=False, suffix=".pdf")
|
| 8 |
-
doc = SimpleDocTemplate(tmp.name)
|
| 9 |
-
|
| 10 |
-
content = []
|
| 11 |
-
for r in results:
|
| 12 |
-
citation = f"{r['agency']}, {r['title']}, {r['url']}."
|
| 13 |
-
content.append(Paragraph(citation, styles["Normal"]))
|
| 14 |
-
|
| 15 |
-
doc.build(content)
|
| 16 |
-
return tmp.name
|
|
|
|
| 1 |
+
def bluebook_citation(result):
|
| 2 |
+
"""
|
| 3 |
+
Formats a public FOIA document reference.
|
| 4 |
+
This is citation formatting ONLY, not legal advice.
|
| 5 |
+
"""
|
| 6 |
+
title = result.get("title", "Untitled Document")
|
| 7 |
+
agency = result.get("agency", "U.S. Government")
|
| 8 |
+
date = result.get("date", "n.d.")
|
| 9 |
+
url = result.get("url", "")
|
| 10 |
|
| 11 |
+
return f"{title}, {agency} (released {date}), {url}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|