<commit_before># encoding: utf-8
from lxml.html import fromstring
from lxml.etree import ParserError, XMLSyntaxError

# return unicoded text which HTML tags are removed
def text_content(html):
    try:
        return unicode(fromstring(html).text_content().strip())
    except ParserError, e:
        # asserted in case of being “</nav>” content
        return u''
    except XMLSyntaxError, e:
        return u''<commit_msg>fix FutureWarning: The behavior of this method will change in future versions. Use specific 'len(elem)' or 'elem is not None' test instead.<commit_after># encoding: utf-8
from lxml.html import fromstring
from lxml.etree import ParserError, XMLSyntaxError

# return unicoded text which HTML tags are removed
def text_content(html):
    try:
        dom = fromstring(html)
        if dom is not None:
            return unicode(dom.text_content().strip())
    except ParserError, e:
        # asserted in case of being “</nav>” content
        return u''
    except XMLSyntaxError, e:
        return u''
{'fraction_non_alphanumeric': 0.0847953216374269, 'fraction_numerical': 0.001949317738791423, 'mean_word_length': 3.279166666666667, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '4977899', 'n_tokens_mistral': 291, 'n_tokens_neox': 286, 'n_words': 111}