<commit_before><commit_msg>add tests for address to xml conversion in manual labeling<commit_after>import training
from training.manual_labeling import addr2XML
from lxml import etree
import unittest


class TestManualAddr2XML(unittest.TestCase) :

    def test_single_component(self) :

        test_input = [ ('Monroe', 'Component') ]
        expected_xml = '<AddressString><Component>Monroe</Component></AddressString>'

        assert etree.tostring( addr2XML(test_input) ) == expected_xml

    def test_two_components(self) :

        test_input = [ ('123', 'foo'), ('Monroe', 'bar') ]
        expected_xml = '<AddressString><foo>123</foo> <bar>Monroe</bar></AddressString>'

        assert etree.tostring( addr2XML(test_input) ) == expected_xml

    def test_multiple_components(self) :

        test_input = [ ('123', 'foo'), ('Monroe', 'bar'), ('St', 'foobar') ]
        expected_xml = '<AddressString><foo>123</foo> <bar>Monroe</bar> <foobar>St</foobar></AddressString>'

        assert etree.tostring( addr2XML(test_input) ) == expected_xml


if __name__ == '__main__' :
    unittest.main()    
{'fraction_non_alphanumeric': 0.14221014492753623, 'fraction_numerical': 0.015398550724637682, 'mean_word_length': 4.187793427230047, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 8}, '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': '7223296', 'n_tokens_mistral': 363, 'n_tokens_neox': 338, 'n_words': 69}