Skip to content

Comments

Intl segmenter updates#8402

Merged
teoli2003 merged 42 commits intomdn:mainfrom
meyerweb:intl-segmenter
Jan 10, 2022
Merged

Intl segmenter updates#8402
teoli2003 merged 42 commits intomdn:mainfrom
meyerweb:intl-segmenter

Conversation

@meyerweb
Copy link
Contributor

No description provided.

meyerweb and others added 3 commits August 6, 2021 16:17
* make spanish_segmenter more... modern?

* add example and syntax to Segmenter#resolvedOptions

* add example and syntax to Segmenter#segment

* add information about segment data objects
@github-actions
Copy link
Contributor

github-actions bot commented Aug 27, 2021

Preview URLs

Flaws

URL: /en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter
Title: Intl.Segmenter
on GitHub
Flaw count: 1

  • bad_bcd_queries:
    • No BCD data for query: javascript.builtins.Intl.Segmenter

URL: /en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/resolvedOptions
Title: Intl.Segmenter.prototype.resolvedOptions()
on GitHub
Flaw count: 1

  • bad_bcd_queries:
    • No BCD data for query: javascript.builtins.Intl.Segmenter.resolvedOptions

URL: /en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/Segmenter
Title: Intl.Segmenter() constructor
on GitHub
Flaw count: 1

  • bad_bcd_queries:
    • No BCD data for query: javascript.builtins.Intl.Segmenter.constructor

URL: /en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/segment
Title: Intl.Segmenter.prototype.segment()
on GitHub
Flaw count: 1

  • bad_bcd_queries:
    • No BCD data for query: javascript.builtins.Intl.Segmenter.segment

URL: /en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/supportedLocalesOf
Title: Intl.Segmenter.supportedLocalesOf()
on GitHub
Flaw count: 1

  • bad_bcd_queries:
    • No BCD data for query: javascript.builtins.Intl.Segmenter.supportedLocalesOf

URL: /en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segments
Title: Intl.Segments
on GitHub
Flaw count: 1

  • bad_bcd_queries:
    • No BCD data for query: javascript.builtins.Intl.Segments

URL: /en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segments/containing
Title: Intl.Segments.prototype.containing()
on GitHub
Flaw count: 1

  • bad_bcd_queries:
    • No BCD data for query: javascript.builtins.Intl.Segments.containing

URL: /en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segments/@@iterator
Title: Intl.Segments.prototype[@@iterator]()
on GitHub
Flaw count: 1

  • bad_bcd_queries:
    • No BCD data for query: javascript.builtins.Intl.Segments.@@iterator

External URLs

URL: /en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter
Title: Intl.Segmenter
on GitHub

No new external URLs


URL: /en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/resolvedOptions
Title: Intl.Segmenter.prototype.resolvedOptions()
on GitHub

No new external URLs


URL: /en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/Segmenter
Title: Intl.Segmenter() constructor
on GitHub


URL: /en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/segment
Title: Intl.Segmenter.prototype.segment()
on GitHub

No new external URLs


URL: /en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/supportedLocalesOf
Title: Intl.Segmenter.supportedLocalesOf()
on GitHub

No new external URLs


URL: /en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segments
Title: Intl.Segments
on GitHub

No new external URLs


URL: /en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segments/containing
Title: Intl.Segments.prototype.containing()
on GitHub

No new external URLs


URL: /en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segments/@@iterator
Title: Intl.Segments.prototype[@@iterator]()
on GitHub

No new external URLs

(this comment was updated 2022-01-07 17:49:04.159442)

Copy link
Contributor

@gibson042 gibson042 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The content here is good, but seems to diverge from conventions that exist elsewhere in https://github.com/mdn/content/tree/main/files/en-us/web/javascript/reference/global_objects/intl . I think those should be corrected before a more Segmenter-specific review.

@romulocintra
Copy link
Contributor

@meyerweb this PR closes tc39/ecma402-mdn#17 Thanks for the great work!!

@meyerweb
Copy link
Contributor Author

@meyerweb this PR closes tc39/ecma402-mdn#17 Thanks for the great work!!

Glad to help! Except we’re not quite there: I still need to write the @@iterator page, and enhance the constructor page with a localeMatcher example.

Specifically, what I need is:

  • A compact (if possible) code example using .next(). Two or three examples would be even better!
  • A code example (or two) of different values of the option localeMatcher yielding different results for the locale when constructing an Intl.Segmenter.

If you have any sources for where I might find such things, I’d be most obliged!

@teoli2003 teoli2003 added the Content:JS JavaScript docs label Sep 13, 2021
@romulocintra
Copy link
Contributor

romulocintra commented Sep 28, 2021

Hi @meyerweb

  • A compact (if possible) code example using .next(). Two or three examples would be even better!
let segmenter = new Intl.Segmenter("fr", {granularity: "word"});
let input = "Moi?  N'est-ce pas.";
let segments = segmenter.segment(input);
let iterator = segments[Symbol.iterator]();

console.log(iterator.next().value); // logs {segment: 'Moi', index: 0, input: "Moi?  N'est-ce pas.", isWordLike: true}
console.log(iterator.next().value); // logs {segment: '?', index: 3, input: "Moi?  N'est-ce pas.", isWordLike: false}
console.log(iterator.next().value); // logs {segment: '  ', index: 4, input: "Moi?  N'est-ce pas.", isWordLike: false}
//...

Or

let segmenter = new Intl.Segmenter("fr", {granularity: "word"});
let input = "Moi?  N'est-ce pas.";
let segments = segmenter.segment(input);
let iterator = segments[Symbol.iterator]();

while (true) {
  let result = iterator.next()
  if (result.done) break;
  console.log(result.value)
}

/* Logs
{segment: 'Moi', index: 0, input: "Moi?  N'est-ce pas.", isWordLike: true}
{segment: '?', index: 3, input: "Moi?  N'est-ce pas.", isWordLike: false}
{segment: '  ', index: 4, input: "Moi?  N'est-ce pas.", isWordLike: false}
{segment: "N'est", index: 6, input: "Moi?  N'est-ce pas.", isWordLike: true}
{segment: '-', index: 11, input: "Moi?  N'est-ce pas.", isWordLike: false}
{segment: 'ce', index: 12, input: "Moi?  N'est-ce pas.", isWordLike: true}
{segment: ' ', index: 14, input: "Moi?  N'est-ce pas.", isWordLike: false}
{segment: 'pas', index: 15, input: "Moi?  N'est-ce pas.", isWordLike: true}
{segment: '.', index: 18, input: "Moi?  N'est-ce pas.", isWordLike: false}
*/

@meyerweb
Copy link
Contributor Author

@romulocintra Please review the new page for the iterator and let me know if anything needs to be fixed. (Or submit your own edits — that works too.) Thanks!

@romulocintra
Copy link
Contributor

romulocintra commented Oct 1, 2021

@meyerweb LGTM, It's not a draft anymore, looks ready to review 👍🏿 great work! If something is missing the goal is to evolve along the time!!!

@meyerweb meyerweb marked this pull request as ready for review October 1, 2021 13:59
@meyerweb meyerweb requested a review from a team as a code owner October 1, 2021 13:59
@meyerweb meyerweb requested review from sideshowbarker and removed request for a team October 1, 2021 13:59
SphinxKnight and others added 13 commits January 7, 2022 06:37
…nter/supportedlocalesof/index.md

Co-authored-by: wbamberg <[email protected]>
@SphinxKnight SphinxKnight requested a review from wbamberg January 7, 2022 06:03
@SphinxKnight
Copy link
Contributor

@wbamberg thanks a lot for the swift review and catching a lot of things. I think there is only the localeMatcher issue remaining.

Copy link
Collaborator

@wbamberg wbamberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was one const that needed to be a let, that I just committed. Otherwise I'm very happy with this. Thanks @SphinxKnight for finishing this off, and @meyerweb and @romulocintra for all your work on it too.

I think perhaps we should not merge until mdn/browser-compat-data#14428 is merged, maybe we could nag someone to review that one.

@SphinxKnight
Copy link
Contributor

and BCD PR is merged :)

@teoli2003
Copy link
Contributor

Merging this per the last two comments \o/

@teoli2003 teoli2003 merged commit c95e770 into mdn:main Jan 10, 2022
wbamberg pushed a commit to mdn/yari that referenced this pull request Jan 10, 2022
SphinxKnight added a commit to SphinxKnight/content that referenced this pull request Mar 31, 2022
teoli2003 pushed a commit that referenced this pull request Mar 31, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Content:JS JavaScript docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants