-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
30 lines (24 loc) · 935 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from documentcloud.addon import AddOn
from eyecite import get_citations
import csv
class LegalCitations(AddOn):
def main(self):
citations_found = []
if not self.documents:
self.set_message("Please select at least one document.")
return
for document in self.get_documents():
citation_list = get_citations(document.full_text)
tagged_citation_list = [
(document.title, document.id, citation)
for citation in citation_list
]
citations_found += tagged_citation_list
# output the citations as a CSV.
with open("citations_found.csv", "w+") as file_:
writer = csv.writer(file_)
writer.writerow(("title", "id", "citation"))
writer.writerows(citations_found)
self.upload_file(file_)
if __name__ == "__main__":
LegalCitations().main()