Skip to content

Commit

Permalink
remove extra comments and imports
Browse files Browse the repository at this point in the history
fix license year
  • Loading branch information
Siavash Mollayi committed Nov 30, 2021
1 parent 6ee8412 commit d449931
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 37 deletions.
5 changes: 2 additions & 3 deletions lingua_franca/lang/common_data_az.py
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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."

Expand Down Expand Up @@ -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'}

Expand Down
6 changes: 1 addition & 5 deletions lingua_franca/lang/format_az.py
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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
Expand Down
12 changes: 4 additions & 8 deletions lingua_franca/lang/parse_az.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -907,7 +903,7 @@ def date_found():
words[start - 1] = ""
found = True
daySpecified = True
# print(words)

# parse time
hrOffset = 0
minOffset = 0
Expand Down Expand Up @@ -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:
Expand Down
22 changes: 2 additions & 20 deletions test/test_format_az.py
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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(
Expand All @@ -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")
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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ə")
Expand Down
2 changes: 1 addition & 1 deletion test/test_parse_az.py
Original file line number Diff line number Diff line change
@@ -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.
Expand Down

0 comments on commit d449931

Please sign in to comment.