Skip to content

Commit

Permalink
[RP] add school_type (#153)
Browse files Browse the repository at this point in the history
* [RP] add school_type

* using walrus to make code more concise

Co-authored-by: Knut Hühne <[email protected]>

---------

Co-authored-by: Knut Hühne <[email protected]>
  • Loading branch information
cyroxx and k-nut authored Mar 5, 2025
1 parent bbcf299 commit 9d7acf2
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions jedeschule/spiders/rheinland_pfalz.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,29 @@
from jedeschule.items import School
from jedeschule.spiders.school_spider import SchoolSpider

school_types = {
'BEA': 'BEA', # I could not find the meaning of this abbreviation
'BBS': 'Berufsbildende Schule',
'FWS': 'Freie Waldorfschule',
'GHS': 'Grund- und Hauptschule (org. verbunden)',
'GRS+': 'Grund- und Realschule plus (org. verbunden)',
'GS': 'Grundschule',
'GY': 'Gymnasium',
'HS': 'Hauptschule',
'IGS': 'Integrierte Gesamtschule',
'Koll': 'Kolleg',
'Koll/AGY': 'Kolleg und Abendgymnasium (org.verbunden)',
'RS': 'Realschule',
'RS+': 'Realschule plus',
'RS+FOS': 'Realschule plus mit Fachoberschule',
'StudSem': 'Studienseminar'

# Förderschulen (special education schools) come in a variety of abbreviations
# The following are some examples from the dataset
# SFGLS, SFG, SFGM, SFE, SFL, SFLG, SFBLS, SFMG, SFLS
# so we will treat them a bit differently, see below in the normalize step
}


class RheinlandPfalzSpider(CrawlSpider, SchoolSpider):
name = "rheinland-pfalz"
Expand Down Expand Up @@ -43,6 +66,17 @@ def parse_school(self, response):
def normalize(self, item: Item) -> School:
zip, city = item.get("Anschrift")[-1].split(" ", 1)
email = item.get("E-Mail", "").replace("(at)", "@")

if kurzbezeichnung := item.get('Kurzbezeichnung'):
first_part = kurzbezeichnung.split(" ")[0]
# special handling for special education schools
if first_part.startswith('SF'):
school_type = 'Förderschule'
else:
school_type = school_types.get(first_part, None)
else:
school_type = None

return School(
name=item.get("name"),
id="RP-{}".format(item.get("id")),
Expand All @@ -56,4 +90,5 @@ def normalize(self, item: Item) -> School:
provider=item.get("Träger"),
fax=item.get("Telefax"),
phone=item.get("Telefon"),
school_type=school_type
)

0 comments on commit 9d7acf2

Please sign in to comment.