alpha01 backoffice: crossword engine, lexicon curation and JSON contract
This commit is contained in:
@@ -87,7 +87,12 @@ class CrosswordFiller:
|
||||
self.words_by_length = self._index_vocabulary(self.vocabulary)
|
||||
self.vocabulary_metadata = vocabulary_metadata or {}
|
||||
self.semantic_metadata = semantic_metadata or {}
|
||||
self.selected_topic = selected_topic.strip().lower()
|
||||
self.selected_topics = [
|
||||
topic.strip().lower()
|
||||
for topic in selected_topic.split(",")
|
||||
if topic.strip()
|
||||
] or ["general"]
|
||||
self.selected_topic = self.selected_topics[0]
|
||||
self.max_themed_fill_words = max(0, max_themed_fill_words)
|
||||
self.seed = seed
|
||||
self.rng = random.Random(seed)
|
||||
@@ -333,7 +338,7 @@ class CrosswordFiller:
|
||||
return score
|
||||
|
||||
def _semantic_topic_score(self, word: str) -> int:
|
||||
if not self.selected_topic or self.selected_topic == "general":
|
||||
if not self.selected_topics or self.selected_topics == ["general"]:
|
||||
return 0
|
||||
|
||||
entry = self._semantic_entry(word)
|
||||
@@ -350,9 +355,9 @@ class CrosswordFiller:
|
||||
semantic = entry.get("semantic", {})
|
||||
semantic_topics = {str(item).lower() for item in semantic.get("semantic_topics", [])}
|
||||
score = 0
|
||||
if self.selected_topic in topics:
|
||||
if any(topic in topics for topic in self.selected_topics):
|
||||
score += 4
|
||||
if self.selected_topic in semantic_topics:
|
||||
if any(topic in semantic_topics for topic in self.selected_topics):
|
||||
score += 6
|
||||
if "general" in topics:
|
||||
score += 1
|
||||
|
||||
Reference in New Issue
Block a user