-
Notifications
You must be signed in to change notification settings - Fork 5
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
Is it possible to select multiple items in one query to the list? #2
Comments
There's not anything already built, mostly because with a weighted set like this, typically you want multiple items from the set to respect the weighted distribution itself, including duplicates. What is the use case for getting a set of unique items? It could be a really useful feature, but I'm having trouble thinking of a use case. |
My situation is pretty specific. Essentially I have a list of items that is continuously growing, I am sending a weekly newsletter containing 5 or so of these items selected at random. I want to avoid duplicates within a short period of time so I'm adding a column to track the time since an item was last sent in an email and using the square of that time to assign a weight. I wrote a wrapper function that makes multiple selections removing each choice from the original list and reassigning the weights dynamically for a certain number of selections given as an argument. |
I looked at adding this to the API, and couldn't find anything that didn't make other calling conventions worse. I'm going to close this for now, though I'm open to PRs with concrete ideas for where to take this. If it's any consolation, I added a section to the README (along with a complete overhaul to make it easier to consume) linking back to your algorithm as an example of how to handle this: https://github.com/Schoonology/weighted#selecting-multiple-items-simultaneously |
For example, I'd like to select 5 unique items from a weighted list. I can write some functionality to do this myself, but I'm curious if there's a feature to specify a number of items to select.
The text was updated successfully, but these errors were encountered: