Introduce async TextDetector create and availability methods#110
Introduce async TextDetector create and availability methods#110
Conversation
f15e479 to
d6833bb
Compare
text.bs
Outdated
| SecureContext | ||
| ] interface TextDetector { | ||
| constructor(); | ||
| static Promise<sequence<DOMString>> availability(TextDetectorOptions options); |
There was a problem hiding this comment.
To match the design of the Writing Assistance APIs as described in #109 this should return Availability.
There was a problem hiding this comment.
I was thinking that sequence<DOMString> is sufficient to indicate available/not available state when we pass sequence<DOMString> languages in TextDetectorOptions. How about return sequence<Availability> so it can check multiple language in one go? Or should we change it as availability(DOMString language) to take one language at a time. WDYT?
There was a problem hiding this comment.
Right now we don't have a pattern for enumerating the set of all supported languages for an API like Translator or Summarizer. I'd rather be consistent with the other APIs and solve the problem of answering the question of "what languages are supported by this client" separately.
The current shape of Translator.availability() for example is good enough because when the developer is looking to translate some text they know what language it's in, though there might be cases where for the UI they are trying to display it would be useful to enumerate all possible languages that the client supports.
Given that it's useful for a TextDetector to be configured to detect multiple languages at a time (e.g. for a multi-lingual document) it makes sense to keep the current input parameter shape, but return a single Availability for consistency with the other APIs.
There was a problem hiding this comment.
Thanks for suggestion! I updated it to reuse Availability from writing-assistance-apis. Please review the latest patch. Thanks!
d6833bb to
a9580db
Compare
|
@reillyeon, thanks for review and approval. |
SHA: 95dda25 Reason: push, by reillyeon Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
SHA: 95dda25 Reason: push, by reillyeon Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This change introduces two new static methods to the TextDetector interface:
This fixes #109