Skip to content

Commit be362fc

Browse files
committed
Tests fixed; nval assignment fixed
1 parent 5266487 commit be362fc

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/tokenizer/tokenizer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1692,13 +1692,13 @@ def parse_phrases_1(token_stream):
16921692
# Coalesce [year|number] + ['e.Kr.'|'f.Kr.'] into year
16931693
if token.kind == TOK.YEAR or token.kind == TOK.NUMBER:
16941694
val = token.val if token.kind == TOK.YEAR else token.val[0]
1695-
nval = ""
1695+
nval = None
16961696
if next_token.txt in BCE: # f.Kr.
16971697
# Yes, we set year X BCE as year -X ;-)
16981698
nval = -val
16991699
elif next_token.txt in CE: # e.Kr.
17001700
nval = val
1701-
if nval:
1701+
if nval is not None:
17021702
token = TOK.Year(token.txt + " " + next_token.txt, nval)
17031703
next_token = next(token_stream)
17041704
if next_token.txt == ".":

test/test_tokenizer.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ def test_sentence(text, expected, **options):
735735

736736
test_sentence(
737737
"1.030 hPa lægð gengur yfir landið árið 2019 e.Kr. Jógúrtin inniheldur 80 kcal.",
738-
"B ME W W W W Y E B W W ME P E",
738+
"B ME W W W W Y E B W W ME P E",
739739
)
740740

741741
test_sentence(
@@ -849,7 +849,12 @@ def test_sentence(text, expected, **options):
849849
)
850850

851851
test_sentence(
852-
"Tösku-og hanskabúðin, sálug, var á Lauga- eða Skothúsvegi.",
852+
"Tösku- og hanskabúðin, sálug, var á Lauga- eða Skothúsvegi.",
853+
"B W P W P W W W P E",
854+
)
855+
856+
test_sentence(
857+
"Tösku-og hanskabúðin, sálug, var á Lauga-eða Skothúsvegi.",
853858
"B W P W P W W W P E",
854859
)
855860

0 commit comments

Comments
 (0)