<commit_before>import requests

import smartbot
from smartbot import utils
from smartbot.exceptions import *
from smartbot.formatting import *


class Plugin(smartbot.Plugin):
    """A plugin for searching Freebase."""
    names = ["define", "freebase"]

    def __init__(self, key):
        self.key = key

    def _search_mid(self, query):
        url = "https://www.googleapis.com/freebase/v1/search"
        payload = {
            "query": query,
            "key": self.key,
            "limit": 1
        }

        session = utils.web.requests_session()
        res = session.get(url, params=payload).json()
        if res["result"]:
            return res["result"][0]["mid"]
        else:
            return None

    def _topic(self, mid):
        url = "https://www.googleapis.com/freebase/v1/topic{}".format(mid)
        session = utils.web.requests_session()
        return requests.get(url).json()

    def _look_for_text(self, topic):
        description = topic["property"].get("/common/topic/description")
        if description:
            return description["values"][0]["text"], \
                   description["values"][0]["value"]
        else:
            return None, None

    def on_command(self, msg, stdin, stdout, reply):
        query = " ".join(msg["args"][1:])
        if not query:
            query = stdin.read().strip()<commit_msg>Remove unnecessary return<commit_after>import requests

import smartbot
from smartbot import utils
from smartbot.exceptions import *
from smartbot.formatting import *


class Plugin(smartbot.Plugin):
    """A plugin for searching Freebase."""
    names = ["define", "freebase"]

    def __init__(self, key):
        self.key = key

    def _search_mid(self, query):
        url = "https://www.googleapis.com/freebase/v1/search"
        payload = {
            "query": query,
            "key": self.key,
            "limit": 1
        }

        session = utils.web.requests_session()
        res = session.get(url, params=payload).json()
        if res["result"]:
            return res["result"][0]["mid"]

    def _topic(self, mid):
        url = "https://www.googleapis.com/freebase/v1/topic{}".format(mid)
        session = utils.web.requests_session()
        return requests.get(url).json()

    def _look_for_text(self, topic):
        description = topic["property"].get("/common/topic/description")
        if description:
            return description["values"][0]["text"], \
                   description["values"][0]["value"]
        else:
            return None, None

    def on_command(self, msg, stdin, stdout, reply):
        query = " ".join(msg["args"][1:])
        if not query:
            query = stdin.read().strip()
{'fraction_non_alphanumeric': 0.14185703758290347, 'fraction_numerical': 0.005158437730287398, 'mean_word_length': 2.2949029126213594, 'pattern_counts': {'":': 6, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 4, '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': '3369292', 'n_tokens_mistral': 797, 'n_tokens_neox': 778, 'n_words': 176}