<commit_before># Copyright 2015 Novo Nordisk Foundation Center for Biosustainability, DTU.

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import absolute_import, print_function
from uuid import uuid4
from IPython.core.display import HTML, Javascript
from IPython.core.display import display

from cameo import util
import logging
import os


ASSETS = os.path.join(os.path.dirname(__file__), "assets")

LOADING_IMAGE = os.path.join(ASSETS, "loading.gif")

logger = logging.getLogger(__name__)


def notice(message):
    if util.in_ipnb():
        display(HTML("<span>%s</span>" % message))
    else:
        print(message)


def bold(message):
    if util.in_ipnb():
        display(HTML("<strong>%s</strong>" % message))
    else:
        print("\033[1m" + message + "\033[0m")


def loading():
    if util.in_ipnb():
        identifier = str(uuid4())
        with open(LOADING_IMAGE, 'rb') as f:
            display(HTML("""
            <img class="loading" id="%s" style="margin:auto; text-align:center;" src="data:image/gif;base64,%s"/>
            """ % (identifier, f.read().encode('base64').replace('\n', ''))))
        return identifier
    else:
        logger.debug("loading only works on Jupyter notebooks")


def stop_loader(identifier):
    if util.in_ipnb():
        display(Javascript("""
        jQuery("#%s").remove();
        """ % identifier))
    else:
        logger.debug("loading only works on Jupyter notebooks")<commit_msg>Add searching animation<commit_after># Copyright 2015 Novo Nordisk Foundation Center for Biosustainability, DTU.

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import absolute_import, print_function
from uuid import uuid4
from IPython.core.display import HTML, Javascript
from IPython.core.display import display

from cameo import util
import logging
import os


ASSETS = os.path.join(os.path.dirname(__file__), "assets")

SEARCHING_IMAGE_FILE = os.path.join(ASSETS, "searching.gif")
with open(SEARCHING_IMAGE_FILE, "rb") as f:
    SEARCHING_IMAGE = f.read().encode('base64').replace('\n', '')


LOADING_IMAGE_FILE = os.path.join(ASSETS, "searching.gif")
with open(SEARCHING_IMAGE_FILE, "rb") as f:
    LOADING_IMAGE = f.read().encode('base64').replace('\n', '')


logger = logging.getLogger(__name__)


def notice(message):
    if util.in_ipnb():
        display(HTML("<span>%s</span>" % message))
    else:
        print(message)


def bold(message):
    if util.in_ipnb():
        display(HTML("<strong>%s</strong>" % message))
    else:
        print("\033[1m" + message + "\033[0m")


def searching():
    if util.in_ipnb():
        identifier = str(uuid4())
        display(HTML("""
        <img class="loading" id="%s" style="margin:auto; text-align:center;" src="data:image/gif;base64,%s"/>
        """ % (identifier, SEARCHING_IMAGE)))
        return identifier
    else:
        logger.debug("loading only works on Jupyter notebooks")


def loading():
    if util.in_ipnb():
        identifier = str(uuid4())
        display(HTML("""
        <img class="loading" id="%s" style="margin:auto; text-align:center;" src="data:image/gif;base64,%s"/>
        """ % (identifier, LOADING_IMAGE)))
        return identifier
    else:
        logger.debug("loading only works on Jupyter notebooks")


def stop_loader(identifier):
    if util.in_ipnb():
        display(Javascript("""
        jQuery("#%s").remove();
        """ % identifier))
    else:
        logger.debug("loading only works on Jupyter notebooks")
{'fraction_non_alphanumeric': 0.12809640705199732, 'fraction_numerical': 0.010935059138585137, 'mean_word_length': 3.6542056074766354, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5283807', 'n_tokens_mistral': 1357, 'n_tokens_neox': 1312, 'n_words': 403}