mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
Added extra translation for lighting
This commit is contained in:
parent
dae2087559
commit
f86a466f3d
4 changed files with 19 additions and 11 deletions
|
|
@ -34,14 +34,6 @@ def app():
|
|||
Currently, this application is just run on a local machine
|
||||
"""
|
||||
|
||||
# mainheat control todos:
|
||||
# [x]'System dalu wediGÇÖi chysylltu +ó defnyddio gwres cymunedol, rhaglennydd a TRVs'
|
||||
# [x]'System dalu wediGÇÖi chysylltu +ó defnyddio gwres cymunedol, TRVs'
|
||||
# [x] 'T+-ól un gyfradd, TRVs'
|
||||
# [x]'T+ól un gyfradd, rhaglennydd a TRVs'
|
||||
# [x]'T+ól un gyfradd, TRVs'
|
||||
# 'TRVs a falf osgoi'
|
||||
|
||||
cleaned_data = {}
|
||||
epc_directories = [entry for entry in EPC_DIRECTORY.iterdir() if entry.is_dir()]
|
||||
for directory in tqdm(epc_directories):
|
||||
|
|
|
|||
|
|
@ -24,15 +24,16 @@ class LightingAttributes:
|
|||
expression and perform the translation
|
||||
"""
|
||||
lel_match = re.search(r"goleuadau ynni-isel mewn (\d+)%? ogçör mannau gosod", self.description)
|
||||
lel_match2 = re.search(r"goleuadau ynni-isel mewn (\d+)%? o'r mannau gosod", self.description)
|
||||
|
||||
if lel_match:
|
||||
if lel_match is not None or lel_match2 is not None:
|
||||
|
||||
# Perform the actual translation
|
||||
percentage = lel_match.group(1)
|
||||
percentage = lel_match.group(1) if lel_match is not None else lel_match2.group(1)
|
||||
self.description = f"low energy lighting in {percentage}% of fixed outlets"
|
||||
else:
|
||||
translation = self.WELSH_TEXT.get(self.description)
|
||||
if translation:
|
||||
self.nodata = False
|
||||
self.description = translation
|
||||
|
||||
def process(self):
|
||||
|
|
|
|||
|
|
@ -35,4 +35,5 @@ test_cases = [
|
|||
{'original_description': 'Dim goleuadau ynni-isel', 'low_energy_proportion': 0},
|
||||
{'original_description': 'Excellent lighting efficiency', 'low_energy_proportion': 1},
|
||||
{'original_description': "Goleuadau ynni-isel ym mhob un o'r mannau gosod", 'low_energy_proportion': 1},
|
||||
{'original_description': "Goleuadau ynni-isel mewn 17% o'r mannau gosod", 'low_energy_proportion': 0.17},
|
||||
]
|
||||
|
|
|
|||
|
|
@ -56,3 +56,17 @@ class TestLightingAttributes:
|
|||
del expected_result["original_description"]
|
||||
result = LightingAttributes(test_case['original_description'], averages).process()
|
||||
assert sorted(result.items()) == sorted(expected_result.items())
|
||||
|
||||
def test_regex_translations(self):
|
||||
"""
|
||||
Some of the regex translations were falling through the net, though we were pulling out the percentages
|
||||
so we just make sure we're translating correctly
|
||||
"""
|
||||
|
||||
init1 = LightingAttributes("Goleuadau ynni-isel mewn 17% o'r mannau gosod", [])
|
||||
|
||||
assert init1.description == 'low energy lighting in 17% of fixed outlets'
|
||||
|
||||
init2 = LightingAttributes("Goleuadau ynni-isel mewn 60% oGÇÖr mannau gosod", [])
|
||||
|
||||
assert init2.description == 'low energy lighting in 60% of fixed outlets'
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue