conversion_utils/tests/test_jos_msd_to_properties.py

58 lines
3.0 KiB
Python

import unittest
from conversion_utils.jos_msds_and_properties import Converter, Msd
class JosMsdToPropertiesTestCase(unittest.TestCase):
def setUp(self):
self.converter = Converter()
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'})
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'})
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')
self.assertEqual(properties.lexeme_feature_map, {'vrsta':'povratni', 'naslonskost':'klitična'})
self.assertEqual(properties.form_feature_map, {})
def test_featureless(self):
properties = self.converter.msd_to_properties(Msd('U', 'sl'), 'en')
self.assertEqual(properties.language, 'en')
self.assertEqual(properties.category, 'punctuation')
self.assertEqual(properties.lexeme_feature_map, {})
self.assertEqual(properties.form_feature_map, {})