Fix: Umlaute einbeziehen Funktionalität repariert
- HTML: name-Attribut und form-Attribut zur Umlaute-Checkbox hinzugefügt - Backend: use_umlaut Parameter zur Form-Verarbeitung hinzugefügt - Backend: Umlaute-Filterung in filter_words() Funktion implementiert - Backend: use_umlaut Variable an Template weitergegeben - JavaScript: applyFilters() Funktion für Umlaute-Checkbox erweitert Die Umlaute einbeziehen Option funktioniert jetzt korrekt sowohl auf Backend- als auch Frontend-Ebene.
This commit is contained in:
13
app.py
13
app.py
@@ -209,7 +209,7 @@ def load_words() -> Tuple[List[str], Dict[str, List[str]]]:
|
|||||||
return words, sources_map
|
return words, sources_map
|
||||||
|
|
||||||
|
|
||||||
def filter_words(words: List[str], position_letters: List[str], includes_text: str, excludes_text: str) -> List[str]:
|
def filter_words(words: List[str], position_letters: List[str], includes_text: str, excludes_text: str, use_umlaut: bool = True) -> List[str]:
|
||||||
results: List[str] = []
|
results: List[str] = []
|
||||||
includes_letters = [ch for ch in includes_text.lower() if ch.isalpha()]
|
includes_letters = [ch for ch in includes_text.lower() if ch.isalpha()]
|
||||||
excludes_letters = [ch for ch in excludes_text.lower() if ch.isalpha()]
|
excludes_letters = [ch for ch in excludes_text.lower() if ch.isalpha()]
|
||||||
@@ -223,6 +223,9 @@ def filter_words(words: List[str], position_letters: List[str], includes_text: s
|
|||||||
# darf-nicht-enthalten
|
# darf-nicht-enthalten
|
||||||
if any(ch in word for ch in excludes_letters):
|
if any(ch in word for ch in excludes_letters):
|
||||||
continue
|
continue
|
||||||
|
# Umlaute-Filter
|
||||||
|
if not use_umlaut and ('ä' in word or 'ö' in word or 'ü' in word or 'ß' in word):
|
||||||
|
continue
|
||||||
results.append(word)
|
results.append(word)
|
||||||
return results
|
return results
|
||||||
|
|
||||||
@@ -242,6 +245,7 @@ def index():
|
|||||||
excludes: str = ""
|
excludes: str = ""
|
||||||
use_ot: bool = True
|
use_ot: bool = True
|
||||||
use_wf: bool = False
|
use_wf: bool = False
|
||||||
|
use_umlaut: bool = True
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
pos = [
|
pos = [
|
||||||
(request.form.get("pos1") or "").strip().lower(),
|
(request.form.get("pos1") or "").strip().lower(),
|
||||||
@@ -254,6 +258,7 @@ def index():
|
|||||||
excludes = (request.form.get("excludes") or "").strip()
|
excludes = (request.form.get("excludes") or "").strip()
|
||||||
use_ot = request.form.get("use_ot") is not None
|
use_ot = request.form.get("use_ot") is not None
|
||||||
use_wf = request.form.get("use_wf") is not None
|
use_wf = request.form.get("use_wf") is not None
|
||||||
|
use_umlaut = request.form.get("use_umlaut") is not None
|
||||||
# Falls keine Quelle gewählt ist, standardmäßig OpenThesaurus aktivieren
|
# Falls keine Quelle gewählt ist, standardmäßig OpenThesaurus aktivieren
|
||||||
if not use_ot and not use_wf:
|
if not use_ot and not use_wf:
|
||||||
use_ot = True
|
use_ot = True
|
||||||
@@ -264,12 +269,13 @@ def index():
|
|||||||
'includes': includes,
|
'includes': includes,
|
||||||
'excludes': excludes,
|
'excludes': excludes,
|
||||||
'use_ot': use_ot,
|
'use_ot': use_ot,
|
||||||
'use_wf': use_wf
|
'use_wf': use_wf,
|
||||||
|
'use_umlaut': use_umlaut
|
||||||
}
|
}
|
||||||
log_search_query(search_params, request.headers.get('User-Agent'))
|
log_search_query(search_params, request.headers.get('User-Agent'))
|
||||||
|
|
||||||
# 1) Buchstaben-/Positionssuche über alle Wörter
|
# 1) Buchstaben-/Positionssuche über alle Wörter
|
||||||
matched = filter_words(all_words, pos, includes, excludes)
|
matched = filter_words(all_words, pos, includes, excludes, use_umlaut)
|
||||||
# 2) Quellen-Filter nur auf Ergebnisansicht anwenden
|
# 2) Quellen-Filter nur auf Ergebnisansicht anwenden
|
||||||
allowed = set()
|
allowed = set()
|
||||||
if use_ot:
|
if use_ot:
|
||||||
@@ -291,6 +297,7 @@ def index():
|
|||||||
sources_map=sources_map,
|
sources_map=sources_map,
|
||||||
use_ot=use_ot,
|
use_ot=use_ot,
|
||||||
use_wf=use_wf,
|
use_wf=use_wf,
|
||||||
|
use_umlaut=use_umlaut,
|
||||||
error_message=None,
|
error_message=None,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -154,7 +154,7 @@
|
|||||||
<fieldset class="filter-box" role="group">
|
<fieldset class="filter-box" role="group">
|
||||||
<legend>Umlaute</legend>
|
<legend>Umlaute</legend>
|
||||||
<div class="inline-controls">
|
<div class="inline-controls">
|
||||||
<label><input id="filter-umlaut" type="checkbox" /> Umlaute einbeziehen (ä, ö, ü, ß)</label>
|
<label><input id="filter-umlaut" type="checkbox" name="use_umlaut" form="search-form" {% if use_umlaut %}checked{% endif %}/> Umlaute einbeziehen (ä, ö, ü, ß)</label>
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<div class="results-box">
|
<div class="results-box">
|
||||||
@@ -228,7 +228,7 @@
|
|||||||
var ot = document.getElementById('filter-ot');
|
var ot = document.getElementById('filter-ot');
|
||||||
var wf = document.getElementById('filter-wf');
|
var wf = document.getElementById('filter-wf');
|
||||||
var uml = document.getElementById('filter-umlaut');
|
var uml = document.getElementById('filter-umlaut');
|
||||||
if (!ot || !wf) return;
|
if (!ot || !wf || !uml) return;
|
||||||
var allowed = [];
|
var allowed = [];
|
||||||
if (ot.checked) allowed.push('ot');
|
if (ot.checked) allowed.push('ot');
|
||||||
if (wf.checked) allowed.push('wf');
|
if (wf.checked) allowed.push('wf');
|
||||||
|
Reference in New Issue
Block a user