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

cit

parent 7cf3f06b
No related branches found
No related tags found
No related merge requests found
Pipeline #445556 failed
...@@ -100,11 +100,15 @@ def main(): ...@@ -100,11 +100,15 @@ def main():
def makeauthors(authors, out): def makeauthors(authors, out):
authors = authors.replace(" and ", "|") authors = authors.replace(" and ", "|")
autlist = authors.split("|") autlist = authors.split("|")
# Maximale Anzahl der anzuzeigenden Autoren
max_authors = 6
for i, a in enumerate(autlist): for i, a in enumerate(autlist):
try: try:
first = None first = None
last = None last = None
name = None name = None
if ',' in a: if ',' in a:
s = a.split(", ") s = a.split(", ")
if len(s) > 1: if len(s) > 1:
...@@ -122,22 +126,24 @@ def makeauthors(authors, out): ...@@ -122,22 +126,24 @@ def makeauthors(authors, out):
first = s[0] first = s[0]
first_sh = first[0] first_sh = first[0]
last = s[1] last = s[1]
name = last + ", " + first_sh + "." name = last + ", " + first_sh + "."
else: else:
# Falls es mehrere Vornamen gibt, sie in Initialen umwandeln # Falls es mehrere Vornamen gibt, sie in Initialen umwandeln
leng = len(s) leng = len(s)
last = s[leng-1] last = s[leng-1]
first = '. '.join([n[0] for n in s[:-1]]) + '.' # Nur Initialen der Vornamen first = '. '.join([n[0] for n in s[:-1]]) + '.' # Nur Initialen der Vornamen
name = last + ", " + first name = last + ", " + first
# Wenn es der letzte Autor ist, kein Semikolon am Ende # Schreibe den Namen in die Ausgabedatei
if i == len(autlist) - 1: if i < max_authors:
out.write("\t" + "\t" + "<span property=\"schema:Name\"> " + name + "</span>" + "\n") out.write("\t" + "\t" + "<span property=\"schema:Name\"> " + name + "</span>" + "\n")
else: # Wenn wir mehr als 6 Autoren haben, schreibe "et al." nach dem 6. Autor
out.write("\t" + "\t" + "<span property=\"schema:Name\"> " + name + "</span>,"+ "\n") if i == max_authors:
out.write("\t" + "\t" + "<span property=\"schema:Name\"> et al.</span>" + "\n")
break # Stoppe die Schleife, nachdem "et al." hinzugefügt wurde
except Exception as e: except Exception as e:
print(f"An unexpected error occurred: {e} see " + a) print(f"An unexpected error occurred: {e} see " + a)
def articleHTML(dictio, x, out): def articleHTML(dictio, x, out):
...@@ -164,10 +170,10 @@ def articleHTML(dictio, x, out): ...@@ -164,10 +170,10 @@ def articleHTML(dictio, x, out):
pag = re.split('--|-|–', pages) pag = re.split('--|-|–', pages)
begin = pag[0].strip() begin = pag[0].strip()
end = pag[1].strip() end = pag[1].strip()
out.write("\t" + "<span property=\"schema:pageBegin\"> "+ begin +"</span>-<span property=\"schema:pageEnd\">"+ end + "</span>"+ "\n") out.write("\t" + "<span property=\"schema:pageBegin\"> "+ begin +"</span>-<span property=\"schema:pageEnd\">"+ end + "</span>&nbsp;"+ "\n")
else: else:
if re.match(r'^\d+(-\d+)?$', pages): # Check for typical numeric page ranges if re.match(r'^\d+(-\d+)?$', pages): # Check for typical numeric page ranges
out.write("\t" + "<span property=\"schema:pageBegin\">"+ pages +"</span>"+ "\n") out.write("\t" + "<span property=\"schema:pageBegin\">"+ pages +"</span>&nbsp;"+ "\n")
else: else:
# Seitenangabe ist nicht numerisch, als fehlend behandeln # Seitenangabe ist nicht numerisch, als fehlend behandeln
print(f"Non-numeric page information detected ('{pages}'). Treating as missing.") print(f"Non-numeric page information detected ('{pages}'). Treating as missing.")
...@@ -181,7 +187,7 @@ def articleHTML(dictio, x, out): ...@@ -181,7 +187,7 @@ def articleHTML(dictio, x, out):
year = dictio['year'] year = dictio['year']
out.write("\t" +"&nbsp;(<time property=\"schema:datePublished\" datatype=\"xsd:gYear\" dateTime=\" " + year + "\">"+year+"</time>)."+ "\n") out.write("\t" +"(<time property=\"schema:datePublished\" datatype=\"xsd:gYear\" dateTime=\" " + year + "\">"+year+"</time>)."+ "\n")
try: try:
doi = dictio['doi'] doi = dictio['doi']
......
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