from usaddress import parse
import training
from training.training import parseTrainingData

class TestSynthetic(object) :
    def test_Parser(self):

        test_file = 'training/test_data/synthetic_data_osm_data_xml.xml'

        for address_text, components in parseTrainingData(test_file) :
            _, labels_true = zip(*components)
            _, labels_pred = zip(*parse(address_text))
            yield equals, address_text, labels_pred, labels_true


def equals(addr, 
           labels_pred, 
           labels_true) :
    assert labels_pred == labels_true


@@ -461,112 +461,887 @@
 e%0A%0A%0A
-def equals(addr, %0A           labels_pred, %0A           labels_true) :%0A    assert labels_pred == labels_true%0A
+class TestUS50_2(object) :%0A    def test_Parser(self):%0A%0A        test_file = 'training/test_data/us50_test_tagged.xml'%0A%0A        for address_text, components in parseTrainingData(test_file) :%0A            _, labels_t = zip(*components)%0A            _, labels = zip(*parse(address_text))%0A            %0A            yield fuzzyEquals, address_text, labels_t, labels%0A%0A%0A%0Adef equals(addr, %0A           labels_pred, %0A           labels_true) :%0A    assert labels_pred == labels_true%0A%0Adef fuzzyEquals(addr, %0A           labels_true, %0A           labels_pred) :%0A    labels = %5B%5D%0A    fuzzy_labels = %5B%5D%0A    for label in labels_pred:%0A        if label == 'StreetNamePostType' or label == 'StreetNamePreDirectional':%0A            fuzzy_labels.append('StreetName')%0A        else:%0A            fuzzy_labels.append(label)%0A    for label in labels_true:%0A        labels.append(label)%0A    assert fuzzy_labels == labels
 %0A

add us50 addresses to tests