def test_slot_copy_changes_to_original_do_not_reflect_to_copy(self): slot = Slot(self.to_value, self.attributes, self.fact) copy = slot.copy() slot.attributes["new_key"] = "new_val" slot.value = LiteralSource("new literal") self.assertNotEqual(slot.value, copy.value) self.assertNotEqual(slot.attributes, copy.attributes)
def resolve_surface_form(self, registry: Registry, random: Generator, language: str, slot: Slot, entity: str, entity_type: str) -> None: if entity_type in ["NEWSPAPER_NAME", "NEWSPAPER"]: value = entity.replace("_", " ").capitalize() elif entity_type == "LANGUAGE": value = LANGUAGES.get(language, {}).get(entity) elif entity_type == "DATE": value = entity[:10] else: return # Was one of the matching things slot.value = lambda f: value
def test_slot_value_setter_updates_slot_type(self): slot = Slot(self.to_value) slot.value = FactFieldSource("a fake type") self.assertEqual(slot.slot_type, "a fake type")
def test_slot_value_setter(self): slot = Slot(self.to_value) slot.value = LiteralSource("another literal") self.assertEqual(slot.value, "another literal")