diff --git a/convert_to_bibtex.py b/python/bib_json_to_bibtex.py similarity index 78% rename from convert_to_bibtex.py rename to python/bib_json_to_bibtex.py index 9e8b360..da8435d 100644 --- a/convert_to_bibtex.py +++ b/python/bib_json_to_bibtex.py @@ -7,7 +7,7 @@ author={AUTHORS}, booktitle={{CONFERENCE}}, year={YEAR}, - note={NOTES}, + note={\\textbf{NOTES}}, }""" _journal_template=""" @@ -16,7 +16,7 @@ author={AUTHORS}, journal={{CONFERENCE}}, year={YEAR}, - note={NOTES}, + note={\\textbf{NOTES}}, }""" _techreport_template=""" @@ -25,17 +25,24 @@ author={AUTHORS}, institution={{INSTITUTION}}, year={YEAR}, - note={NOTES}, + note={\\textbf{NOTES}}, }""" _arxiv_template=""" @misc{KEY, - title={{TITLE}}, + title={\\normalfont{``TITLE''}}, author={AUTHORS}, - institution={{INSTITUTION}}, year={YEAR}, url={URL}, - note={(arXiv preprint)}, +}""" + +_patent_template=""" +@patent{KEY, + title={TITLE}, + author={AUTHORS}, + number={NUMBER}, + year={YEAR}, + note={NOTES}, }""" _workshop_template=""" @@ -44,7 +51,7 @@ author={AUTHORS}, institution={{INSTITUTION}}, year={YEAR}, - note={NOTES}, + note={\\textbf{NOTES}}, }""" _course_template=""" @@ -53,7 +60,7 @@ author={AUTHORS}, howpublished={{HOWPUBLISHED}}, year={YEAR}, - note={NOTES}, + note={\\textbf{NOTES}}, }""" def list_to_string(mylist): @@ -103,10 +110,20 @@ def arxiv(pub): if 'arxiv' in pub: ret = ret.replace("URL", pub['arxiv']) else: - ret = ret.replace("URL", "https://arxiv.org") + ret = ret.replace("URL", "") ret = ret.replace("NOTES", notes_to_string(pub['notes']) if "notes" in pub else "") return ret +def patent(pub): + ret = _patent_template + ret = ret.replace("KEY", pub['key']) + ret = ret.replace("TITLE", pub['title']) + ret = ret.replace("AUTHORS", list_to_string(pub['authors'])) + ret = ret.replace("YEAR", pub['year']) + ret = ret.replace("NUMBER", pub['number']) + ret = ret.replace("NOTES", f"Filed: {pub['filed']}") + return ret + def course(pub): ret = _course_template ret = ret.replace("KEY", pub['key']) @@ -123,10 +140,13 @@ def dispatcher(pub): if pub['type'] == 'techreport': return techreport(pub) if pub['type'] == 'course': return course(pub) if pub['type'] == 'arxiv': return arxiv(pub) + if pub['type'] == 'patent': return patent(pub) raise ValueError(pub['type']) -with open('pubs.json', 'r') as fp: +with open('../pubs.json', 'r') as fp: data = json.load(fp) for pub in data: # if pub['key'] != "chen2020bspnet": continue #TODO - print(dispatcher(pub)) + text = dispatcher(pub) + text = text.replace("Andrea Tagliasacchi", "\\textcolor{BrickRed}{Andrea Tagliasacchi}") + print(text) diff --git a/python/patents_ccvxml_to_json.py b/python/patents_ccvxml_to_json.py new file mode 100644 index 0000000..59e161a --- /dev/null +++ b/python/patents_ccvxml_to_json.py @@ -0,0 +1,51 @@ +import xml.etree.ElementTree as ET +import json + +# Read XML content from a file +file_path = 'ccv_patents.xml' + +# Parse the XML content +tree = ET.parse(file_path) +root = tree.getroot() + +# Create a list to hold the converted data +data = [] + +# Iterate through each 'section' in the XML +for section in root.findall('section'): + section_data = {} + + # Get values from the fields within each section + for field in section.findall('field'): + label = field.get('label') + value = field.find('value') + lov = field.find('lov') + if value is not None and value.text: + section_data[label.lower().replace(' ', '_')] = value.text.strip() + elif lov is not None and lov.text: + section_data[label.lower().replace(' ', '_')] = lov.text.strip() + + # Extract inventors list and get the first inventor + inventors_list = section_data.get("inventors", "").split(';') + first_inventor = inventors_list[0].strip() if inventors_list else "" + + # Create the desired JSON structure + formatted_data = { + "type": "patent", + "key": f"{first_inventor.lower().replace(' ', '')}{section_data.get('filing_date', '').split('-')[0]}patent", + "title": section_data.get("patent_title", ""), + "status": section_data.get("patent_status", "").lower(), + "filed": section_data.get("filing_date", ""), + "authors": [author.strip() for author in inventors_list], + "patent_number": section_data.get("patent_number", "") + } + + # Append formatted data to the list + data.append(formatted_data) + +# Convert the list of dictionaries to JSON +json_data = json.dumps(data, indent=2) + +# Write JSON data to a file +with open('converted_data.json', 'w') as json_file: + json_file.write(json_data) \ No newline at end of file diff --git a/python/talks_ccvxml_to_json.py b/python/talks_ccvxml_to_json.py new file mode 100644 index 0000000..d07ea14 --- /dev/null +++ b/python/talks_ccvxml_to_json.py @@ -0,0 +1,48 @@ +import xml.etree.ElementTree as ET +import json + +# Read XML content from a file +file_path = 'ccv_talks.xml' + +# Parse the XML content +tree = ET.parse(file_path) +root = tree.getroot() + +# Create a list to hold the converted data +data = [] + +# Iterate through each 'section' in the XML +for section in root.findall('section'): + section_data = {} + + # Get values from the fields within each section + for field in section.findall('field'): + label = field.get('label') + value = field.find('value') + lov = field.find('lov') + if value is not None and value.text: + section_data[label.lower()] = value.text + elif lov is not None and lov.text == 'Yes': + section_data[label.lower()] = 'Yes' + + # if "keynote?" in section_data: + # print(section_data.get("keynote?", "").lower()) + + # Create the desired JSON structure + formatted_data = { + "title": section_data.get("presentation title", ""), + "event": section_data.get("conference / event name", ""), + "location": f"{section_data.get('city', '')} ({section_data.get('location', '')})", + "year": section_data.get("presentation year", ""), + "keynote": section_data.get("keynote?", "").lower() if "keynote?" in section_data else "no" + } + + # Append formatted data to the list + data.append(formatted_data) + +# Convert the list of dictionaries to JSON +json_data = json.dumps(data, indent=2) + +# Write JSON data to a file +with open('ccv_talks.json', 'w') as json_file: + json_file.write(json_data) diff --git a/python/talks_json_to_latex.py b/python/talks_json_to_latex.py new file mode 100644 index 0000000..1ed7216 --- /dev/null +++ b/python/talks_json_to_latex.py @@ -0,0 +1,17 @@ +import json + +# Read JSON content from a file +file_path = 'ccv_talks.json' + +# Read JSON data from file +with open(file_path, 'r') as json_file: + data = json.load(json_file) + +# Iterate through each entry in the JSON data +for entry in data: + template = """\\item \\ressubheading{event}{location}{title}{year}""" + template = template.replace("event", entry['event']) + template = template.replace("location", entry['location']) + template = template.replace("title", entry['title']) + template = template.replace("year", entry['year']) + print(template) \ No newline at end of file