Add files via upload
This commit is contained in:
parent
e7bf8a417b
commit
65d8f4a31f
5 changed files with 59 additions and 0 deletions
9
bib/customizations.py
Normal file
9
bib/customizations.py
Normal file
|
@ -0,0 +1,9 @@
|
|||
import bibtexparser
|
||||
|
||||
|
||||
def customizations_tajd(record):
|
||||
record = bibtexparser.customization.type(record)
|
||||
record = bibtexparser.customization.author(record)
|
||||
record = bibtexparser.customization.journal(record)
|
||||
record = bibtexparser.customization.doi(record)
|
||||
return record
|
15
bib/load_bib_file.py
Normal file
15
bib/load_bib_file.py
Normal file
|
@ -0,0 +1,15 @@
|
|||
import bibtexparser
|
||||
|
||||
|
||||
def load_bib_file(filename_bib: str, customizations):
|
||||
# Load the bib file:
|
||||
with open(filename_bib, mode="r") as file:
|
||||
file_content: str = file.read()
|
||||
|
||||
parser = bibtexparser.bparser.BibTexParser()
|
||||
parser.customization = customizations
|
||||
parser.ignore_nonstandard_types = False
|
||||
|
||||
bib_database = bibtexparser.loads(file_content, parser=parser)
|
||||
|
||||
return bib_database
|
10
bib/shorten_authorname.py
Normal file
10
bib/shorten_authorname.py
Normal file
|
@ -0,0 +1,10 @@
|
|||
def shorten_authorname(input: str) -> str:
|
||||
temp = input.split(",")
|
||||
name: str = temp[0].lstrip().rstrip() + str(",")
|
||||
temp = temp[1].lstrip().rstrip().split(" ")
|
||||
for i in temp:
|
||||
if len(i) > 0:
|
||||
first_letter = i.upper()[0]
|
||||
if first_letter.isalpha() is True:
|
||||
name += str(" ") + first_letter + str(".")
|
||||
return name
|
15
bib/unique_author_list.py
Normal file
15
bib/unique_author_list.py
Normal file
|
@ -0,0 +1,15 @@
|
|||
from bib.shorten_authorname import shorten_authorname
|
||||
|
||||
|
||||
def unique_author_list(bib_database):
|
||||
temp_authors = []
|
||||
for idx in range(0, len(bib_database.entries)):
|
||||
if "author" in bib_database.entries[idx].keys():
|
||||
for temp_entry in bib_database.entries[idx]["author"]:
|
||||
temp_authors.append(shorten_authorname(temp_entry))
|
||||
else:
|
||||
print(f"Author is missing. Entry-ID:{idx}")
|
||||
|
||||
unique_autors = list(set(temp_authors))
|
||||
unique_autors.sort()
|
||||
return unique_autors
|
10
bib/unique_type_list.py
Normal file
10
bib/unique_type_list.py
Normal file
|
@ -0,0 +1,10 @@
|
|||
def unique_type_list(bib_database):
|
||||
temp_types = []
|
||||
for idx in range(0, len(bib_database.entries)):
|
||||
if "ENTRYTYPE" in bib_database.entries[idx].keys():
|
||||
entry = bib_database.entries[idx]
|
||||
entry_type: str = str(entry["ENTRYTYPE"]).lstrip().rstrip()
|
||||
temp_types.append(entry_type)
|
||||
unique_types = list(set(temp_types))
|
||||
unique_types.sort()
|
||||
return unique_types
|
Loading…
Reference in a new issue