def test_get_undictionaried_words(self): word_1 = words.Word.create_test_word(type=r.WORD_TYPE.NOUN, prefix='w-', properties=words.Properties( r.GENDER.FEMININE, r.ANIMALITY.INANIMATE, r.NUMBER.PLURAL)) word_2 = words.Word.create_test_word(type=r.WORD_TYPE.NOUN, prefix='x-', properties=words.Properties( r.GENDER.FEMININE, r.ANIMALITY.INANIMATE)) word_3 = words.Word.create_test_word(type=r.WORD_TYPE.NOUN, prefix='y-', properties=words.Properties( r.GENDER.FEMININE, r.ANIMALITY.INANIMATE, r.NUMBER.PLURAL)) dictionary = Dictionary() dictionary.add_word(word_1) dictionary.add_word(word_2) dictionary.add_word(word_3) TEXT = '[external_1|загл] 1 [x-нс,ед,тв|external_2|буд] 2 [слово|тв,ед] [бла-бла]' template = templates.Template() template.parse(TEXT, externals=['external_1', 'external_2']) self.assertEqual( template.get_undictionaried_words( externals=['external_1', 'external_2'], dictionary=dictionary), ['слово', 'бла-бла'])
def test_form(self): form = words.WordForm( word=self.word, properties=words.Properties(r.NUMBER.PLURAL), form_properties=words.Properties(r.NUMBER.PLURAL, r.CASE.DATIVE), ) self.assertEqual(form.form, 'w-нс,мн,дт')
def test_parse(self): TEXT = '[external_1|загл] 1 [ед3|external_2|буд] 2 [external_2|тв,ед]' template = templates.Template() template.parse(TEXT, externals=['external_1', 'external_2']) self.assertEqual(template.template, '%s 1 %s 2 %s') self.assertEqual(len(template._substitutions), 3) substitution = template._substitutions[0] self.assertEqual(substitution.id, 'external_1') self.assertEqual(substitution.dependencies, [words.Properties(r.WORD_CASE.UPPER)]) substitution = template._substitutions[1] self.assertEqual(substitution.id, 'ед3') self.assertEqual( substitution.dependencies, ['external_2', words.Properties(r.TIME.FUTURE)]) substitution = template._substitutions[2] self.assertEqual(substitution.id, 'external_2') self.assertEqual( substitution.dependencies, [words.Properties(r.CASE.INSTRUMENTAL, r.NUMBER.SINGULAR)])
def test_noun_integer__semantic_dependency(self): TESTS = { (r.INTEGER_FORM.SINGULAR, ): (r.NOUN_FORM.NORMAL, r.INTEGER_FORM.SINGULAR, r.NUMBER.SINGULAR), (r.INTEGER_FORM.DUAL, r.CASE.NOMINATIVE): (r.NOUN_FORM.NORMAL, r.INTEGER_FORM.DUAL, r.NUMBER.PLURAL, r.CASE.NOMINATIVE), (r.INTEGER_FORM.DUAL, r.CASE.DATIVE): (r.NOUN_FORM.NORMAL, r.INTEGER_FORM.DUAL, r.NUMBER.PLURAL, r.CASE.DATIVE), (r.INTEGER_FORM.DUAL, r.CASE.ACCUSATIVE, r.ANIMALITY.ANIMATE): (r.NOUN_FORM.NORMAL, r.INTEGER_FORM.DUAL, r.NUMBER.PLURAL, r.CASE.ACCUSATIVE, r.ANIMALITY.ANIMATE), (r.INTEGER_FORM.DUAL, r.CASE.ACCUSATIVE, r.ANIMALITY.INANIMATE): (r.NOUN_FORM.NORMAL, r.INTEGER_FORM.DUAL, r.NUMBER.PLURAL, r.CASE.ACCUSATIVE, r.ANIMALITY.INANIMATE), (r.INTEGER_FORM.COMPOSITE_DUAL, r.CASE.NOMINATIVE): (r.NOUN_FORM.NORMAL, r.INTEGER_FORM.COMPOSITE_DUAL, r.NUMBER.PLURAL, r.CASE.NOMINATIVE), (r.INTEGER_FORM.COMPOSITE_DUAL, r.CASE.DATIVE): (r.NOUN_FORM.NORMAL, r.INTEGER_FORM.COMPOSITE_DUAL, r.NUMBER.PLURAL, r.CASE.DATIVE), (r.INTEGER_FORM.COMPOSITE_DUAL, r.CASE.ACCUSATIVE, r.ANIMALITY.ANIMATE): (r.NOUN_FORM.NORMAL, r.INTEGER_FORM.COMPOSITE_DUAL, r.NUMBER.PLURAL, r.CASE.ACCUSATIVE, r.ANIMALITY.ANIMATE), (r.INTEGER_FORM.COMPOSITE_DUAL, r.CASE.ACCUSATIVE, r.ANIMALITY.INANIMATE): (r.NOUN_FORM.NORMAL, r.INTEGER_FORM.COMPOSITE_DUAL, r.NUMBER.PLURAL, r.CASE.ACCUSATIVE, r.ANIMALITY.INANIMATE), (r.INTEGER_FORM.PLURAL, r.CASE.NOMINATIVE): (r.NOUN_FORM.NORMAL, r.INTEGER_FORM.PLURAL, r.NUMBER.PLURAL, r.CASE.NOMINATIVE), (r.INTEGER_FORM.PLURAL, r.CASE.DATIVE): (r.NOUN_FORM.NORMAL, r.INTEGER_FORM.PLURAL, r.NUMBER.PLURAL, r.CASE.DATIVE), (r.INTEGER_FORM.PLURAL, r.CASE.ACCUSATIVE, r.ANIMALITY.ANIMATE): (r.NOUN_FORM.NORMAL, r.INTEGER_FORM.PLURAL, r.NUMBER.PLURAL, r.CASE.ACCUSATIVE, r.ANIMALITY.ANIMATE), (r.INTEGER_FORM.PLURAL, r.CASE.ACCUSATIVE, r.ANIMALITY.INANIMATE): (r.NOUN_FORM.NORMAL, r.INTEGER_FORM.PLURAL, r.NUMBER.PLURAL, r.CASE.ACCUSATIVE, r.ANIMALITY.INANIMATE), (r.INTEGER_FORM.MIL_BIL, r.CASE.NOMINATIVE): (r.NOUN_FORM.NORMAL, r.INTEGER_FORM.MIL_BIL, r.NUMBER.PLURAL, r.CASE.NOMINATIVE), (r.INTEGER_FORM.MIL_BIL, r.CASE.DATIVE): (r.NOUN_FORM.NORMAL, r.INTEGER_FORM.MIL_BIL, r.NUMBER.PLURAL, r.CASE.DATIVE), (r.INTEGER_FORM.MIL_BIL, r.CASE.ACCUSATIVE, r.ANIMALITY.ANIMATE): (r.NOUN_FORM.NORMAL, r.INTEGER_FORM.MIL_BIL, r.NUMBER.PLURAL, r.CASE.ACCUSATIVE, r.ANIMALITY.ANIMATE), (r.INTEGER_FORM.MIL_BIL, r.CASE.ACCUSATIVE, r.ANIMALITY.INANIMATE): (r.NOUN_FORM.NORMAL, r.INTEGER_FORM.MIL_BIL, r.NUMBER.PLURAL, r.CASE.ACCUSATIVE, r.ANIMALITY.INANIMATE) } for test, result in TESTS.items(): self.assertEqual( transformators._noun_integer( words.Properties(r.DEPENDENCY_MODE.SEMANTIC, *test)), words.Properties(r.DEPENDENCY_MODE.SEMANTIC, *result))
def compress(self, data_list): fields = get_fields(self.word_type) keys = {key: i for i, key in enumerate(sorted(fields.keys()))} word_forms = [ data_list[keys['%s_%d' % (WORD_FIELD_PREFIX, i)]] for i in range(len(utg_data.INVERTED_WORDS_CACHES[self.word_type])) ] properties = utg_words.Properties() for static_property, required in self.word_type.properties.items(): value = data_list[keys['%s_%s' % (WORD_FIELD_PREFIX, static_property.__name__)]] if not value: continue properties = utg_words.Properties(properties, value) word = utg_words.Word(type=self.word_type, forms=word_forms, properties=properties) word.autofill_missed_forms() return word
def test_noun_integer(self): TESTS = { (r.INTEGER_FORM.SINGULAR, ): (r.NOUN_FORM.NORMAL, r.INTEGER_FORM.SINGULAR, r.NUMBER.SINGULAR), (r.INTEGER_FORM.DUAL, r.CASE.NOMINATIVE): (r.NOUN_FORM.NORMAL, r.INTEGER_FORM.DUAL, r.NUMBER.SINGULAR, r.CASE.GENITIVE), (r.INTEGER_FORM.DUAL, r.CASE.DATIVE): (r.NOUN_FORM.COUNTABLE, r.INTEGER_FORM.DUAL, r.NUMBER.PLURAL, r.CASE.DATIVE), (r.INTEGER_FORM.DUAL, r.CASE.ACCUSATIVE, r.ANIMALITY.ANIMATE): (r.NOUN_FORM.COUNTABLE, r.INTEGER_FORM.DUAL, r.NUMBER.PLURAL, r.CASE.ACCUSATIVE, r.ANIMALITY.ANIMATE), (r.INTEGER_FORM.DUAL, r.CASE.ACCUSATIVE, r.ANIMALITY.INANIMATE): (r.NOUN_FORM.NORMAL, r.INTEGER_FORM.DUAL, r.NUMBER.SINGULAR, r.CASE.GENITIVE, r.ANIMALITY.INANIMATE), (r.INTEGER_FORM.COMPOSITE_DUAL, r.CASE.NOMINATIVE): (r.NOUN_FORM.NORMAL, r.INTEGER_FORM.COMPOSITE_DUAL, r.NUMBER.SINGULAR, r.CASE.GENITIVE), (r.INTEGER_FORM.COMPOSITE_DUAL, r.CASE.DATIVE): (r.NOUN_FORM.COUNTABLE, r.INTEGER_FORM.COMPOSITE_DUAL, r.NUMBER.PLURAL, r.CASE.DATIVE), (r.INTEGER_FORM.COMPOSITE_DUAL, r.CASE.ACCUSATIVE, r.ANIMALITY.ANIMATE): (r.NOUN_FORM.NORMAL, r.INTEGER_FORM.COMPOSITE_DUAL, r.NUMBER.SINGULAR, r.CASE.GENITIVE, r.ANIMALITY.ANIMATE), (r.INTEGER_FORM.COMPOSITE_DUAL, r.CASE.ACCUSATIVE, r.ANIMALITY.INANIMATE): (r.NOUN_FORM.NORMAL, r.INTEGER_FORM.COMPOSITE_DUAL, r.NUMBER.SINGULAR, r.CASE.GENITIVE, r.ANIMALITY.INANIMATE), (r.INTEGER_FORM.PLURAL, r.CASE.NOMINATIVE): (r.NOUN_FORM.COUNTABLE, r.INTEGER_FORM.PLURAL, r.NUMBER.PLURAL, r.CASE.GENITIVE), (r.INTEGER_FORM.PLURAL, r.CASE.DATIVE): (r.NOUN_FORM.COUNTABLE, r.INTEGER_FORM.PLURAL, r.NUMBER.PLURAL, r.CASE.DATIVE), (r.INTEGER_FORM.PLURAL, r.CASE.ACCUSATIVE, r.ANIMALITY.ANIMATE): (r.NOUN_FORM.COUNTABLE, r.INTEGER_FORM.PLURAL, r.NUMBER.PLURAL, r.CASE.GENITIVE, r.ANIMALITY.ANIMATE), (r.INTEGER_FORM.PLURAL, r.CASE.ACCUSATIVE, r.ANIMALITY.INANIMATE): (r.NOUN_FORM.COUNTABLE, r.INTEGER_FORM.PLURAL, r.NUMBER.PLURAL, r.CASE.GENITIVE, r.ANIMALITY.INANIMATE), (r.INTEGER_FORM.MIL_BIL, r.CASE.NOMINATIVE): (r.NOUN_FORM.COUNTABLE, r.INTEGER_FORM.MIL_BIL, r.NUMBER.PLURAL, r.CASE.GENITIVE), (r.INTEGER_FORM.MIL_BIL, r.CASE.DATIVE): (r.NOUN_FORM.COUNTABLE, r.INTEGER_FORM.MIL_BIL, r.NUMBER.PLURAL, r.CASE.GENITIVE), (r.INTEGER_FORM.MIL_BIL, r.CASE.ACCUSATIVE, r.ANIMALITY.ANIMATE): (r.NOUN_FORM.COUNTABLE, r.INTEGER_FORM.MIL_BIL, r.NUMBER.PLURAL, r.CASE.GENITIVE, r.ANIMALITY.ANIMATE), (r.INTEGER_FORM.MIL_BIL, r.CASE.ACCUSATIVE, r.ANIMALITY.INANIMATE): (r.NOUN_FORM.COUNTABLE, r.INTEGER_FORM.MIL_BIL, r.NUMBER.PLURAL, r.CASE.GENITIVE, r.ANIMALITY.INANIMATE) } for test, result in TESTS.items(): self.assertEqual( transformators._noun_integer(words.Properties(*test)), words.Properties(*result))
def test_parse(self): substitution = templates.Substitution.parse( variable='[bla-bla|external_1|дт|external_2|вн,личн]', externals=['bla-bla', 'external_1', 'external_2']) self.assertEqual(substitution.id, 'bla-bla') self.assertEqual(substitution.dependencies, [ 'external_1', words.Properties(r.CASE.DATIVE), 'external_2', words.Properties(r.CASE.ACCUSATIVE, r.PRONOUN_CATEGORY.PERSONAL) ])
def name_from(self, with_url=True): if with_url: return '<a href="%s" target="_blank">%s</a> — %s из %s' % ( self.url, self.name, self.race.text, self.place.utg_name.form( utg_words.Properties(utg_relations.CASE.GENITIVE))) return '%s — %s из %s' % (self.name, self.race.text, self.place.utg_name.form( utg_words.Properties( utg_relations.CASE.GENITIVE)))
def test_merge_properties__externals(self): substitution = templates.Substitution.parse( variable='[bla-bla|external]', externals=['external']) word = words.Word.create_test_word(type=r.WORD_TYPE.NOUN, prefix='w-', properties=words.Properties( r.CASE.DATIVE, r.GRADE.COMPARATIVE)) self.assertEqual( substitution._list_propeties(externals={'external': word}), ([words.Properties(r.CASE.DATIVE, r.GRADE.COMPARATIVE)], [word]))
def text_on_road(self, place_from_id, place_to_id): self.sync() key = (place_from_id, place_to_id) if key not in self._position_on_road_cache: self._position_on_road_cache[key] = u'дорога из %s в %s' % ( places_storage.places[place_from_id].utg_name.form( utg_words.Properties(utg_relations.CASE.GENITIVE)), places_storage.places[place_to_id].utg_name.form( utg_words.Properties(utg_relations.CASE.ACCUSATIVE))) return self._position_on_road_cache[key]
def test_eq(self): properties_1 = words.Properties(r.CASE.DATIVE, r.NUMBER.PLURAL, r.PERSON.SECOND) properties_2 = words.Properties(r.CASE.DATIVE, r.NUMBER.PLURAL, r.PERSON.SECOND) self.assertEqual(properties_1, properties_2) properties_3 = words.Properties(properties_2, r.NUMBER.SINGULAR) self.assertNotEqual(properties_1, properties_3)
def test_init(self): forms = [ 'x%d' % i for i in range(len(data.WORDS_CACHES[r.WORD_TYPE.VERB])) ] word = words.Word(type=r.WORD_TYPE.VERB, forms=forms, properties=words.Properties(r.CASE.DATIVE, r.TIME.FUTURE)) self.assertTrue(word.type.is_VERB) self.assertEqual(word.forms, forms) self.assertEqual(word.properties, words.Properties(r.CASE.DATIVE, r.TIME.FUTURE))
def test_form__optional_property(self): word = words.Word.create_test_word(r.WORD_TYPE.NOUN, properties=words.Properties( r.GENDER.FEMININE, r.ANIMALITY.INANIMATE, r.NUMBER.PLURAL)) self.assertEqual(word.form(words.Properties(r.CASE.DATIVE)), 'w-нс,мн,дт') self.assertEqual( word.form(words.Properties(r.CASE.DATIVE, r.NUMBER.PLURAL)), 'w-нс,мн,дт') self.assertEqual( word.form(words.Properties(r.CASE.DATIVE, r.TIME.FUTURE)), 'w-нс,мн,дт') word = words.Word.create_test_word(r.WORD_TYPE.NOUN, properties=words.Properties( r.GENDER.FEMININE, r.ANIMALITY.INANIMATE, r.NUMBER.SINGULAR)) self.assertEqual(word.form(words.Properties(r.CASE.DATIVE)), 'w-нс,ед,дт') self.assertEqual( word.form(words.Properties(r.CASE.DATIVE, r.NUMBER.PLURAL)), 'w-нс,ед,дт') self.assertEqual( word.form(words.Properties(r.CASE.DATIVE, r.TIME.FUTURE)), 'w-нс,ед,дт')
def test_construct(self): properties = words.Properties(r.CASE.DATIVE, r.NUMBER.PLURAL, r.PERSON.SECOND) self.assertTrue(properties._data[r.CASE].is_DATIVE) self.assertTrue(properties._data[r.NUMBER].is_PLURAL) self.assertTrue(properties._data[r.PERSON].is_SECOND)
def get_form(self, key): cache = utg_data.WORDS_CACHES[self.type] if key not in cache: return u'' form = self.word.form(words.Properties(*key)) other_form = self.other_version.form(words.Properties( *key)) if self.other_version else None if other_form is None or form == other_form: html = form else: html = u'<span class="changed-word" rel="tooltip" title="в копии: %s">%s</span>' % ( other_form, form) return jinja2.Markup(html)
def get_test_name(self, name='', gender=relations.GENDER.MASCULINE): name = utg_words.Word.create_test_word( type=utg_relations.WORD_TYPE.NOUN, prefix=('%s-' % name) if name else 't-', properties=utg_words.Properties(utg_relations.ANIMALITY.ANIMATE, gender.utg_id)) return name
def get_fast_name(self, name, gender=relations.GENDER.MASCULINE): word = utg_words.Word.create_test_word( type=utg_relations.WORD_TYPE.NOUN, properties=utg_words.Properties(utg_relations.ANIMALITY.ANIMATE, gender.utg_id)) word.forms = [name] * len(word.forms) return word
def job_effect_kwargs(self, place): return {'actor_type': 'place', 'actor_name': 'Проект города {name}'.format(name=place.utg_name.form(utg_words.Properties(utg_relations.CASE.GENITIVE))), 'person': None, 'place': place, 'positive_heroes': self.inner_positive_heroes, 'negative_heroes': self.inner_negative_heroes, 'job_power': place.get_job_power() }
def test_correct_autofill_of_noun_countable_form(self): word = utg_words.Word.create_test_word(utg_relations.WORD_TYPE.NOUN) for key, index in utg_data.WORDS_CACHES[word.type].items(): if utg_relations.NOUN_FORM.COUNTABLE in key: word.forms[index] = '' word.autofill_missed_forms() for key, index in utg_data.WORDS_CACHES[word.type].items(): if utg_relations.NOUN_FORM.COUNTABLE in key: modified_key = list( property if property != utg_relations.NOUN_FORM.COUNTABLE else utg_relations.NOUN_FORM.NORMAL for property in key) self.assertEqual( word.form(utg_words.Properties(*key)), word.form(utg_words.Properties(*modified_key)))
def test_update__empty(self): properties = words.Properties(r.CASE.DATIVE, r.NUMBER.PLURAL, r.PERSON.SECOND) old_data = copy.copy(properties._data) properties._update() self.assertEqual(old_data, properties._data)
def test_noun_integer__unknown_integer_form(self): self.assertRaises( exceptions.UnknownIntegerFormError, transformators._noun_integer, words.Properties( mock.Mock(_relation=r.INTEGER_FORM, **{ 'is_%s' % form.name: False for form in r.INTEGER_FORM.records })))
def test_update(self): properties = words.Properties(r.CASE.DATIVE, r.NUMBER.PLURAL, r.PERSON.SECOND) properties._update(r.NUMBER.SINGULAR, r.TIME.FUTURE) self.assertTrue(properties._data[r.CASE].is_DATIVE) self.assertTrue(properties._data[r.NUMBER].is_SINGULAR) self.assertTrue(properties._data[r.PERSON].is_SECOND) self.assertTrue(properties._data[r.TIME].is_FUTURE)
def text_near_place(self, place_id): self.sync() if place_id not in self._position_near_place_cache: self._position_near_place_cache[ place_id] = u'окрестности %s' % places_storage.places[ place_id].utg_name.form( utg_words.Properties(utg_relations.CASE.GENITIVE)) return self._position_near_place_cache[place_id]
def test_starts_with_consonant_cluster(self): word = words.Word(type=r.WORD_TYPE.NOUN, forms=[ 'сон', 'сна', 'сну', 'сон', 'сном', 'сне', 'сны', 'снов', 'снам', 'сны', 'снами', 'снах', 'сны', 'снов', 'снам', 'сны', 'снами', 'снах' ], properties=words.Properties(r.GENDER.MASCULINE, r.ANIMALITY.INANIMATE)) form = words.WordForm(word=word, properties=words.Properties( r.CASE.NOMINATIVE)) # сон self.assertFalse(form.starts_with_consonant_cluster) form = words.WordForm(word=word, properties=words.Properties( r.CASE.DATIVE)) # сну self.assertTrue(form.starts_with_consonant_cluster)
def get_fast_name(self, name, gender=relations.GENDER.MASCULINE): from utg import words as utg_words from utg import relations as utg_relations name = utg_words.Word.create_test_word( type=utg_relations.WORD_TYPE.NOUN, properties=utg_words.Properties(utg_relations.ANIMALITY.ANIMATE, gender.utg_id)) name.forms = [name] * len(name.forms) return name
def get_name(self, race, gender): name_forms = self._get_name(race, gender).get_forms_for(gender=gender.pynames_id, language=self.language) name_forms += ['']*6 name = utg_words.Word(type=utg_relations.WORD_TYPE.NOUN, forms=name_forms, properties=utg_words.Properties(utg_relations.ANIMALITY.ANIMATE, gender.utg_id)) name.autofill_missed_forms() return name
def test_substitute__percent_symbol(self): TEXT = '[external_1|загл] 1 [w-нс,ед,тв|external_2|буд] 2% [external_2|тв,ед]' # TEXT = u'[external_2|тв,ед]' word_1 = words.Word.create_test_word(type=r.WORD_TYPE.NOUN, prefix='w-', properties=words.Properties( r.GENDER.FEMININE, r.ANIMALITY.INANIMATE)) word_2 = words.Word.create_test_word(type=r.WORD_TYPE.NOUN, prefix='x-', properties=words.Properties( r.GENDER.FEMININE, r.ANIMALITY.INANIMATE)) word_3 = words.Word.create_test_word(type=r.WORD_TYPE.NOUN, prefix='y-', properties=words.Properties( r.GENDER.FEMININE, r.ANIMALITY.INANIMATE, r.NUMBER.PLURAL)) dictionary = Dictionary() dictionary.add_word(word_1) dictionary.add_word(word_2) dictionary.add_word(word_3) template = templates.Template() template.parse(TEXT, externals=['external_1', 'external_2']) result = template.substitute(externals={ 'external_1': dictionary.get_word('x-нс,ед,им'), 'external_2': dictionary.get_word('y-нс,мн,им'), }, dictionary=dictionary) self.assertEqual(result, 'X-нс,ед,им 1 w-нс,мн,им 2% y-нс,мн,тв')
def test_get(self): properties = words.Properties(r.CASE.DATIVE, r.NUMBER.PLURAL, r.PERSON.SECOND) for relation in logic.get_property_relations(): if relation == r.WORD_TYPE: self.assertEqual(properties.get(relation), None) elif relation in properties._data: self.assertEqual(properties.get(relation), properties._data[relation]) else: self.assertEqual(properties.get(relation), relation.records[0])
def test_get_word_restrictions(self): normal_noun = utg_words.WordForm( utg_words.Word.create_test_word(type=utg_relations.WORD_TYPE.NOUN, prefix='w-1-', only_required=True)) singular_noun = utg_words.WordForm( utg_words.Word.create_test_word( type=utg_relations.WORD_TYPE.NOUN, prefix='w-1-', only_required=True, properties=utg_words.Properties( utg_relations.NUMBER.SINGULAR))) plural_noun = utg_words.WordForm( utg_words.Word.create_test_word(type=utg_relations.WORD_TYPE.NOUN, prefix='w-1-', only_required=True, properties=utg_words.Properties( utg_relations.NUMBER.PLURAL))) self.assertEqual( logic.get_word_restrictions('x', normal_noun), (('x', storage.restrictions_storage.get_restriction( relations.TEMPLATE_RESTRICTION_GROUP.PLURAL_FORM, relations.WORD_HAS_PLURAL_FORM.HAS.value).id), )) self.assertEqual( logic.get_word_restrictions('x', singular_noun), (('x', storage.restrictions_storage.get_restriction( relations.TEMPLATE_RESTRICTION_GROUP.PLURAL_FORM, relations.WORD_HAS_PLURAL_FORM.HAS_NO.value).id), )) self.assertEqual( logic.get_word_restrictions('x', plural_noun), (('x', storage.restrictions_storage.get_restriction( relations.TEMPLATE_RESTRICTION_GROUP.PLURAL_FORM, relations.WORD_HAS_PLURAL_FORM.HAS.value).id), ))
def parse_properties(cls, text): properties = [] for slug in text.split(','): slug.strip() if not slug: continue if slug not in data.VERBOSE_TO_PROPERTIES: raise exceptions.UnknownVerboseIdError(verbose_id=slug) properties.append(data.VERBOSE_TO_PROPERTIES[slug]) return words.Properties(*properties)