<commit_before>"""
Geospatial queries.

"""
from collections import defaultdict
from shapely.geometry import mapping

__all__ = [
    'polygon_hashtags',
]

def polygon_hashtags(collection, polygon, skip_users=None):
    """
    Returns hashtag counts for all tweets in a polygon.

    Parameters
    ----------
    collection : MongoDB collection
        The collection of tweets.
    polygon : Shapely Polygon, geoJSON Polygon, list
        The coordinates of the polygon. Note that for a list, it should be a
        list of LinearRing coordinate arrays. A LinearRing coordinate array
        is list of (longitude, latitude) pairs that is closed---the first and
        last point must be the same).
    skip_users : list of int
        A list of Twitter user ids. Any tweet from these user ids will be
        skipped and not included in the counts.

    Returns
    -------
    counts : defaultdict
        The counts for each hashtag. Keys are hashtags, values are counts.
    skipped : int
        The number of tweets that were not counted, due to `skip_users`.

    Examples
    --------
    >>> seattle = [
    ...     [[-122.4596959,47.4810022],
    ...      [-122.4596959,47.7341388],
    ...      [-122.2244329,47.7341388],
    ...      [-122.2244329,47.4810022],
    ...      [-122.4596959,47.4810022]],
    ... ]
    ...
    >>> counts, skipped = polygon_hashtags(collection, seattle)

    Notes
    -----
    This relies on MongoDB's geospatial queries.
    A '2dsphere' index on the collection will speed this up.

    """
    if skip_users is None:
        skip_users = set([])
    else:
        skip_users = set(skip_users)
<commit_msg>Add external link for information on what a polygon should be.<commit_after>"""
Geospatial queries.

"""
from collections import defaultdict
from shapely.geometry import mapping

__all__ = [
    'polygon_hashtags',
]

def polygon_hashtags(collection, polygon, skip_users=None):
    """
    Returns hashtag counts for all tweets in a polygon.

    Parameters
    ----------
    collection : MongoDB collection
        The collection of tweets.
    polygon : Shapely Polygon, geoJSON Polygon, list
        The coordinates of the polygon. Note that for a list, the [polygon]_
        should be a list of LinearRing coordinate arrays. A LinearRing
        coordinate array is a list of (longitude, latitude) pairs that is
        closed---the first and last point must be the same.
    skip_users : list of int
        A list of Twitter user ids. Any tweet from these user ids will be
        skipped and not included in the counts.

    Returns
    -------
    counts : defaultdict
        The counts for each hashtag. Keys are hashtags, values are counts.
    skipped : int
        The number of tweets that were not counted, due to `skip_users`.

    Examples
    --------
    >>> seattle = [
    ...     [[-122.4596959,47.4810022],
    ...      [-122.4596959,47.7341388],
    ...      [-122.2244329,47.7341388],
    ...      [-122.2244329,47.4810022],
    ...      [-122.4596959,47.4810022]],
    ... ]
    ...
    >>> counts, skipped = polygon_hashtags(collection, seattle)

    Notes
    -----
    This relies on MongoDB's geospatial queries.
    A '2dsphere' index on the collection will speed this up.
    For more information on geojson polygons:

    .. [polygon] http://geojson.org/geojson-spec.html#polygon

    """
    if skip_users is None:
        skip_users = set([])
    else:
        skip_users = set(skip_users)

{'fraction_non_alphanumeric': 0.10479471719781798, 'fraction_numerical': 0.05512489233419466, 'mean_word_length': 2.2140221402214024, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7276590', 'n_tokens_mistral': 1173, 'n_tokens_neox': 1001, 'n_words': 358}