conversion_utils/tests/test_jos_msd_to_properties.py

62 lines
3.2 KiB
Python
Raw Normal View History

import os.path
import unittest
2021-09-10 13:30:04 +00:00
from conversion_utils.jos_msds_and_properties import SpecificationsParser, Converter, Msd
class JosMsdToPropertiesTestCase(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)
def test_en_en(self):
properties = self.converter.msd_to_properties(Msd('Ncfpd', 'en'), 'en')
self.assertEqual(properties.language, 'en')
self.assertEqual(properties.category, 'noun')
self.assertEqual(properties.lexeme_feature_map, {'type':'common', 'gender':'feminine'})
self.assertEqual(properties.form_feature_map, {'number':'plural', 'case':'dative'})
def test_en_sl(self):
properties = self.converter.msd_to_properties(Msd('Ncfpd', 'en'), 'sl')
self.assertEqual(properties.language, 'sl')
self.assertEqual(properties.category, 'samostalnik')
self.assertEqual(properties.lexeme_feature_map, {'vrsta':'občno_ime', 'spol':'ženski'})
self.assertEqual(properties.form_feature_map, {'število':'množina', 'sklon':'dajalnik'})
def test_sl_en(self):
properties = self.converter.msd_to_properties(Msd('Sozmd', 'sl'), 'en')
self.assertEqual(properties.language, 'en')
self.assertEqual(properties.category, 'noun')
self.assertEqual(properties.lexeme_feature_map, {'type':'common', 'gender':'feminine'})
self.assertEqual(properties.form_feature_map, {'number':'plural', 'case':'dative'})
def test_sl_sl(self):
properties = self.converter.msd_to_properties(Msd('Sozmd', 'sl'), 'sl')
self.assertEqual(properties.language, 'sl')
self.assertEqual(properties.category, 'samostalnik')
self.assertEqual(properties.lexeme_feature_map, {'vrsta':'občno_ime', 'spol':'ženski'})
self.assertEqual(properties.form_feature_map, {'število':'množina', 'sklon':'dajalnik'})
2021-09-10 14:27:57 +00:00
def test_exception_feature_level(self):
properties = self.converter.msd_to_properties(Msd('Pp2-sd--y', 'en'), 'sl', 'ti')
self.assertEqual(properties.language, 'sl')
self.assertEqual(properties.category, 'zaimek')
self.assertEqual(properties.lexeme_feature_map, {'vrsta':'osebni', 'oseba':'druga'})
self.assertEqual(properties.form_feature_map, {'število':'ednina', 'sklon':'dajalnik', 'naslonskost':'klitična'})
2021-09-10 14:27:57 +00:00
def test_normal_feature_level(self):
properties = self.converter.msd_to_properties(Msd('Px------y', 'en'), 'sl', 'jst')
self.assertEqual(properties.language, 'sl')
self.assertEqual(properties.category, 'zaimek')
2021-09-10 14:27:57 +00:00
self.assertEqual(properties.lexeme_feature_map, {'vrsta':'povratni', 'naslonskost':'klitična'})
self.assertEqual(properties.form_feature_map, {})
def test_featureless(self):
2021-09-10 14:27:57 +00:00
properties = self.converter.msd_to_properties(Msd('U', 'sl'), 'en')
self.assertEqual(properties.language, 'en')
2021-09-10 14:27:57 +00:00
self.assertEqual(properties.category, 'punctuation')
self.assertEqual(properties.lexeme_feature_map, {})
self.assertEqual(properties.form_feature_map, {})