From d4499318176f4a81293e4280b2da36bae7b146f0 Mon Sep 17 00:00:00 2001 From: Siavash Mollayi Date: Tue, 30 Nov 2021 16:46:09 +0330 Subject: [PATCH] remove extra comments and imports fix license year --- lingua_franca/lang/common_data_az.py | 5 ++--- lingua_franca/lang/format_az.py | 6 +----- lingua_franca/lang/parse_az.py | 12 ++++-------- test/test_format_az.py | 22 ++-------------------- test/test_parse_az.py | 2 +- 5 files changed, 10 insertions(+), 37 deletions(-) diff --git a/lingua_franca/lang/common_data_az.py b/lingua_franca/lang/common_data_az.py index c4a8c82f..5a96e130 100644 --- a/lingua_franca/lang/common_data_az.py +++ b/lingua_franca/lang/common_data_az.py @@ -1,5 +1,5 @@ # -# Copyright 2017 Mycroft AI Inc. +# Copyright 2021 Mycroft AI Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,7 +15,6 @@ # from collections import OrderedDict from .parse_common import invert_dict -# from parse_common import invert_dict _FUNCTION_NOT_IMPLEMENTED_WARNING = "Tələb olunan funksiya Azərbaycan dilində yerinə yetirilmir." @@ -180,7 +179,7 @@ # negate next number (-2 = 0 - 2) _NEGATIVES_AZ = {"mənfi", "minus"} -# sum the next number (twenty two = 20 + 2) +# sum the next number (iyirmi iki = 20 + 2) _SUMS_AZ = {'on', '10', 'iyirmi', '20', 'otuz', '30', 'qırx', '40', 'əlli', '50', 'altmış', '60', 'yetmiş', '70', 'səksən', '80', 'doxsan', '90'} diff --git a/lingua_franca/lang/format_az.py b/lingua_franca/lang/format_az.py index 0a97e907..ea4a4f9f 100644 --- a/lingua_franca/lang/format_az.py +++ b/lingua_franca/lang/format_az.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright 2017 Mycroft AI Inc. +# Copyright 2021 Mycroft AI Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -317,10 +317,6 @@ def nice_time_az(dt, speech=True, use_24hour=False, use_ampm=False): speak += pronounce_number_az(int(string[3:5])) return speak else: - # if dt.hour == 0 and dt.minute == 0: - # return "gecə yarısı" - # elif dt.hour == 12 and dt.minute == 0: - # return "günorta" hour = dt.hour % 12 or 12 # 12 hour clock and 0 is spoken as 12 next_hour = (dt.hour + 1) % 12 or 12 diff --git a/lingua_franca/lang/parse_az.py b/lingua_franca/lang/parse_az.py index cd2b143d..4fc46612 100644 --- a/lingua_franca/lang/parse_az.py +++ b/lingua_franca/lang/parse_az.py @@ -23,9 +23,8 @@ from lingua_franca.time import now_local from lingua_franca.lang.parse_common import is_numeric, look_for_fractions, \ invert_dict, ReplaceableNumber, partition_list, tokenize, Token, Normalizer -from lingua_franca.lang.common_data_az import _NUM_STRING_AZ, \ - _LONG_ORDINAL_AZ, _LONG_SCALE_AZ, _SHORT_SCALE_AZ, _SHORT_ORDINAL_AZ, \ - _NEGATIVES_AZ, _SUMS_AZ, _MULTIPLIES_LONG_SCALE_AZ, \ +from lingua_franca.lang.common_data_az import _LONG_SCALE_AZ, \ + _SHORT_SCALE_AZ, _NEGATIVES_AZ, _SUMS_AZ, _MULTIPLIES_LONG_SCALE_AZ, \ _MULTIPLIES_SHORT_SCALE_AZ, _FRACTION_MARKER_AZ, _DECIMAL_MARKER_AZ, \ _STRING_NUM_AZ, _STRING_SHORT_ORDINAL_AZ, _STRING_LONG_ORDINAL_AZ, \ _FRACTION_STRING_AZ, _generate_plurals_az, _SPOKEN_EXTRA_NUM_AZ @@ -34,9 +33,6 @@ import json from lingua_franca.internal import resolve_resource_file -def _remove_ak(): - pass - def _convert_words_to_numbers_az(text, short_scale=True, ordinals=False): """ Convert words in a string into their equivalent numbers. @@ -907,7 +903,7 @@ def date_found(): words[start - 1] = "" found = True daySpecified = True - # print(words) + # parse time hrOffset = 0 minOffset = 0 @@ -1106,7 +1102,7 @@ def date_found(): extractedDate = anchorDate.replace(microsecond=0) if datestr != "": - # date included an explicit date, e.g. "june 5" or "june 2, 2017" + # date included an explicit date, e.g. "iyun 5" or "iyun 2, 2017" try: temp = datetime.strptime(datestr, "%B %d") except ValueError: diff --git a/test/test_format_az.py b/test/test_format_az.py index 6198da50..40036ef8 100644 --- a/test/test_format_az.py +++ b/test/test_format_az.py @@ -1,5 +1,5 @@ # -# Copyright 2017 Mycroft AI Inc. +# Copyright 2021 Mycroft AI Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -21,8 +21,6 @@ import sys from pathlib import Path -# TODO either write a getter for lingua_franca.internal._SUPPORTED_LANGUAGES, -# or make it public somehow from lingua_franca import load_languages, unload_languages, set_default_lang, \ get_primary_lang_code, get_active_langs, get_supported_langs from lingua_franca.internal import UnsupportedLanguageError @@ -218,17 +216,6 @@ def test_auto_scientific_notation(self): self.assertEqual( pronounce_number(1.1e-150), "bir nöqtə bir vurulsun " "on üstü mənfi yüz əlli") - # value is platform dependent so better not use in tests? - # self.assertEqual( - # pronounce_number(sys.float_info.min), "iki nöqtə iki iki times " - # "on to the power of " - # "mənfi üç yüz " - # "və səkkiz") - # self.assertEqual( - # pronounce_number(sys.float_info.max), "bir nöqtə yeddi doqquz " - # "times on to the power of" - # " üç yüz və səkkiz") - def test_large_numbers(self): self.assertEqual( @@ -255,7 +242,6 @@ def test_large_numbers(self): self.assertEqual( pronounce_number(1000000000000, short_scale=True), "bir trilyon") - # TODO maybe beautify this self.assertEqual( pronounce_number(1000001, short_scale=True), "bir milyon, bir") @@ -314,9 +300,6 @@ def test_ordinals(self): short_scale=False), "on səkkiz " "trilyonuncu") -# def nice_time(dt, lang="en-us", speech=True, use_24hour=False, -# use_ampm=False): - class TestNiceDateFormat(unittest.TestCase): @classmethod @@ -520,13 +503,12 @@ def test_nice_year(self): dt, lang=lang, bc=ast.literal_eval(p['bc']))) i = i + 1 - # Test all years from 0 to 9999 for all languages, + # Test all years from 0 to 9999 for az, # that some output is produced print("Test all years in " + lang) for i in range(1, 9999): dt = datetime.datetime(i, 1, 31, 13, 2, 3, tzinfo=default_timezone()) self.assertTrue(len(nice_year(dt, lang=lang)) > 0) - # Looking through the date sequence can be helpful def test_nice_duration(self): self.assertEqual(nice_duration(1), "bir saniyə") diff --git a/test/test_parse_az.py b/test/test_parse_az.py index 79e05040..32172ba9 100644 --- a/test/test_parse_az.py +++ b/test/test_parse_az.py @@ -1,5 +1,5 @@ # -# Copyright 2017 Mycroft AI Inc. +# Copyright 2021 Mycroft AI Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License.