You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -344,9 +354,9 @@ The <dfn attribute for="AI">summarizer</dfn> getter steps are to return [=this=]
344
354
345
355
1. Set |availableCreateOptions|[(|type|, |format|, |length|)] to the [=current summarizer create options availability=] given |type|, |format|, and |length|.
346
356
347
-
1. Let |availableLanguages| be the [=current summarizer language availability map=].
357
+
1. Let « |readilyAvailableLanguages|, |afterDownloadAvailableLanguages| » be the [=current summarizer language availabilities=].
348
358
349
-
1. If |availableLanguages| is null, or |availableCreateOptions|'s [=map/values=][=list/contains=] null, then [=queue a global task=] on the [=AI task source=] given [=this=] to perform the following steps:
359
+
1. If |readilyAvailableLanguages| is null, |afterDownloadAvailableLanguages| is null, or |availableCreateOptions|'s [=map/values=][=list/contains=] null, then [=queue a global task=] on the [=AI task source=] given [=this=] to perform the following steps:
350
360
351
361
1. [=Reject=] |promise| with an "{{UnknownError}}" {{DOMException}}.
352
362
@@ -357,8 +367,10 @@ The <dfn attribute for="AI">summarizer</dfn> getter steps are to return [=this=]
: [=AISummarizerCapabilities/readily available languages=]
371
+
:: |readilyAvailableLanguages|
372
+
: [=AISummarizerCapabilities/after-download available languages=]
373
+
:: |afterDownloadAvailableLanguages|
362
374
</dl>
363
375
364
376
1. [=Resolve=] |promise| with |capabilitiesObject|.
@@ -368,16 +380,18 @@ The <dfn attribute for="AI">summarizer</dfn> getter steps are to return [=this=]
368
380
369
381
Every {{AISummarizerCapabilities}} has an <dfn for="AISummarizerCapabilities">available create options</dfn>, a [=map=] from [=tuples=] of ({{AISummarizerType}}, {{AISummarizerFormat}}, {{AISummarizerLength}}) values to {{AICapabilityAvailability}} values, set during creation.
370
382
371
-
Every {{AISummarizerCapabilities}} has an <dfn for="AISummarizerCapabilities">available languages</dfn>, a [=map=] of strings representing BCP 47 language tags to {{AICapabilityAvailability}} values, set during creation. The [=map/values=] will never be "{{AICapabilityAvailability/no}}".
383
+
Every {{AISummarizerCapabilities}} has an <dfn for="AISummarizerCapabilities">readily available languages</dfn>, [=set=] of strings representing BCP 47 language tags, set during creation.
384
+
385
+
Every {{AISummarizerCapabilities}} has an <dfn for="AISummarizerCapabilities">after-download available languages</dfn>, [=set=] of strings representing BCP 47 language tags, set during creation.
372
386
373
387
<div algorithm>
374
388
The <dfn attribute for="AISummarizerCapabilities">available</dfn> getter steps are:
375
389
376
-
1. If [=this=]'s [=AISummarizerCapabilities/available languages=][=map/is empty|are empty=], then return "{{AICapabilityAvailability/no}}".
390
+
1. If [=this=]'s [=AISummarizerCapabilities/readily available languages=] and [=AISummarizerCapabilities/after-download available languages=][=map/is empty|are empty=], then return "{{AICapabilityAvailability/no}}".
377
391
378
392
1. If [=this=]'s all of [=this=]'s [=AISummarizerCapabilities/available create options=][=map/values=] are "{{AICapabilityAvailability/no}}", then return "{{AICapabilityAvailability/no}}".
379
393
380
-
1. If all of [=this=]'s [=AISummarizerCapabilities/available create options=]'s [=map/values=] or all of [=this=]'s [=AISummarizerCapabilities/available languages=]'s[=map/values=]are "{{AICapabilityAvailability/after-download}}", then return "{{AICapabilityAvailability/after-download}}".
394
+
1. If [=this=]'s [=AISummarizerCapabilities/readily available languages=][=map/is empty|are empty=], then return "{{AICapabilityAvailability/after-download}}".
381
395
382
396
1. Return "{{AICapabilityAvailability/readily}}".
383
397
</div>
@@ -391,9 +405,23 @@ Every {{AISummarizerCapabilities}} has an <dfn for="AISummarizerCapabilities">av
391
405
<div algorithm>
392
406
The <dfn method for="AISummarizerCapabilities">languageAvailable(|languageTag|)</dfn> method steps are:
393
407
394
-
1. Return [=this=]'s [=AISummarizerCapabilities/available languages=][|languageTag|], or "{{AICapabilityAvailability/no}}" if no such [=map/entry=][=map/exists=].
408
+
1. If [$IsStructurallyValidLanguageTag$](|languageTag|) is false, then throw a {{TypeError}}.
409
+
410
+
1. Set |languageTag| to [$CanonicalizeUnicodeLocaleId$](|languageTag|).
411
+
412
+
1. Let |bestReadilyAvailableMatch| be [$LookupMatchingLocaleByBestFit$]([=this=]'s [=AISummarizerCapabilities/readily available languages=], |languageTag|).
413
+
414
+
1. If |bestReadilyAvailableMatch| is not undefined, then return "{{AICapabilityAvailability/readily}}".
415
+
416
+
<p class="note">|bestReadilyAvailableMatch|.\[[locale]] contains the actual language tag from [=this=]'s [=AISummarizerCapabilities/readily available languages=], which might be different from |languageTag|.
417
+
418
+
1. Let |bestAfterDownloadAvailableMatch| be [$LookupMatchingLocaleByBestFit$]([=this=]'s [=AISummarizerCapabilities/after-download available languages=], |languageTag|).
395
419
396
-
<p class="issue">Per <a href="https://github.com/WICG/translation-api/issues/11">WICG/translation-api#11</a> it seems we're supposed to do something more complex than just straight string comparison for language tags, but it's not clear what.</p>
420
+
1. If |bestAfterDownloadAvailableMatch| is not undefined, then return "{{AICapabilityAvailability/after-download}}".
421
+
422
+
<p class="note">|bestAfterDownloadAvailableMatch|.\[[locale]] contains the actual language tag from [=this=]'s [=AISummarizerCapabilities/after-download available languages=], which might be different from |languageTag|.
423
+
424
+
1. Return "{{AICapabilityAvailability/no}}".
397
425
</div>
398
426
399
427
<hr>
@@ -413,27 +441,66 @@ Every {{AISummarizerCapabilities}} has an <dfn for="AISummarizerCapabilities">av
413
441
</div>
414
442
415
443
<div algorithm>
416
-
The <dfn>current summarizer language availability map</dfn>is given by the following steps. They return a [=map=]from strings representing BCP 47 language tags to {{AICapabilityAvailability}} values, or null. [[!RFC5646]]
444
+
The <dfn>current summarizer language availabilities</dfn>are given by the following steps. They return a [=list=]containing two [=list/items=]; the items each are [=sets=] of strings representing [=Unicode canonicalized locale identifier=], or null. [[!ECMA-402]]
417
445
418
446
1. [=Assert=]: this algorithm is running [=in parallel=].
419
447
420
-
1. If there is some error attempting to determine whether the user agent supports summarizing text, which the user agent believes to be transient (such that re-querying the [=current summarizer create options availability=] could stop producing such an error), then return null.
448
+
1. If there is some error attempting to determine whether the user agent supports summarizing text, which the user agent believes to be transient (such that re-querying the [=current summarizer language availabilities=] could stop producing such an error), then return « null, null ».
449
+
450
+
1. Let |readilyAvailableLanguages| and |afterDownloadAvailableLanguages| be empty [=sets=].
451
+
452
+
1. [=list/For each=] human language |languageTag|, represented as a [=Unicode canonicalized locale identifier=], for which the user agent supports summarizing text written in that language, without performing any downloading operations:
453
+
454
+
1. [=set/Append=] |languageTag| to |readilyAvailableLanguages|.
455
+
456
+
1. [=list/For each=] human language |languageTag|, represented as a [=Unicode canonicalized locale identifier=], for which the user agent believes it can summarize text written in that language, but only after performing a download (e.g., of an AI model or fine-tuning):
457
+
458
+
1. [=Assert=]: |readilyAvailableLanguages| does not [=set/contain=] |languageTag|.
459
+
460
+
1. [=set/Append=] |languageTag| to |afterDownloadAvailableLanguages|.
461
+
462
+
1. If the [=set/union=] of |readilyAvailableLanguages| and |afterDownloadAvailableLanguages| does not meet the [=language tag set completeness rules=], then:
463
+
464
+
1. Let |missingLanguageTags| be the [=set=] of missing language tags necessary to meet the [=language tag set completeness rules=].
465
+
466
+
1. [=set/For each=] |languageTag| of |missingLanguageTags|:
467
+
468
+
1. <span id="readily-or-after-download-implementation-defined"></span>[=set/Append=] |languageTag| to either |readilyAvailableLanguages| or |afterDownloadAvailableLanguages|. Which of the two sets to append to is [=implementation-defined=], and should be guided by considerations similar to that of [$LookupMatchingLocaleByBestFit$] in terms of keeping "best fallback languages" together.
The <dfn>language tag set completeness rules</dfn> state that for every [=set/item=] |languageTag|, if |languageTag| has more than one subtag, then the set must also contain a less narrow language tag with the same language subtag and a strict subset of the same following subtags (i.e., omitting one or more).
475
+
476
+
<p class="note">This definition is intended to align with that of [=[[AvailableLocales]]=] in <cite>ECMAScript Internationalization API Specification</cite>. [[ECMA-402]]
421
477
422
-
1. Let |availableLanguages| be an empty [=map=].
478
+
<div class="example" id="example-subtags-intro">
479
+
This means that if an implementation supports summarization of "`de-DE`" text, it will also count as supporting "`de`" text.
423
480
424
-
1. [=list/For each=] human language for which the user agent supports summarizing text written in that language, without performing any downloading operations:
481
+
The converse direction is supported not by the [=language tag set completeness rules=], but instead by the use of [$LookupMatchingLocaleByBestFit$], which ensures that if an implementation supports summarizing "`de`" text, it also counts as supporting summarization of "`de-CH`", "`de-Latn-CH`", etc.
482
+
</div>
425
483
426
-
1. Let |languageTag| be that language, represented as a BCP 47 language tag string. <span class="issue">Describe how to handle subtags.</span>
A common setup seen in today's software is to support two types of written Chinese: "traditional Chinese" and "simplified Chinese". Let's suppose that the user agent supports summarizing text written in traditional Chinese readily, and simplified Chinese after a download.
427
486
428
-
1. Set |availableLanguages|[|languageTag|] to "{{AICapabilityAvailability/readily}}".
487
+
One way this could be implemented would be for [=current summarizer language availabilities=] to return that « "`zh-Hant`" » is readily available, and « "`zh`", "`zh-Hans`" » is available after download. This return value conforms to the requirements of the [=language tag set completeness rules=], in ensuring that "`zh`" is present. Per <a class="allow-2119" href="#readily-or-after-download-implementation-defined">the "should"-level guidance</a>, the implementation has determined that "`zh`" belongs in the list of after-download available languages, with "`zh-Hans`", instead of in the list of readily available languages, with "`zh-Hant`".
429
488
430
-
1. [=list/For each=] human language for which the user agent believes it can summarize text written in that language, but only after performing a download (e.g., of an AI model or fine-tuning):
489
+
Combined with the use of [$LookupMatchingLocaleByBestFit$], this means the the {{AISummarizerCapabilities/languageAvailable()}} will give the the following answers:
431
490
432
-
1. Let |languageTag| be that language, represented as a BCP 47 language tag string. <span class="issue">Describe how to handle subtags.</span>
0 commit comments