<commit_before>import unittest
from scrapemark import scrape

class TestScrape(unittest.TestCase):
    
    def assertScrape(self, pattern, input, output, kwargs={}):
        return self.assertEqual(scrape(pattern, html=input, **kwargs), output)
    
    def test_basic(self):
        data = ['{{ foo }}', 'hello', {'foo':'hello'}]
        self.assertScrape(*data)
    
    def test_html(self):
        data = ['{{ foo|html }}', '<a>hello</a>', {'foo':'<a>hello</a>'}]
        self.assertScrape(*data)

    def test_multi(self):
        data = ['{*<a>{{ [foo] }}</a>*}', '<em><a>hello</a><a>hello2</a></em>', {'foo':['hello','hello2']}]
        self.assertScrape(*data)
    
    def test_standalone(self):
        data = ['<a value="" value2="{{ foo|float }}" />', '<a value="yay" value2="3.0" />', {'foo': 3.0}]
        self.assertScrape(*data)

    def adda(self, string):
        return string + "a"
    
    def test_adda(self):
        data = ['{{ foo|adda }}', '<a>hello</a>', {'foo':'helloa'}, {'processors':{'adda':self.adda}, 'verbose':True}]
        self.assertScrape(*data)

if __name__ == '__main__':
    unittest.main()<commit_msg>Test comments and entities<commit_after>import unittest
from scrapemark import scrape

class TestScrape(unittest.TestCase):

    def assertScrape(self, pattern, input, output, kwargs={}):
        return self.assertEqual(scrape(pattern, html=input, **kwargs), output)

    def test_basic(self):
        data = ['{{ foo }}', 'hello', {'foo':'hello'}]
        self.assertScrape(*data)

    def test_html(self):
        data = ['{{ foo|html }}', '<a>hello</a>', {'foo':'<a>hello</a>'}]
        self.assertScrape(*data)

    def test_multi(self):
        data = ['{*<a>{{ [foo] }}</a>*}', '<em><a>hello</a><a>hello2</a></em>', {'foo':['hello','hello2']}]
        self.assertScrape(*data)

    def test_standalone(self):
        data = ['<a value="" value2="{{ foo|float }}" />', '<a value="yay" value2="3.0" />', {'foo': 3.0}]
        self.assertScrape(*data)

    def adda(self, string):
        return string + "a"

    def test_adda(self):
        data = ['{{ foo|adda }}', '<a>hello</a>', {'foo':'helloa'}, {'processors':{'adda':self.adda}, 'verbose':True}]
        self.assertScrape(*data)

    def test_comments(self):
        data = ['{# comment #}', '', {}]
        self.assertScrape(*data)

    def test_entity(self):
        data = ['{{ foo }}', '&mdash;', {'foo':u'\u2014'}]
        self.assertScrape(*data)

if __name__ == '__main__':
    unittest.main()

{'fraction_non_alphanumeric': 0.22905027932960895, 'fraction_numerical': 0.007980845969672785, 'mean_word_length': 3.3075601374570445, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 35, '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': '149214', 'n_tokens_mistral': 898, 'n_tokens_neox': 864, 'n_words': 162}