Skip to content
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 OnlineNewsMediaCloudESProvider.random_sample method & tests #47

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

philbudne
Copy link
Contributor

First draft, for your consideration...

Adds a new random_sample method (by extending the existing code used to sample titles) with a required fields=["field1", "field2"] which determines the fields returned.

I could almost certainly tuck the functionality into the existing sample method if the fields argument isn't passed, call super().sample(....) which will return the (possibly not so random) hits from the overview query.

Then, if web-search passed a fields list in the /api/search/sample endpoint the new (separate) query would be used for the sample stories for a search...

provider.py:
* Declare AllItems to be Iterable[Items]
* Add a comment on "sample" not being random!
* Add random_sample!!
* Use random_sample in _sample_titles (safe since deprecated providers being removed)

onlinenews.py:
* Update/correct comments
* Raised some questions in comments!
* Renamed "Field" TypeAlias to ES_Field, add ES_Fields
* Allow floating FilterTuple weight
* Merged _sanitize functionality into SanitizedQuery
* Have random_sample return AllItems, use yield
@philbudne philbudne changed the title DRAFT: Add OnlineNewsMediaCloudESProvider.random_sample method & tests Add OnlineNewsMediaCloudESProvider.random_sample method & tests Feb 8, 2025
@philbudne
Copy link
Contributor Author

Less drafty!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant