import os.path import unittest from conversion_utils.jos_msds_and_properties import SpecificationsParser, Converter, Properties class JosPropertiesToMsdTestCase(unittest.TestCase): def setUp(self): specifications_file_name = os.path.join(os.path.dirname(__file__), '../resources/msd-sl.spc.xml') parser = SpecificationsParser() specifications = parser.parse(specifications_file_name) self.converter = Converter(specifications) def test_en_en(self): msd = self.converter.properties_to_msd(Properties('noun', {'type':'common', 'gender':'feminine'}, {'number':'dual', 'case':'nominative'}, 'en'), 'en') self.assertEqual(msd.language, 'en') self.assertEqual(msd.code, 'Ncfdn') def test_en_sl(self): msd = self.converter.properties_to_msd(Properties('noun', {'type':'common', 'gender':'feminine'}, {'number':'dual', 'case':'nominative'}, 'en'), 'sl') self.assertEqual(msd.language, 'sl') self.assertEqual(msd.code, 'Sozdi') def test_sl_en(self): msd = self.converter.properties_to_msd(Properties('samostalnik', {'vrsta':'občno_ime', 'spol':'ženski'}, {'število':'dvojina', 'sklon':'imenovalnik'}, 'sl'), 'en') self.assertEqual(msd.language, 'en') self.assertEqual(msd.code, 'Ncfdn') def test_sl_sl(self): msd = self.converter.properties_to_msd(Properties('samostalnik', {'vrsta':'občno_ime', 'spol':'ženski'}, {'število':'dvojina', 'sklon':'imenovalnik'}, 'sl'), 'sl') self.assertEqual(msd.language, 'sl') self.assertEqual(msd.code, 'Sozdi') def test_exception_feature_level(self): msd = self.converter.properties_to_msd(Properties('zaimek', {'vrsta':'osebni', 'oseba':'druga'}, {'število':'ednina', 'sklon':'dajalnik', 'naslonskost':'klitična'}, 'sl'), 'en') self.assertEqual(msd.language, 'en') self.assertEqual(msd.code, 'Pp2-sd--y') def test_normal_feature_level(self): msd = self.converter.properties_to_msd(Properties('zaimek', {'vrsta':'osebni', 'oseba':'druga', 'naslonskost':'klitična'}, {'število':'množina', 'sklon':'dajalnik'}, 'sl'), 'en') self.assertEqual(msd.language, 'en') self.assertEqual(msd.code, 'Pp2-pd--y') def test_featureless(self): msd = self.converter.properties_to_msd(Properties('conjunction', {}, {}, 'en'), 'sl') self.assertEqual(msd.language, 'sl') self.assertEqual(msd.code, 'V')