Newer
Older
APC-bills / v1 / editorsFunctions / autres.py
@leogail leogail on 1 Aug 621 bytes fix(apc): fix jsons
from global_functions import *
import sys
import json


filename = sys.stdin.read().strip()
full_text = ocr_pdf(filename)


#Extract infos
unverified_doi = find_doi(full_text)
doi = ""
#only if a doi is found
if unverified_doi:
    if verify_doi(unverified_doi):
        #If DOI is found, write it in "doi" column instead of 'unverified_doi' column.
        doi=unverified_doi
        unverified_doi=""


new_row = {"nom_complet": filename.split("/")[1], "doi": doi, "unverified_doi":unverified_doi ,"item_editor":"","full_text": re.sub("\n\n+","\n",re.sub("\s\s+"," ",full_text))}
sys.stdout.write((json.dumps(new_row)))