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