Skip to content
Snippets Groups Projects
Commit 74e55ab3 authored by Liliana Sanfilippo's avatar Liliana Sanfilippo
Browse files

cit

parent f16b822c
No related branches found
No related tags found
No related merge requests found
......@@ -64,27 +64,29 @@ def main():
en_x = library.entries[x]
print("Filling dictionary for entry "+ str(startnum+count) + "")
# Direkt auf die Einträge zugreifen, da es sich um ein Dictionary handelt
for key, value in en_x.items():
key_low = key.lower()
dictio[key_low] = value
# Überprüfung auf den Typ des Eintrags über 'ENTRYTYPE'
print("Checking Entry type of "+ str(startnum+count) + "")
if en_x['ENTRYTYPE'] == "article":
articleHTML(dictio, (startnum+count), out)
elif en_x['ENTRYTYPE'] == "misc":
miscHTML(dictio, (startnum+count), out)
elif en_x['ENTRYTYPE'] == "book":
bookHTML(dictio, (startnum+count), out)
elif en_x['ENTRYTYPE'] == "inbook":
bookHTML(dictio, (startnum+count), out)
count += 1;
except Exception as e:
print(f"An unexpected error occurred: {e}")
print(f"An unexpected error occurred: {e} in line 83")
except Exception as e:
print(f"An unexpected error occurred: {e}")
print(f"An unexpected error occurred: {e} in line 85")
except FileNotFoundError:
print(f"Error: The file '{args.input}' was not found.")
print(f"Error: The file '{args.input}' was not found. line 87")
if len(problemlist)>0:
print("- - - - - - - - - - - - - - - - - ")
print("REMAINING ERRORS:")
......@@ -103,22 +105,26 @@ def articleHTML(dictio, x, out):
out.write("<li typeof=\"schema:ScolarlyArticle\" role=\"doc-biblioentry\" property=\"schema:citation\" id=\"desc-" + str(x) + "\">"+ "\n")
out.write("\t" + "<span property=\"schema:author\" typeof=\"schema:Person\">"+ "\n")
print("Just a sec, seperating authors...")
print("Just a sec, separating authors...")
authors = dictio['author']
authors = authors.replace(" and ", "|")
liste = authors.split("|")
for a in liste:
try:
#print("processing " + a)
first = None
last = None
name = None
if ',' in a:
s = a.split(", ")
first = s[1]
first_sh = first[0]
last = s[0]
name = last + ", " + first_sh + "."
if len(s) > 1:
first = s[1]
first_sh = first[0]
last = s[0]
name = last + ", " + first_sh + "."
else:
# Falls es nur einen Nachnamen gibt
last = s[0]
name = last + ", "
else:
s = a.split()
if len(s) == 2:
......@@ -130,17 +136,17 @@ def articleHTML(dictio, x, out):
leng = len(s)
last = s[leng-1]
first = ''
for n in s:
if n != s[-1]:
first = first + n[0] + '.'
name = last + ", " + first
for n in s[:-1]: # Alle bis auf den letzten Namen
first += n[0] + '.'
name = last + ", " + first
if a == liste[-1]:
out.write("\t" + "\t" +"<span property=\"schema:Name\"> " +name + "</span>"+ "\n")
out.write("\t" + "\t" + "<span property=\"schema:Name\"> " + name + "</span>" + "\n")
else:
out.write("\t" +"\t" +"<span property=\"schema:Name\"> " +name + "</span>;"+ "\n")
out.write("\t" + "\t" + "<span property=\"schema:Name\"> " + name + "</span>;" + "\n")
except Exception as e:
print(f"An unexpected error occurred: {e} see " + a)
out.write("\t" +"</span>"+ "\n")
out.write("\t" + "<span property=\"schema:name\">&nbsp;"+dictio['title']+ ". </span>"+ "\n")
out.write("\t" +"<i property=\"schema:publisher\" typeof=\"schema:Organization\"> "+ dictio['journal'] +"</i>"+ "\n")
......@@ -210,7 +216,14 @@ def bookHTML(dictio, x, out):
aut = dictio['author']
out.write("\t" + "\t" +"<span property=\"schema:Name\"> " + aut + "</span>."+ "\n")
out.write("\t" +"</span>"+ "\n")
out.write("\t" + "<span property=\"schema:name\">&nbsp;"+dictio['title']+ ".</span>"+ "\n")
if 'title' in dictio:
out.write("\t" + "<span property=\"schema:name\">&nbsp;"+dictio['title']+ ".</span>"+ "\n")
elif 'booktitle' in dictio:
out.write("\t" + "<span property=\"schema:name\">&nbsp;"+dictio['booktitle']+ ".</span>"+ "\n")
else:
print(f"No title or booktitle found for entry {x}")
problemlist.append(f"Check for missing title or booktitle at entry {x}")
out.write("\t" +"<i property=\"schema:publisher\" typeof=\"schema:Organization\">&nbsp;"+ dictio['publisher'] +"</i>"+ "\n")
year = dictio['year']
out.write("\t" + "&nbsp;(<time property=\"schema:datePublished\" datatype=\"xsd:gYear\" dateTime=\"" + year + "\">"+year+"</time>)."+ "\n")
......
This diff is collapsed.
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment