Multitude of corrections of Slovene language (#246)

* Multitude of corrections of Slovene language

* Indentation correction for flake8

* Added tests from https://github.com/gregopet/num2words by @gregopet and merged them with existing.

* Flake8ing tests.

* Sorted imports

* Some more sorting...

* Last time for sorting?
This commit is contained in:
Blaž Bregar
2019-03-29 18:47:18 +01:00
committed by Ernesto Rodriguez Ortiz
parent eef5b03593
commit 18194b52ef
4 changed files with 189 additions and 45 deletions

View File

@@ -17,40 +17,12 @@
from __future__ import unicode_literals
from . import lang_AR
from . import lang_CZ
from . import lang_EN
from . import lang_EN_IN
from . import lang_FR
from . import lang_FR_CH
from . import lang_FR_BE
from . import lang_FR_DZ
from . import lang_DE
from . import lang_ES
from . import lang_FI
from . import lang_LT
from . import lang_LV
from . import lang_PL
from . import lang_RO
from . import lang_RU
from . import lang_ID
from . import lang_JA
from . import lang_NO
from . import lang_DK
from . import lang_PT
from . import lang_PT_BR
from . import lang_HE
from . import lang_IT
from . import lang_ES_VE
from . import lang_ES_CO
from . import lang_VI
from . import lang_TR
from . import lang_NL
from . import lang_UK
from . import lang_SL
from . import lang_SR
from . import lang_TH
from . import lang_KO
from . import (lang_AR, lang_CZ, lang_DE, lang_DK, lang_EN, lang_EN_IN,
lang_ES, lang_ES_CO, lang_ES_VE, lang_FI, lang_FR, lang_FR_BE,
lang_FR_CH, lang_FR_DZ, lang_HE, lang_ID, lang_IT, lang_JA,
lang_KO, lang_LT, lang_LV, lang_NL, lang_NO, lang_PL, lang_PT,
lang_PT_BR, lang_RO, lang_RU, lang_SL, lang_SR, lang_TH,
lang_TR, lang_UK, lang_VI)
CONVERTER_CLASSES = {
'ar': lang_AR.Num2Word_AR(),

View File

@@ -22,8 +22,8 @@ from .lang_EU import Num2Word_EU
class Num2Word_SL(Num2Word_EU):
GIGA_SUFFIX = "iljard"
MEGA_SUFFIX = "iljon"
GIGA_SUFFIX = "ilijard"
MEGA_SUFFIX = "ilijon"
def setup(self):
super(Num2Word_SL, self).setup()
@@ -36,7 +36,7 @@ class Num2Word_SL(Num2Word_EU):
self.mid_numwords = [(1000, "tisoč"), (900, "devetsto"),
(800, "osemsto"), (700, "sedemsto"),
(600, "šesto"), (500, "petsto"),
(600, "šeststo"), (500, "petsto"),
(400, "štiristo"), (300, "tristo"),
(200, "dvesto"), (100, "sto"),
(90, "devetdeset"), (80, "osemdeset"),
@@ -57,16 +57,31 @@ class Num2Word_SL(Num2Word_EU):
"osem": "osm",
"sto": "stot",
"tisoč": "tisoč",
"miljon": "miljont"
"milijon": "milijont"
}
self.ordflag = False
def merge(self, curr, next):
ctext, cnum, ntext, nnum = curr + next
if ctext == "dve" and not self.ordflag:
if ctext.endswith("dve") and self.ordflag and nnum <= 1000000:
ctext = ctext[:len(ctext)-1] + "a"
if ctext == "dve" and not self.ordflag and nnum < 1000000000:
ctext = "dva"
if (ctext.endswith("tri") or ctext.endswith("štiri")) and\
nnum == 1000000 and not self.ordflag:
if ctext.endswith("štiri"):
ctext = ctext[:-1]
ctext = ctext + "je"
if cnum >= 20 and cnum < 100 and nnum == 2:
ntext = "dva"
if ctext.endswith("ena") and nnum >= 1000:
ctext = ctext[0:-1]
if cnum == 1:
if nnum < 10**6 or self.ordflag:
return next
@@ -89,15 +104,28 @@ class Num2Word_SL(Num2Word_EU):
elif not ntext.endswith("d"):
ntext += "i"
elif ctext.endswith("en"):
if ntext.endswith("d") or ntext.endswith("n"):
ntext += ""
elif ctext.endswith("dve") and ntext.endswith("n"):
ctext = ctext[:-1] + "a"
ntext += "a"
elif ctext.endswith("je") and ntext.endswith("n"):
ntext += "i"
else:
if ntext.endswith("d"):
ntext += "a"
elif ntext.endswith("n"):
ntext += ""
elif ntext.endswith("d"):
ntext += "e"
else:
ntext += "ov"
if nnum >= 10**2 and self.ordflag is False:
if nnum >= 10**2 and self.ordflag is False and ctext:
ctext += " "
val = cnum * nnum