<commit_before>from __future__ import absolute_import

import logging
import re
from html2text import config
import html2text
from fulltext.util import run, which

config.BODY_WIDTH = 0

LOGGER = logging.getLogger(__name__)
LOGGER.addHandler(logging.NullHandler())

EXTENSIONS = ('hwp',)

STRIP_EOL = re.compile(r'\s+')

if which('hwp5proc') is None:
    LOGGER.warning('CLI tool "hwp5proc" is required for .hwp backend. use "pip install pyhwp"')

def _cmd(path, **kwargs):
    cmd = ['hwp5proc', 'xml']
    cmd.extend([path])
    return cmd

def to_text (html):
    return STRIP_EOL.sub (' ', html2text.html2text(html))
 
def _get_path(path, **kwargs):
    return to_text (run(*_cmd(path, **kwargs)).decode('utf-8'))
    <commit_msg>remove generalizing spaces<commit_after>from __future__ import absolute_import

import logging
from html2text import config
import html2text
from fulltext.util import run, which

config.BODY_WIDTH = 0

LOGGER = logging.getLogger(__name__)
LOGGER.addHandler(logging.NullHandler())

EXTENSIONS = ('hwp',)


if which('hwp5proc') is None:
    LOGGER.warning('CLI tool "hwp5proc" is required for .hwp backend. use "pip install pyhwp"')


def _cmd(path, **kwargs):
    cmd = ['hwp5proc', 'xml']
    cmd.extend([path])
    return cmd


def to_text(html):
    return html2text.html2text(html)


def _get_path(path, **kwargs):
    return to_text(run(*_cmd(path, **kwargs)).decode('utf-8'))
{'fraction_non_alphanumeric': 0.13154172560113153, 'fraction_numerical': 0.01272984441301273, 'mean_word_length': 4.920502092050209, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '4522687', 'n_tokens_mistral': 502, 'n_tokens_neox': 494, 'n_words': 127}