<commit_before>from algoliasearch import algoliasearch

class AlgoliaHelper(object):
    """Handles the Algolia stuff."""

    def __init__(self):
        self.app_id = 'PBF4ZR3KBT'
        self.api_key = '<KEY>' # search-only
        self.index_name = 'ubuntu_irc_logs'

        # Restricted search (for acquiring metadata).
        self.restricted_search = {
            'page': 1,
            'hitsPerPage': 1,
            'length': 1
        }

        # General search.
        self.general_search = {
            'highlightPreTag': '',
            'highlightPostTag': '',
            'hitsPerPage': 1000
        }

        # Keep it simple.
        self.client = algoliasearch.Client(self.app_id, self.api_key)
        self.index = self.client.init_index(self.index_name)

    def get_channels(self):
        """Get a list of indexed channels."""

        criteria = {'facets': 'channel'}
        results = self.index.search(
            '',
            dict(self.restricted_search, **criteria)
        )

        return results['facets']['channel'].keys()

    def do_a_search(self, query, criteria):
        """Execute a generic search based on some criteria."""

        results = self.index.search(
            query,
            dict(self.general_search, **criteria)
        )

        return results

    def get_irc_logs(self, timestamp, channel):
        """Search for IRC logs given a datestamp and criteria."""

        # Because we're only interested in exact timestamp hits, we need the
        # ranking info in order to filter out inexact results.
        criteria = {
            'facetFilters': ['channel:' + channel],
            'getRankingInfo': 1
        }
        results = self.index.search(
            timestamp,
            dict(self.general_search, **criteria)
        )

        returnable = []
        for hit in results['hits']:
            if hit['_rankingInfo']['proximityDistance'] <= 3:
                returnable.append('[' + hit['datestamp'] + '] ' + \
                    hit['username'] + ': ' + hit['message'])

        return returnable

    def get_most_recent_user_stamp(self, username):
        """Get the timestamp of the most recent log line for a user."""

        criteria = {
            'facetFilters': ['username:' + username],
            'getRankingInfo': 1<commit_msg>make log line easier to read<commit_after>"""Algolia is a funny word."""
from algoliasearch import algoliasearch

class AlgoliaHelper(object):
    """Handles the Algolia stuff."""

    def __init__(self):
        self.app_id = 'PBF4ZR3KBT'
        self.api_key = '<KEY>' # search-only
        self.index_name = 'ubuntu_irc_logs'

        # Restricted search (for acquiring metadata).
        self.restricted_search = {
            'page': 1,
            'hitsPerPage': 1,
            'length': 1
        }

        # General search.
        self.general_search = {
            'highlightPreTag': '',
            'highlightPostTag': '',
            'hitsPerPage': 1000
        }

        # Keep it simple.
        self.client = algoliasearch.Client(self.app_id, self.api_key)
        self.index = self.client.init_index(self.index_name)

    def get_channels(self):
        """Get a list of indexed channels."""

        criteria = {'facets': 'channel'}
        results = self.index.search(
            '',
            dict(self.restricted_search, **criteria)
        )

        return results['facets']['channel'].keys()

    def do_a_search(self, query, criteria):
        """Execute a generic search based on some criteria."""

        results = self.index.search(
            query,
            dict(self.general_search, **criteria)
        )

        return results

    def get_irc_logs(self, timestamp, channel):
        """Search for IRC logs given a datestamp and criteria."""

        # Because we're only interested in exact timestamp hits, we need the
        # ranking info in order to filter out inexact results.
        criteria = {
            'facetFilters': ['channel:' + channel],
            'getRankingInfo': 1
        }
        results = self.index.search(
            timestamp,
            dict(self.general_search, **criteria)
        )

        returnable = []
        for hit in results['hits']:
            if hit['_rankingInfo']['proximityDistance'] <= 3:
                returnable.append('[' + hit['datestamp'] + '] <' + \
                    hit['username'] + '> ' + hit['message'])

        return returnable

    def get_most_recent_user_stamp(self, username):
        """Get the timestamp of the most recent log line for a user."""

        criteria = {
            'facetFilters': ['username:' + username],
            'getRankingInfo': 1
{'fraction_non_alphanumeric': 0.11917429240263885, 'fraction_numerical': 0.005107469674398808, 'mean_word_length': 1.9634300126103406, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 6, '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': '4414941', 'n_tokens_mistral': 1359, 'n_tokens_neox': 1277, 'n_words': 331}