Skip to content

Commit

Permalink
corpus definition improvements
Browse files Browse the repository at this point in the history
Co-Authored-By: Meesch <[email protected]>
  • Loading branch information
lukavdplas and Meesch committed Jan 15, 2025
1 parent 1589c25 commit de38452
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions backend/corpora/uu_course_descriptions/uu_course_descriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
1: 'Bachelor 1',
2: 'Bachelor 2',
3: 'Bachelor 3',
'1': 'Bachelor 1',
'2': 'Bachelor 2',
'3': 'Bachelor 3',
'M': 'Master',
'H1': 'Honours 1',
'H2': 'Honours 2',
Expand All @@ -48,7 +51,11 @@
'-': None,
}

def get_from(mapping: Mapping) -> Callable:
def get_from_mapping_or_return(mapping: Mapping) -> Callable:
'''
Returns a function that will look up a value in the provided mapping, and return the
input value if it is not included.
'''
return lambda value: mapping.get(value, value)

def filter_label(label):
Expand Down Expand Up @@ -193,7 +200,7 @@ def _extract_teacher_data(self):
FieldDefinition(
name='faculty',
display_name='Faculty',
extractor=CSV('FACULTEIT', transform=get_from(FACULTIES)),
extractor=CSV('FACULTEIT', transform=get_from_mapping_or_return(FACULTIES)),
es_mapping=keyword_mapping(),
search_filter=MultipleChoiceFilter(),
visualizations=['resultscount', 'termfrequency'],
Expand All @@ -202,15 +209,15 @@ def _extract_teacher_data(self):
name='exam_goal',
display_name='Exam goal',
description='',
extractor=CSV('EXAMENDOEL', transform=get_from(EXAM_GOALS)),
extractor=CSV('EXAMENDOEL', transform=get_from_mapping_or_return(EXAM_GOALS)),
es_mapping=keyword_mapping(),
search_filter=MultipleChoiceFilter(),
visualizations=['resultscount', 'termfrequency'],
),
FieldDefinition(
name='level',
display_name='Level',
extractor=CSV('CATEGORIE', transform=get_from(LEVELS)),
extractor=CSV('CATEGORIE', transform=get_from_mapping_or_return(LEVELS)),
es_mapping=keyword_mapping(),
search_filter=MultipleChoiceFilter(),
visualizations=['resultscount', 'termfrequency'],
Expand Down

0 comments on commit de38452

Please sign in to comment.