-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add LocalizedDatasetPrototype #28310
Add LocalizedDatasetPrototype #28310
Conversation
very nice |
Woah, very cool |
LocId datasets from random books are worth translating to this system as well |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add a evenly-weighted random pick method for parity with normal datasets?
In SharedRandomExtensions? Sure. |
About the PR
Adds a variant of DatasetPrototype specifically for cases where a dataset of sequentially-numbered LocId strings is desired (like tips, word lists, advertisements, etc).
Why / Balance
This saves you from having to make a dumb boilerplate YAML file that just lists all the LocIds like:
and instead lets you just do:
Technical details
On the C# side,
LocalizedDatasetPrototype
can be used just like a regularDatasetPrototype
-Values
implementsIReadOnlyList
, so you can index it, iterate through it, or (the most likely case) pass it toRobustRandom.Pick
to get a random entry.Behind the scenes though, any operations on
Values
will actually just construct the LocId strings from the prefix and index number. This should also cut down on the memory usage of localized datasets, since they won't need to actually store all the LocIds and can just construct them as needed.Also includes a unit test to demonstrate that it works.
Media
Code.
Breaking changes
Changelog
Nah.