diff --git a/build/luecken.py b/build/luecken.py new file mode 100644 index 0000000..6e7e14c --- /dev/null +++ b/build/luecken.py @@ -0,0 +1,14 @@ +# -*- coding: utf-8 -*- +"""Zeigt Begriffsluecken eines Artikels gegen den lokalen Brief. Aufruf: python3 build/luecken.py SLUG""" +import json, re, sys +s = sys.argv[1] +a = json.load(open(f'artikel/artikel-{s}.json', encoding='utf-8')) +b = json.load(open(f'build/lokal/briefe/{s}.json', encoding='utf-8')) +t = ' '.join([a.get('kurzantwort',''), a['content_html'], a.get('faq_ueberschrift','')] + [f['frage']+' '+f['antwort'] for f in a['faq']]) +t = re.sub(r'<[^>]+>', ' ', t).lower() +print('Pflicht (ist/min-max):') +print(' ' + ', '.join(f"{x['begriff']} {t.count(x['begriff'].lower())}/{x['min']}-{x['max']}" for x in b['begriffe_pflicht'])) +fehl = [x for x in b['begriffe_erweitert'] if t.count(x['begriff'].lower()) < (x['min'] or 1)] +fehl.sort(key=lambda x: -(x['bei_wettbewerbern_pc'] or 0)) +print(f'Erweitert fehlend {len(fehl)}/{len(b["begriffe_erweitert"])}:') +print(' ' + ', '.join(f"{x['begriff']}({x['bei_wettbewerbern_pc']})" for x in fehl)) diff --git a/build/meta_luecken.py b/build/meta_luecken.py new file mode 100644 index 0000000..29b1025 --- /dev/null +++ b/build/meta_luecken.py @@ -0,0 +1,12 @@ +# -*- coding: utf-8 -*- +"""Titel-, Description- und H2-Begriffe gegen den Brief. Aufruf: python3 build/meta_luecken.py SLUG""" +import json, re, sys +s = sys.argv[1] +a = json.load(open(f'artikel/artikel-{s}.json', encoding='utf-8')) +z = json.load(open(f'build/lokal/briefe/{s}.json', encoding='utf-8'))['zusatz'] +h2 = ' '.join(re.findall(r'
{f.get('antwort','')}
" for f in a.get('faq') or []) + html = '\n'.join([f"{a['kurzantwort']}
" if a.get('kurzantwort') else '', a['content_html'], + f"