2021-09-10 08:40:59 +00:00
|
|
|
import unittest
|
|
|
|
|
2021-10-12 15:44:55 +00:00
|
|
|
from conversion_utils.jos_msds_and_properties import Converter, Msd
|
2021-09-10 08:40:59 +00:00
|
|
|
|
|
|
|
class JosMsdToPropertiesTestCase(unittest.TestCase):
|
|
|
|
|
|
|
|
def setUp(self):
|
2021-09-29 22:22:43 +00:00
|
|
|
self.converter = Converter()
|
2021-09-10 08:40:59 +00:00
|
|
|
|
|
|
|
def test_en_en(self):
|
2021-09-10 13:52:11 +00:00
|
|
|
properties = self.converter.msd_to_properties(Msd('Ncfpd', 'en'), 'en')
|
2021-09-10 08:40:59 +00:00
|
|
|
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):
|
2021-09-10 13:52:11 +00:00
|
|
|
properties = self.converter.msd_to_properties(Msd('Ncfpd', 'en'), 'sl')
|
2021-09-10 08:40:59 +00:00
|
|
|
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):
|
2021-09-10 13:52:11 +00:00
|
|
|
properties = self.converter.msd_to_properties(Msd('Sozmd', 'sl'), 'en')
|
2021-09-10 08:40:59 +00:00
|
|
|
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):
|
2021-09-10 13:52:11 +00:00
|
|
|
properties = self.converter.msd_to_properties(Msd('Sozmd', 'sl'), 'sl')
|
2021-09-10 08:40:59 +00:00
|
|
|
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):
|
2021-09-10 13:52:11 +00:00
|
|
|
properties = self.converter.msd_to_properties(Msd('Pp2-sd--y', 'en'), 'sl', 'ti')
|
2021-09-10 08:40:59 +00:00
|
|
|
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')
|
2021-09-10 08:40:59 +00:00
|
|
|
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, {})
|
2021-09-10 08:40:59 +00:00
|
|
|
|
|
|
|
def test_featureless(self):
|
2021-09-10 14:27:57 +00:00
|
|
|
properties = self.converter.msd_to_properties(Msd('U', 'sl'), 'en')
|
2021-09-10 08:40:59 +00:00
|
|
|
self.assertEqual(properties.language, 'en')
|
2021-09-10 14:27:57 +00:00
|
|
|
self.assertEqual(properties.category, 'punctuation')
|
2021-09-10 08:40:59 +00:00
|
|
|
self.assertEqual(properties.lexeme_feature_map, {})
|
|
|
|
self.assertEqual(properties.form_feature_map, {})
|