Skip to content

Commit

Permalink
Website: list per language the missing intents (home-assistant#2526)
Browse files Browse the repository at this point in the history
* List missing intents

* Black
  • Loading branch information
balloob authored Nov 13, 2024
1 parent c3cf63d commit 909736d
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 21 deletions.
46 changes: 27 additions & 19 deletions script/intentfest/website_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


def run() -> int:
language_summaries = []
language_summaries = {}

language_info = yaml.safe_load(LANGUAGES_FILE.read_text())

Expand Down Expand Up @@ -55,10 +55,11 @@ def run() -> int:
for translation in merged_sentences["responses"]["errors"].values()
)

usable = (
all(intent_sentence_count[key] for key in IMPORTANT_INTENTS)
and errors_translated
)
missing_intents = [
intent for intent in IMPORTANT_INTENTS if not intent_sentence_count[intent]
]

usable = not missing_intents and errors_translated

complete = (
all(value > 0 for value in intent_sentence_count.values())
Expand All @@ -73,20 +74,19 @@ def run() -> int:
for intent, response_set in used_responses_per_intent.items()
}

language_summaries.append(
{
"language": language,
"native_name": language_info[language]["nativeName"],
"leaders": language_info[language].get("leaders"),
"intents": intent_sentence_count,
"used_responses": used_responses_count,
"responses": response_sentence_count,
"intent_responses_translated": intent_responses_translated,
"errors_translated": errors_translated,
"usable": usable,
"complete": complete,
}
)
language_summaries[language] = {
"language": language,
"native_name": language_info[language]["nativeName"],
"leaders": language_info[language].get("leaders"),
"intents": intent_sentence_count,
"used_responses": used_responses_count,
"responses": response_sentence_count,
"intent_responses_translated": intent_responses_translated,
"errors_translated": errors_translated,
"usable": usable,
"complete": complete,
"missing_intents": missing_intents,
}

intents = {}
for intent, info in intent_info.items():
Expand All @@ -100,6 +100,14 @@ def run() -> int:
{
"intents": intents,
"languages": language_summaries,
"improvements": [
info["language"]
for info in sorted(
language_summaries.values(),
key=lambda x: (len(x["missing_intents"]), x["language"]),
)
if info["missing_intents"]
],
},
indent=2,
)
Expand Down
25 changes: 23 additions & 2 deletions website/src-11ty/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,16 @@
<thead>
<tr>
<th>Language</th>
{% for intent in intentSummary.languages[0].intents %}
{% for intent in intentSummary.languages.en.intents %}
<th>{{intent[0] | remove_first: "Hass"}}</th>
{% endfor %}
<th>Errors translated</th>
<th>Leader</th>
</tr>
</thead>
<tbody>
{% for summary in intentSummary.languages %}
{% for item in intentSummary.languages %}
{% assign summary = item[1] %}
<tr class="{% if summary.usable %}usable{% endif %}">
<td>
<a
Expand Down Expand Up @@ -98,3 +99,23 @@
</tbody>
</table>
<p><i>Every cell in the table links to the relevant file.</i></p>
<h2>Road to Team 💚</h2>
List of languages that are missing important intent coverage.
<table>
<tr>
<th>Language</th>
<th>Missing</th>
<th>Intents</th>
</tr>
{% for language in intentSummary.improvements %}
<tr>
<td>{{ language }}</td>
<td>{{ intentSummary.languages[language].missing_intents | size }}</td>
<td style="text-align: left; padding-left: 16px;">
{% for intent in intentSummary.languages[language].missing_intents %}
{{ intent }}{% if forloop.last == false %}, {% endif %}
{% endfor %}
</td>
</tr>
{% endfor %}
</table>

0 comments on commit 909736d

Please sign in to comment.