Skip to content

Commit 0eac14b

Browse files
committed
Fix "compute summarizer language availability" algorithm
It was totally busted.
1 parent 18a628d commit 0eac14b

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

index.bs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -317,19 +317,27 @@ The <dfn attribute for="AI">summarizer</dfn> getter steps are to return [=this=]
317317
<div algorithm>
318318
To <dfn>compute summarizer language availability</dfn> given an [=ordered set=] of strings |requestedLanguages| and a [=map=] from {{AIAvailability}} values to [=sets=] of strings |availabilities|, perform the following steps. They return an {{AIAvailability}} value, and they mutate |requestedLanguages| in place to update language tags to their best-fit matches.
319319

320-
1. [=set/For each=] |languageTag| of |requestedLanguages|:
320+
1. Let |availability| be "{{AIAvailability/available}}".
321+
322+
1. [=set/For each=] |language| of |requestedLanguages|:
321323

322324
1. [=list/For each=] |availabilityToCheck| of « "{{AIAvailability/available}}", "{{AIAvailability/downloading}}", "{{AIAvailability/downloadable}}" »:
323325

324-
1. Let |bestMatch| be [$LookupMatchingLocaleByBestFit$](|availabilities|[|availabilityToCheck|], « |languageTag| »).
326+
1. Let |languagesWithThisAvailability| be |availabilities|[|availabilityToCheck|].
327+
328+
1. Let |bestMatch| be [$LookupMatchingLocaleByBestFit$](|languagesWithThisAvailability|, « |language| »).
325329

326330
1. If |bestMatch| is not undefined, then:
327331

328-
1. [=list/Replace=] |languageTag| with |bestMatch|.\[[locale]] in |requestedLanguages|.
332+
1. [=list/Replace=] |language| with |bestMatch|.\[[locale]] in |requestedLanguages|.
329333

330-
1. Return |availabilityToCheck|.
334+
1. Set |availability| to the [=AIAvailability/minimum availability=] given |availability| and |availabilityToCheck|.
335+
336+
1. [=iteration/Break=].
331337

332338
1. Return "{{AIAvailability/unavailable}}".
339+
340+
1. Return |availability|.
333341
</div>
334342

335343
<div algorithm>

0 commit comments

Comments
 (0)