Skip to main content

A simple Python package to build event based requests for the NewsEye API

Project description

newseyevent

This Python package is used to represent a wikivents Event object as a Solr or platform.newseye.eu query string. Full documentation is hosted on Gitlab Pages and available publicly.

Request managers

The only object you should use in order to export event is either the SolrCollection and the SolrQueryEventArticlesInLanguage class or inherited classes.

Below is an example on how to use the SolrRequestManager:

from wikivents.models import ISO6391LanguageCode
from wikivents.factories.wikimedia import WikimediaFactory
from datetime import datetime
from newseyevent.solr import SolrQueryEventArticlesInLanguage, SolrQueryEventArticlesInLanguageDateRange, \
    SolrInstance, SolrCollection

# Create the Easter Rising event instance
event = WikimediaFactory.create_event("Q193689")

# Create the object representing the Solr Collection (on a specific host, with an explicit collection name)
solr_collection = SolrCollection(SolrInstance("localhost", 8993), "newseye_collection")

# Query articles related to the event, in English
query_articles_in_lang = SolrQueryEventArticlesInLanguage(event, ISO6391LanguageCode("fr"))
print(solr_collection.query(query_articles_in_lang))

# Query articles related to the event, in English, published between 01/01/1910 and 01/01/1911
query_articles_in_lang_date_range = SolrQueryEventArticlesInLanguageDateRange(
    event, ISO6391LanguageCode("en"),
    datetime.strptime("1910-01-01", "%Y-%m-%d"),
    datetime.strptime("1911-01-01", "%Y-%m-%d")
)
print(solr_collection.query(query_articles_in_lang_date_range))

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Built Distribution

newseyevent-0.1.0.dev202101111736-py3-none-any.whl (18.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page