<commit_before>from bs4 import BeautifulSoup
from bs4 import Comment
from bs4 import NavigableString

import plumeria.util.http as http
from plumeria.command import commands, CommandError
from plumeria.command.parse import Text
from plumeria.util.ratelimit import rate_limit


@commands.register("bible", "esv", category="Search", params=[Text('verse')])
@rate_limit()
async def search_esv(message, verse):
    """
    Search for a bible passage from the English Standard Version.

    Example::

        bible Romans 12:16

    """
    r = await http.get("http://www.esvapi.org/v2/rest/passageQuery", params={
        "key": "IP",
        "passage": verse,
        "output-format": "crossway-xml-1.0"
    })

    doc = BeautifulSoup(r.text(), features="lxml")
    if not doc.passage:
        raise CommandError("Verse not found.")
    return "".join([str(node) for node in doc.passage.content.find('verse-unit').children
                    if isinstance(node, NavigableString) and not isinstance(node, Comment)])<commit_msg>Handle woc element from bible API.<commit_after>from bs4 import BeautifulSoup
from bs4 import Comment
from bs4 import NavigableString

import plumeria.util.http as http
from plumeria.command import commands, CommandError
from plumeria.command.parse import Text
from plumeria.util.ratelimit import rate_limit


@commands.register("bible", "esv", category="Search", params=[Text('verse')])
@rate_limit()
async def search_esv(message, verse):
    """
    Search for a bible passage from the English Standard Version.

    Example::

        bible Romans 12:16

    """
    r = await http.get("http://www.esvapi.org/v2/rest/passageQuery", params={
        "key": "IP",
        "passage": verse,
        "output-format": "crossway-xml-1.0"
    })

    doc = BeautifulSoup(r.text(), features="lxml")
    if not doc.passage:
        raise CommandError("Verse not found.")
    if doc.passage.content.find('woc'):
        return doc.passage.content.find('woc').text
    return "".join([str(node) for node in doc.passage.content.find('verse-unit').children
                    if isinstance(node, NavigableString) and not isinstance(node, Comment)])
{'fraction_non_alphanumeric': 0.12517321016166283, 'fraction_numerical': 0.009237875288683603, 'mean_word_length': 3.569620253164557, 'pattern_counts': {'":': 6, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 4}, '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': '3917961', 'n_tokens_mistral': 677, 'n_tokens_neox': 644, 'n_words': 178}