"""Offline regression checks against separately reviewed grammar solutions.""" from build import lines,KEYS,DEST,OPEN import json,collections EXPECTED={ 'introductions':['am','are','is','is','is','My','from','is','are','are','am','are','His','Her','What','Where','am','is','your','Who','am','is','are','is'], 'family':['have','has','has','She','He','have','brothers','My','have','Has','Have','has not','They','Her','His','has','has','have not','children','are','has','He','have','Has'], 'numbers_time':['is','at','on','in','days','is','time','day','past','half','to','on','in','first','second','minutes','How','When','after','are','at','on','in','third'], 'daily_life':['eat','plays','goes','read','play','do','Do','Does','does','play','does','always','at','on','studies','washes','do','does not','When','finishes','clean','do','cooks','Does'], 'food_shopping':['an','a','apples','some','is','are','would','any','any','many','much','of','Can','tomatoes','This','These','do','costs','or','some','an','many','of','are'], 'home_city':['is','are','in','on','under','next to','Where','left','right','straight','is','Is','Are','opposite','between','behind','in front of','rooms','our','is','are','Where','next to','are']} for module in KEYS[:6]: for index,row in enumerate(lines(module,'grammar')): assert row[1].count('___')==1,(module,index,'blank') assert row[2]==EXPECTED[module][index],(module,index,'reviewed grammar key') assert len(set(x.casefold() for x in row[2:5]))==3,(module,index,'options') for index,row in enumerate(lines(module,'vocabulary')): word,answer,b,c,example,goal=row assert word.casefold() in example.casefold(),(module,index,'missing word context') assert len(set(x.casefold() for x in [answer,b,c]))==3,(module,index,'translations') for index,row in enumerate(lines(module,'stories')): assert len(row)==11,(module,index,'story format') assert row[1].endswith('?') and row[5].endswith('?'),(module,index,'questions') assert len(set(x.casefold() for x in row[2:5]))==3 and len(set(x.casefold() for x in row[6:9]))==3,(module,index,'story options') assert not any(w in row[0].lower() for w in ['look at the picture','see the photo','http','<']), (module,index,'external context') for module in KEYS[:6]: assert len(OPEN[module])==14,(module,'open instruction coverage') for instruction,criterion in OPEN[module]: assert instruction and criterion and 'Situation' not in instruction,(module,instruction) entries=[] for path in sorted(DEST.glob('*.json')): if path.name!='manifest.json':entries+=json.loads(path.read_text()) assert len(entries)==840 counts=collections.Counter((e['task']['module_id'],e['task']['skill']) for e in entries) assert len(counts)==42 and set(counts.values())=={20} for key in counts: bucket=[e for e in entries if (e['task']['module_id'],e['task']['skill'])==key] assert collections.Counter(e['difficulty'] for e in bucket)=={1:8,2:8,3:4} if key[1] in ['grammar','vocabulary','reading','listening']: assert sorted(collections.Counter(e['task']['answer_key']['correct_option_id'] for e in bucket).values())==[6,7,7] assert len({e['id'] for e in entries})==840 changed=[e for e in entries if e['task']['kind'] in ['free_speech','free_text']] assert len(changed)==140 and all(e['id'].startswith('a1bank_en_v2_') for e in changed) for e in changed: t=e['task'] assert 'Situation' not in t['prompt'] and 'eigene oder erfundene Angaben' in t['prompt'],e['id'] assert len(t['answer_key']['rubric'])>=4 and 'Werte aus der Beispielantwort sind nicht verbindlich.' in ' '.join(t['answer_key']['rubric']),e['id'] assert all(e['id'].startswith('a1bank_en_v1_') for e in entries if e not in changed) print('PASS: 144 reviewed grammar keys, 144 contextual vocabulary items, 144 factual scenes; 840 outputs, 42 balanced buckets, media completeness and balanced choice positions.')