diff --git a/test/dataextractors/test_multiple.py b/test/dataextractors/test_multiple.py index 6a1ee9693afab003137bf3c929320f0eaa4e0d37..dcad3a17c13daf726bfd9f878b32e1b5966ccecc 100644 --- a/test/dataextractors/test_multiple.py +++ b/test/dataextractors/test_multiple.py @@ -8,7 +8,7 @@ from travelogues_extraction.getrecords.acnumber_extractor import extract_ac_from from travelogues_extraction.dataextractors.dataextractors.combinedsubfields import VerfasserGND, ReihentitelBandzählung, \ HaupttitelTitelzusatzVerantwortlichkeitsangabe, BandzählungTitelDesBandes, VerlagsOrtNormiertGND, DruckOrtNormiertGND, \ VerlegerNormiertGNDID, DruckerGNDID, WeitereVerfasserGNDID, HerausgeberGNDID, ÜbersetzerGNDID, BeiträgerGNDID, \ - WeitereBeteiligteGNDID, IllustratorenGNDID, WidmenderGNDID, WidmungsempfängerGNDID + WeitereBeteiligteGNDID, IllustratorenGNDID, WidmenderGNDID, WidmungsempfängerGNDID, WerkeInRelation from travelogues_extraction.dataextractors.dataextractors.index import IndexSetter @@ -46,6 +46,7 @@ async def test_multiple_classes(): illustratorenGNDID = IllustratorenGNDID(target_dataframe) widmenderGNDID = WidmenderGNDID(target_dataframe) widmungsempfängerGNDID = WidmungsempfängerGNDID(target_dataframe) + werkeInRelation = WerkeInRelation(target_dataframe) index = 0 stop = 7 @@ -87,6 +88,7 @@ async def test_multiple_classes(): await illustratorenGNDID.write(record) await widmenderGNDID.write(record) await widmungsempfängerGNDID.write(record) + await werkeInRelation.write(record) assert target_dataframe.shape[0] == index + 1 if record.ac_number == 'AC09682453': @@ -248,6 +250,13 @@ async def test_multiple_classes(): assert widmungsempfängerGNDID_list[0][0][0].isalpha() assert widmungsempfängerGNDID_list[0][1].startswith('http://d-nb.info/gnd/') + if record.ac_number in ('AC09836279', 'AC07705435'): + werkeInRelation_val: typing.Union[str, float] = target_dataframe.at[record.ac_number, werkeInRelation.column] + if record.ac_number == 'AC09836279': + assert werkeInRelation_val.__repr__() == 'nan' + else: + assert werkeInRelation_val[0].isalpha() + index += 1 if index == stop: diff --git a/travelogues_extraction/controller/main.py b/travelogues_extraction/controller/main.py index ead2657abfd68073d32c7dc915a40754cc354596..898193b9807962c2f2cdfbb19e9abac0cc79849c 100644 --- a/travelogues_extraction/controller/main.py +++ b/travelogues_extraction/controller/main.py @@ -37,7 +37,7 @@ class FromAlmaOutputToExcel: VerlegerNormiertGNDID, DruckerGNDID, Erscheinungsjahr, ErscheinungsjahrSortierform, Kollation, Illustrationen, Format, Anmerkungen, Sprache, OriginalSprache, BemerkungenZurSprache, Standardnummer, WeitereVerfasserGNDID, HerausgeberGNDID, ÜbersetzerGNDID, BeiträgerGNDID, WeitereBeteiligteGNDID, IllustratorenGNDID, WidmenderGNDID, - WidmungsempfängerGNDID, ArtDesInhalts, Inhalt + WidmungsempfängerGNDID, ArtDesInhalts, Inhalt, WerkeInRelation ] def __init__(self, alma_output: str, target_output: str, slice: slice): diff --git a/travelogues_extraction/dataextractors/dataextractors/combinedsubfields.py b/travelogues_extraction/dataextractors/dataextractors/combinedsubfields.py index bc6a3238c60a4510b2cdb8a43dfcc1ea8dd8737e..65924d4c051b63679d76d04ede71d7d97255dc77 100644 --- a/travelogues_extraction/dataextractors/dataextractors/combinedsubfields.py +++ b/travelogues_extraction/dataextractors/dataextractors/combinedsubfields.py @@ -186,4 +186,14 @@ class WidmungsempfängerGNDID(AbstractMultifield): 'and' 'marc:subfield[@code="4" and text()="dte"]' ']' - ), namespaces=namespaces) \ No newline at end of file + ), namespaces=namespaces) + + +class WerkeInRelation(AbstractMultifield): + column = 'Werke in Relation' + primary_xml_path = lxmletree.XPath('./marc:datafield[(@tag="700" and @ind1="1" and @ind2="2") or (@tag="787" and @ind1="0" and @ind2="8")]', namespaces=namespaces) + xpath_isgnd_tuples = ( + VerlagsOrtNormiertGND.xpath_isgnd_tuples[0], + AbstractMultifield.XpathIsGnd(xpath=lxmletree.XPath('./marc:subfield[@code="t"]', namespaces=namespaces), isgnd=False), + VerlagsOrtNormiertGND.xpath_isgnd_tuples[1], + ) \ No newline at end of file