Commit b291668d authored by Neeme Kahusk's avatar Neeme Kahusk

asutus

parent 6c35424f
SIMPLE = ['ressursi nimed','doi']
NAMES = ['eestikeelne ressursi nimi','ingliskeelne ressursi nimi','doi']
NAMES = ['eestikeelne ressursi nimi','ingliskeelne ressursi nimi','kontaktisiku asutus','doi']
......@@ -17,6 +17,26 @@ from configure_columns import SIMPLE, NAMES
XPATHLIST = NAMES
class Name(object):
def __init__(self):
self.value = ''
self.language = ''
class Project(object):
def __init__(self):
self.names = []
self.shortNames = []
class Organization(object):
def __init__(self):
self.names = []
self.shortNames = []
self.departmentNames = []
self.communicationInfo = None
class CommunicationInfo(object):
def __init__(self):
self.email = ''
......@@ -31,10 +51,12 @@ class CommunicationInfo(object):
class Person(object):
def __init__(self):
self.surname = ''
self.givenName = ''
self.surname = []
self.givenName = []
self.sex = None
self.position = ''
self.communicationInfo = None
def make_filter(tabelifail: str = 'tulbad.csv') -> list:
"""Reads "columns file" (columns 'label', 'simplepath', 'xpath' etc. and returns
......@@ -50,6 +72,18 @@ def make_filter(tabelifail: str = 'tulbad.csv') -> list:
labels_et = [x for x in csvdata if x['label_et'] in XPATHLIST]
return labels_et
def text_or_subtexts(element: etree._Element):
out = []
if element.text:
a = element.text
if a.startswith('10.15155/'):
a = 'http://doi.org/' + a
return a
else:
for el in element.xpath('./descendant-or-self::*/text()'):
out.append(el)
return ', '.join(out)
def get_xpath(root: etree._ElementTree, xpath: str) -> str:
"""Returns text attribute(s) of XML Elements returned by xpath query.
......@@ -60,7 +94,8 @@ def get_xpath(root: etree._ElementTree, xpath: str) -> str:
"""
namespaces = {'x':'http://www.ilsp.gr/META-XMLSchema'}
elements = root.xpath(xpath, namespaces=namespaces)
texts = [x.text for x in elements]
texts = [text_or_subtexts(x) for x in elements]
#return texts
return ', '.join(texts)
......
......@@ -14,9 +14,11 @@ kasutuspiirangud distributionInfo/licenceInfo/restrictionsOfUse .//x:distributi
levitamise vahend distributionInfo/licenceInfo/distributionAccessMedium .//x:distributionInfo/x:licenceInfo/x:distributionAccessMedium accessibleThroughInterface 224 {http://www.ilsp.gr/META-XMLSchema}distributionInfo/{http://www.ilsp.gr/META-XMLSchema}licenceInfo/{http://www.ilsp.gr/META-XMLSchema}distributionAccessMedium[1]
distributionInfo/licenceInfo/distributionAccessMedium .//x:distributionInfo/x:licenceInfo/x:distributionAccessMedium downloadable 224 {http://www.ilsp.gr/META-XMLSchema}distributionInfo/{http://www.ilsp.gr/META-XMLSchema}licenceInfo/{http://www.ilsp.gr/META-XMLSchema}distributionAccessMedium[2]
allalaadimiskoht distributionInfo/licenceInfo/downloadLocation .//x:distributionInfo/x:licenceInfo/x:downloadLocation ftp://ftp.eki.ee/pub/keeletehnoloogia/inglise-eesti/ 224 {http://www.ilsp.gr/META-XMLSchema}distributionInfo/{http://www.ilsp.gr/META-XMLSchema}licenceInfo/{http://www.ilsp.gr/META-XMLSchema}downloadLocation
kontaktisik contactPerson .//x:contactPerson
kontaktisiku perekonnanimi contactPerson/surname lang=en ".//x:contactPerson/x:surname[@lang=""en""]" Hein 224 {http://www.ilsp.gr/META-XMLSchema}contactPerson/{http://www.ilsp.gr/META-XMLSchema}surname
kontaktisiku eesnimi contactPerson/givenName lang=en ".//x:contactPerson/x:givenName[@lang=""en""]" Indrek 224 {http://www.ilsp.gr/META-XMLSchema}contactPerson/{http://www.ilsp.gr/META-XMLSchema}givenName
kontaktisiku meiliaadress contactPerson/communicationInfo/email .//x:contactPerson/x:communicationInfo/x:email Indrek.Hein@eki.ee 224 {http://www.ilsp.gr/META-XMLSchema}contactPerson/{http://www.ilsp.gr/META-XMLSchema}communicationInfo/{http://www.ilsp.gr/META-XMLSchema}email
kontaktisiku asutus contactPerson/affiliation .//x:contactPerson/x:affiliation
Eestikeelne kontaktisiku koduasutuse nimi contactPerson/affiliation/organizationName lang=et ".//x:contactPerson/x:affiliation/x:organizationName[@lang=""et""]" Eesti Keele Instituut 224 {http://www.ilsp.gr/META-XMLSchema}contactPerson/{http://www.ilsp.gr/META-XMLSchema}affiliation/{http://www.ilsp.gr/META-XMLSchema}organizationName[1]
ingliskeelne kontaktisiku koduasutuse nimi contactPerson/affiliation/organizationName lang=en ".//x:contactPerson/x:affiliation/x:organizationName[@lang=""en""]" Institute of the Estonian Language 224 {http://www.ilsp.gr/META-XMLSchema}contactPerson/{http://www.ilsp.gr/META-XMLSchema}affiliation/{http://www.ilsp.gr/META-XMLSchema}organizationName[2]
kontaktisiku koduasutuse meiliaadress contactPerson/affiliation/communicationInfo/email .//x:contactPerson/x:affiliation/x:communicationInfo/x:email eki@eki.ee 224 {http://www.ilsp.gr/META-XMLSchema}contactPerson/{http://www.ilsp.gr/META-XMLSchema}affiliation/{http://www.ilsp.gr/META-XMLSchema}communicationInfo/{http://www.ilsp.gr/META-XMLSchema}email
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment