<commit_before>#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import json
import requests
import weechat

info = (
        'JiSearch',
        'ark',
        '0.1',
        'MIT',
        'Requests the jisho\'s API',
        '',
        'utf-8'
        )

url = 'http://beta.jisho.org/api/v1/search/words?keyword='

def jisho_search(data, buffer, message):
    r = requests.get(url+message)
    
    result = b'[JiSearch] '
    try:
        data = json.loads(r.text)['data'][0]

        try:
            result += b'kanji: %s | ' % data['japanese'][0]['word'].encode('utf-8')
        except KeyError:
            pass
        result += b'reading: %s | ' % data['japanese'][0]['reading'].encode('utf-8')
        result += b'meaning: %s' % data['senses'][0]['english_definitions'][0].encode('utf-8')

    except:
        result += 'no results found.'
    weechat.prnt(weechat.current_buffer(), result)
    return weechat.WEECHAT_RC_OK

if weechat.register(*info):
    weechat.hook_command('jisearch', 'Calls Jisho\'s API to search for words/kanji', '', '', '', 'jisho_search', '')


<commit_msg>updated command help<commit_after>#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import json
import requests
import weechat

info = (
        'JiSearch',
        'ark',
        '0.1',
        'MIT',
        'Requests the jisho\'s API',
        '',
        'utf-8'
        )

url = 'http://beta.jisho.org/api/v1/search/words?keyword='

def jisho_search(data, buffer, message):
    r = requests.get(url+message)
    
    result = b'[JiSearch] '
    try:
        data = json.loads(r.text)['data'][0]

        try:
            result += b'kanji: %s | ' % data['japanese'][0]['word'].encode('utf-8')
        except KeyError:
            pass
        result += b'reading: %s | ' % data['japanese'][0]['reading'].encode('utf-8')
        result += b'meaning: %s' % data['senses'][0]['english_definitions'][0].encode('utf-8')

    except:
        result += 'no results found.'
    weechat.prnt(weechat.current_buffer(), result)
    return weechat.WEECHAT_RC_OK

if weechat.register(*info):
    weechat.hook_command(
            'jisearch',
            'Calls Jisho\'s API to search for english words, kanji or kana',
            '[kanji | kana | english]',
            '',
            '',
            'jisho_search',
            '')



{'fraction_non_alphanumeric': 0.17837139164153382, 'fraction_numerical': 0.012063765618267988, 'mean_word_length': 2.2475524475524478, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6382961', 'n_tokens_mistral': 821, 'n_tokens_neox': 825, 'n_words': 148}