Added support for translating msds or properties
This commit is contained in:
parent
a088025026
commit
6b63b9940e
|
@ -291,3 +291,9 @@ class Converter:
|
||||||
i += 1
|
i += 1
|
||||||
msd_code += position_map[position]
|
msd_code += position_map[position]
|
||||||
return Msd(msd_code, language)
|
return Msd(msd_code, language)
|
||||||
|
|
||||||
|
def translate_msd(self, msd, language):
|
||||||
|
return self.properties_to_msd(self.msd_to_properties(msd, language), language)
|
||||||
|
|
||||||
|
def translate_properties(self, properties, language):
|
||||||
|
return self.msd_to_properties(self.properties_to_msd(properties, language), language)
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import os.path
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from conversion_utils.jos_msds_and_properties import SpecificationsParser, Converter, Msd
|
from conversion_utils.jos_msds_and_properties import Converter, Msd
|
||||||
|
|
||||||
class JosMsdToPropertiesTestCase(unittest.TestCase):
|
class JosMsdToPropertiesTestCase(unittest.TestCase):
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import os.path
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from conversion_utils.jos_msds_and_properties import SpecificationsParser, Converter, Properties
|
from conversion_utils.jos_msds_and_properties import Converter, Properties
|
||||||
|
|
||||||
class JosPropertiesToMsdTestCase(unittest.TestCase):
|
class JosPropertiesToMsdTestCase(unittest.TestCase):
|
||||||
|
|
||||||
|
|
18
tests/test_jos_translate_msd.py
Normal file
18
tests/test_jos_translate_msd.py
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
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_sl(self):
|
||||||
|
msd_sl = self.converter.translate_msd(Msd('Ncfpd', 'en'), 'sl')
|
||||||
|
self.assertEqual(msd_sl.language, 'sl')
|
||||||
|
self.assertEqual(msd_sl.code, 'Sozmd')
|
||||||
|
|
||||||
|
def test_sl_en(self):
|
||||||
|
msd_en = self.converter.translate_msd(Msd('Sozmd', 'sl'), 'en')
|
||||||
|
self.assertEqual(msd_en.language, 'en')
|
||||||
|
self.assertEqual(msd_en.code, 'Ncfpd')
|
24
tests/test_jos_translate_properties.py
Normal file
24
tests/test_jos_translate_properties.py
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
from conversion_utils.jos_msds_and_properties import Converter, Properties
|
||||||
|
|
||||||
|
class JosPropertiesToMsdTestCase(unittest.TestCase):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
self.converter = Converter()
|
||||||
|
|
||||||
|
def test_en_sl(self):
|
||||||
|
properties_en = Properties('noun', {'type':'common', 'gender':'feminine'}, {'number':'dual', 'case':'dative'}, 'en')
|
||||||
|
properties_sl = self.converter.translate_properties(properties_en, 'sl')
|
||||||
|
self.assertEqual(properties_sl.category, 'samostalnik')
|
||||||
|
self.assertEqual(properties_sl.lexeme_feature_map, {'vrsta':'občno_ime', 'spol':'ženski'})
|
||||||
|
self.assertEqual(properties_sl.form_feature_map, {'število':'dvojina', 'sklon':'dajalnik'})
|
||||||
|
self.assertEqual(properties_sl.language, 'sl')
|
||||||
|
|
||||||
|
def test_sl_en(self):
|
||||||
|
properties_sl = Properties('samostalnik', {'vrsta':'občno_ime', 'spol':'ženski'}, {'število':'dvojina', 'sklon':'dajalnik'}, 'sl')
|
||||||
|
properties_en = self.converter.translate_properties(properties_sl, 'en')
|
||||||
|
self.assertEqual(properties_en.category, 'noun')
|
||||||
|
self.assertEqual(properties_en.lexeme_feature_map, {'type':'common', 'gender':'feminine'})
|
||||||
|
self.assertEqual(properties_en.form_feature_map, {'number':'dual', 'case':'dative'})
|
||||||
|
self.assertEqual(properties_en.language, 'en')
|
Loading…
Reference in New Issue
Block a user