Skip to content

Dates, numbers and measures; the difference before a comparative - #96

Merged
vthorsteinsson merged 4 commits into
masterfrom
dates-numbers
Dec 4, 2026
Merged

vthorsteinsson merged 4 commits into
masterfrom
dates-numbers

Conversation

@vthorsteinsson

@vthorsteinsson vthorsteinsson commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

Dates, numbers and measures are the second largest group among the diagnosed causes of sentences that do not parse in a sample of 5,000 news sentences. This PR fixes most of that group. It also gives a measure of difference in the dative its place in the tree, before "á eftir"/"á undan" and before a comparative, and adds ranges with "til" ("200 til 460 milljónir króna").

What now parses

Sentence What was wrong
Hann kom í gær, sunnudag. no weekday in apposition to "í gær", "á morgun", "í gærkvöldi"
Napoli varð meistari tímabilið 2024. "tímabil" and "leiktíð" were not time nouns
Leicester varð Englandsmeistari tímabilið 2015/16. the same, with the two years of a season
Sætið var öruggt allan seinni hálfleikinn. "allan" + a time noun allowed no qualifier, and few nouns
Úrræðið varir lengur en þrjá mánuði. no "lengur en" + duration
Um það bil fimm hundruð farþegar yfirgáfu lestina. "um það bil" was not a phrase
Yfir hundrað skjálftar mældust. BÍN has "hundrað" in the singular only
Á annað hundrað skólar taka þátt. no rule
Hann las þrjár til fjórar bækur. ranges only between digits
Tveir þriðju þeirra eru viðstaddir. no fractions with a pronoun or a noun after them
Fyrsta tveggja mínútna brottvísunin var dæmd. no measure in the genitive between a determiner and its noun
Heiðar seldi allan 12% hlut sinn. the same, with a percentage
Hann hóf sitt 24. tímabil. no ordinal number after a determiner
Liðið er í 2. sæti, tveimur stigum á eftir Val. no difference in front of "á eftir"
Tveimur árum eldri systir hans kom. no difference in front of a comparative
Hann hljóp tveimur sekúndum hraðar. the same, before an adverb
Kostnaðurinn er 200 til 460 milljónir króna. ranges of amounts with a dash only
Hraðinn er 40 til 70 km/klst. the same, for measurements
Þessi 300 milljóna króna kostnaður er mikill. no amount in the genitive between a determiner and its noun

Also: "einn og hálfan dag", "tvær fyrstu þeirra", "þrír komma tveir", "tuttugu árum og þremur dögum síðar", "frá 1. júní síðastliðnum", "í meira en 500 daga", "það sem eftir lifir tímabils".

Trees that were wrong

  • "Hún er tveimur árum eldri en hann" had "tveimur árum" as a dative object of "vera", and "eldri en hann" as a predicate of its own. The difference is now inside the phrase of the comparative, where "mun" and "miklu" already were (MiðstigForskeyti): before an adjective in a predicate, before an adjective in front of a noun ("með tveimur mörkum betri markatölu") and before an adverb ("sæti ofar").
  • "á eftir" and "á undan" are one preposition (FsÁEftirUndan), not an adverb and a preposition, and take the difference in front.
  • "einn þriggja sakborninga" was the number 3: two number words in a row were multiplied into one number token (parse_phrases_1() in bintokenizer.py). Only "hundrað", "þúsund", "milljón" etc. multiply the number word before them now.
  • "Liðið er í öðru sæti" read "Liðið" as the supine of "líða". Prefs.conf now has the noun first.
  • "Hann fékk 20 til 30 prósent atkvæða" was "20" and a phrase with "til", as was "200 til 300 manns". The tokenizer joins the upper bound of a range with its unit, and the grammar now has ranges of such tokens with "til" (FjárhæðarBil, PrósentubilTil), with "á bilinu" as a prefix of a number. For this the amount and prósenta terminals take a case (amount_þf_kvk, prósenta_ef): a percent range without a case becomes a genitive possessor of the noun before it.

Two things that limit the rules

  • Only a unit of measure is a difference. With any noun in the dative, both rules took the objects of verbs: "fylgdi tveimur mönnum á eftir bílnum", "gaf tveimur börnum stærri gjafir". The units are a list (MunurNafnorð), shared by the two rules. Before "fleiri" and "færri" the difference is counted in anything: "manni færri", "þremur atkvæðum fleiri", "einum færri".
  • A difference does not have the definite article, with a few exceptions (see "After review" below).
  • A duration in the bare accusative ("var frá þrjá mánuði") is a time phrase as a last resort only, with a penalty of 36. Without it, the rule takes the objects of "taka", "fá" and others ("Það tók tvö ár").

Measurements

Before After
News sample: unparsed of 5,000 346 326
The 23 diagnosed sentences that parse 1 20
Targeted samples (17 constructions, 2,016 sentences): unparsed 398 157
Sample for the comparative (231 sentences): unparsed 18 15
Sample of ranges with "til" (450 sentences): unparsed 80 37
Gold development set: unparsed of 4,239 251 244
Gold development set: labelled bracket F1 0.7462 0.7463
Warm pass over 1,000 news sentences 1.664 s 1.697 s
  • No sentence of the news sample that parsed before is lost; 102 other trees in it change.
  • Two sentences of the targeted samples no longer parse, both with "um það bil". Their earlier parses had "um" as a preposition with the noun phrase "það bil".
  • In the sample for the comparative, 127 trees change; in most of them the dative was an object of the verb.
  • In the sample of ranges, 182 trees change and none is lost. Amounts go from 52 unparsed of 150 to 13; for percentages the gain is in the trees.
  • PP attachment against the gold standard is unchanged (0.730).
  • The 2% in speed is in the core: the grammar has grown. It was measured after the first two commits, not after the ranges and the review fixes.
  • Matching and reducer parity (GREYNIR_MATCHING_PARITY, GREYNIR_REDUCER_PARITY) show no differences on 1,500 sentences with all four commits.
  • GreynirCorrect's 99 tests passed with the engine of the first two commits, as with master's (the merging of number words changed); they were not run again after the ranges and the review fixes. GreynirServer's suite was not run.

Known limits

  • A number word after a product of number words is still joined with it, and the value is wrong: "þrjú hundruð fjörutíu" is 12,000. That is as it was. Numbers written out in full should be added up, with their "og".
  • Three of the 23 diagnosed sentences still fail: "F-35 og F-16 orrustuþotur", "tuttugu árum og fjölda umfjallana síðar", "milli tveir og þrír að stærð".
  • A difference before a comparative that stands alone ("Valur er með stigi minna") has "með" as an adverb, and after a verb with a dative object ("lék tveimur mönnum færri") the verb takes the dative.
  • "Liðið er tveimur leikjum á eftir" still reads "liðið" as the supine. A stronger preference for the noun loses "Það hefur liðið langur tími".
  • "11 til 13 milljónir rúmmetra" still has "til" as a preposition: a number token matches a tala terminal in any case, so "13 milljónir" passes for a genitive.
  • A number and a unit after a verb with a dative object is read as a difference: "Kjósendur treysta tveimur flokkum betur en áður". In "kom tveimur dögum fyrr" the difference is right.

These are in the backlog in CLAUDE.md, with what was done.

After review

Three comments, all confirmed, fixed in the fourth commit:

  • A definite dative object was read as a difference ("Hann lauk leiknum fyrr en hinir", "Hann fagnaði markinu á undan félögum sínum"), as a lemma literal without _gr also matches the form with the article. A lemma literal can now have the variant _ángr, the name that the format of a NounPhrase has for the indefinite form. It is matched in Python and natively (TF_NO_ARTICLE in ematcher.cpp) and is not in the terminal names of the simple tree. The 100 unit literals have it.
    The article is not always wrong, though. Of 161 news sentences with such a noun in the definite dative before a comparative or "á eftir"/"á undan", about 40 have "skrefinu á undan", "skrefinu lengra" or "skrefinu framar", and a few "árinu eldri", "deginum eldri", "höfðinu hærri". Those are still differences (MunurMeðGreini, MiðstigMeðGreini). The 25 with an object or "frá árinu á undan" have the tree of master again.
  • "um það bil sem" is a conjunction ("Um það bil sem vélin lenti hófst rigningin"), which the static phrase had lost.
  • A test depended on the version of BÍN ("Þrótti" is a person name in islenska-data 5.0.1).

The review fixes change no tree in the news sample, the other samples or the gold development set.

Tests

Seven new tests in test/test_parse.py: a weekday after a day reference, seasons and durations, number words, measures before a noun, "á eftir"/"á undan", the difference before a comparative, and ranges with "til", each with the sentences that must not change next to it. One in test/test_native_matching.py for the _ángr variant, natively and in Python. 182 tests pass on Python 3.14, 3.10 and PyPy 3.11, and 183 on free-threaded 3.14 with 8 threads; the suite also passes with islenska-data 5.0.1. Ruff and mypy are clean.

🤖 Generated with Claude Code

vthorsteinsson and others added 2 commits December 3, 2026 15:17
The cluster "dates, numbers and measures" of the sentences that do not
parse: 20 of its 23 diagnosed sentences parse now, and the sample of
5,000 news sentences goes from 346 unparsed to 326, with none lost.

Dates and time:

- A weekday in apposition to "í gær", "á morgun", "í gærkvöldi":
  "Hann kom í gær, sunnudag".
- "tímabil", "keppnistímabil" and "leiktíð" are time nouns, also with a
  year or the two years of a season ("tímabilið 2015/16": the parser
  never sees the slash, so the rule is a year followed by a number).
- "allan seinni hálfleikinn", "nær allan leikinn"; "lengur en þrjá
  mánuði"; "í meira en 500 daga"; "tuttugu árum og þremur dögum síðar";
  "frá 1. júní síðastliðnum".
- A duration in the bare accusative ("var frá þrjá mánuði") is a time
  phrase as a last resort only, as it otherwise takes the objects of
  "taka", "fá" and others.

Numbers:

- "um það bil" is a static phrase; "hundrað" stands where plural number
  words do ("yfir hundrað skjálftar", "tæplega hundrað manns"); "á annað
  hundrað skólar".
- Ranges of number words ("þrjár til fjórar bækur"), fractions ("tveir
  þriðju þeirra"), "tvær fyrstu þeirra", "einn og hálfan dag", "þrír
  komma tveir".
- Two number words in a row are no longer multiplied into one number:
  "einn þriggja sakborninga" was the number 3. After a product of
  number words the joining is as it was ("þrjú hundruð fjörutíu").

Measures:

- A measure in the genitive, or a percentage, between a determiner and
  its noun: "fyrsta tveggja mínútna brottvísunin", "allan 12% hlut
  sinn", "eina fjögurra klukkustunda siglingu".
- An ordinal number after a determiner: "sitt 24. tímabil".
- "á eftir" and "á undan" are one preposition, with the difference in
  the dative in front: "tveimur stigum á eftir Val", "níu stigum á
  eftir". Only what a difference is measured in may stand there, or the
  rule takes the objects of verbs ("fylgdi tveimur mönnum á eftir
  bílnum").

"liðið" is a noun before it is the supine of "líða" (Prefs.conf):
"Liðið er í öðru sæti".

Against the gold standard the figures are as they were (labelled
bracket F1 0.7463 against 0.7462, 244 trees without a parse against
251). A warm pass over 1,000 news sentences takes 2% longer (1.697 s
against 1.664 s), all of it in the core.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
"Hún er tveimur árum eldri en hann" had "tveimur árum" as a dative
object of "vera" and "eldri en hann" as a predicate of its own, as
there was no rule for a measure in front of a comparative. Where no
verb could take the dative, the sentence did not parse: "Tveimur árum
eldri systir hans kom", "Hann hljóp tveimur sekúndum hraðar".

The difference is now part of the phrase of the comparative, where
"mun" and "miklu" already were (MiðstigForskeyti), before an adjective
in a predicate, an adjective in front of a noun ("með tveimur mörkum
betri markatölu") and an adverb ("sæti ofar"). It is a number and a
unit of measure, a unit alone ("ári yngri"), an amount ("1,8 milljörðum
króna minna") or a percentage. The units are those of "tveimur stigum á
eftir", with more added: with any noun there, the rule takes the
objects of verbs ("gaf tveimur börnum stærri gjafir"). Before "fleiri"
and "færri" the difference is counted in anything: "manni færri",
"þremur atkvæðum fleiri", "einum færri".

In a sample of 231 news sentences with the construction, 127 trees
change and 3 more sentences parse (18 unparsed to 15). In the sample of
5,000 news sentences 9 trees change, and the figures against the gold
standard are the same.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
# 'ári (yngri)', 'sæti (ofar)'
MiðstigMunur →
MunurEinkunn? Tímatala_þgf/tala/kyn MunurNafnorð_þgf/tala/kyn
| MunurEinkunn? MunurNafnorð_þgf_et/kyn

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A terminal without _gr also matches the noun with the article, so with the +16/+20 bonuses a definite dative object is now taken as the difference. These parse correctly on master and wrongly here:

  • Hann lauk leiknum fyrr en hinir.
  • Kjósendur treysta flokknum betur en áður.
  • Hann fagnaði markinu á undan félögum sínum.
  • Hún gaf leiknum hærri einkunn en ég.

A difference is never definite, so excluding the article from the unit nouns, or giving the alternatives without a number no bonus, should fix it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed: all four had the object on master and a difference here. Fixed in 30a49c9.

A lemma literal can now have the variant _ángr (the name that the format of a NounPhrase already has for the indefinite form), which excludes the form with the article. It is matched natively as well as in Python, and the 100 unit literals of MunurNafnorð have it.

One correction to "a difference is never definite". I drew the news sentences with one of these nouns in the definite dative before a comparative or "á eftir"/"á undan" (161 sentences from 40,000 articles):

  • About 40 are differences with the article: "skrefinu á undan", "skrefinu lengra", "skrefinu framar", and a few "árinu eldri", "deginum eldri", "höfðinu hærri". Excluding the article everywhere made these objects of "vera".
  • 25 are of the kind you describe: objects ("stýra leiknum betur") and "frá árinu á undan", "frá mánuðinum á undan".

So "skrefinu" is still a difference and the three phrases with an adjective are listed (MiðstigMeðGreini). The 25 have the tree of master again.

Two things this does not do:

  • In "Hann fagnaði markinu á undan félögum sínum" the object is right, but the "á undan" phrase now hangs on "markinu" and not on the verb, as "með félögum sínum" does on master in the same place.
  • A number and a unit after a verb with a dative object is still read as a difference: "Kjósendur treysta tveimur flokkum betur en áður". The article does not help there; it is in the backlog in CLAUDE.md.


"á stangli", "aþ nheþ", "á stangl"
"á ný", "aa aa", "á ný"
"um það bil", "ao fpheo nheo", "um það bil"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making "um það bil" a fixed phrase loses "um það bil sem": "Um það bil sem vélin lenti hófst rigningin." parses on master and fails here. A rule for 'um_það_bil:ao' "sem:st" next to the one for "um leið og" should bring it back.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed, and fixed in 30a49c9 with the rule you suggest, in Tíðartenging next to "um leið og". The sentence is in test_number_words now, with "Hann kom um það bil sem fundurinn hófst."

Comment thread test/test_parse.py Outdated
),
(
"ÍBV er núna aðeins stigi á undan Þrótti.",
"PP ao no_hk_et_þgf ao P fs_þgf /P NP no_et_þgf_kk /NP /PP",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With islenska-data 5.0.1, the current release, "Þrótti" is read as a person name (person_þgf_kk), so this fails. Ending the expected string at P fs_þgf /P NP would make it independent of that.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed with islenska-data 5.0.1 (person_þgf_kk), and changed as you suggest in 30a49c9. The suite passes with 5.0.1 and with 5.0.0, which uv.lock has.

vthorsteinsson and others added 2 commits December 3, 2026 20:46
"Kostnaðurinn er 200 til 460 milljónir króna" did not parse: the
tokenizer joins the upper bound of a range with its unit into one
token (an amount, a percentage, a measurement), and the grammar had
ranges of such tokens with a dash only. Where the sentence did parse,
"til" was a preposition: "fékk 20 til 30 prósent atkvæða" was "20" and
a phrase with "til".

- Amounts: "200 til 460 milljónir króna" (FjárhæðarBil), also in the
  genitive before a noun ("200 til 300 milljóna króna kostnaður"). The
  first number does not agree with the amount in gender ("tvö til þrjú
  hundruð milljónir króna").
- Percentages: "20 til 30 prósent atkvæða", "5,1 til 5,4 prósenta
  verðbólgu" (PrósentubilTil). The range has the case of the
  percentage: without a case it becomes a genitive possessor of the
  noun before it ("verð til neytenda um 25 til 30 prósent").
- Measurements ("40 til 70 km/klst") and "200 til 300 manns".
- "á bilinu" is a prefix of a number: "á bilinu 200 til 300 milljónir".
- A singular first number in a range of number words: "1 til 8 stig".
- An amount in the genitive between a determiner and its noun: "þessi
  300 milljóna króna kostnaður".

For this, the amount and prósenta terminals take a case and a gender
(amount_þf_kvk, prósenta_ef), which is checked against the token if it
has any ("15 kr." and "30%" have none). An amount terminal with a
currency code and a case does not match an amount without a case, as
before.

In a sample of 450 news sentences with such a range, 80 unparsed go to
37 (amounts 52 to 13 of 150), none is lost and 182 trees change. In the
sample of 5,000 news sentences 10 trees change and 326 remain unparsed;
in the gold development set three sentences change.

Left: "11 til 13 milljónir rúmmetra", where "til" stays a preposition,
as a number token matches a tala terminal in any case.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
From the review of the pull request:

- The units of a difference ("tveimur stigum á eftir", "sæti ofar")
  are lemma literals, and a lemma literal without _gr also matches the
  form with the article. With the bonuses of the rules, a definite
  dative object became the difference: "Hann lauk leiknum fyrr en
  hinir", "Kjósendur treysta flokknum betur en áður", "Hann fagnaði
  markinu á undan félögum sínum", "Hún gaf leiknum hærri einkunn en
  ég", and "frá árinu á undan" was "árinu á undan" with a stray "frá".

  A lemma literal can now have the variant _ángr ('stig:hk'_et_þgf_ángr),
  the name that the format of a NounPhrase has for the indefinite
  form: it does not match a form with the article. It is matched
  natively (TF_NO_ARTICLE in ematcher.cpp) and in Python
  (matcher_lemma_literal()), only lemma literals take it, and it is
  left out of the terminal names of the simple tree. The 100 literals
  of MunurNafnorð have it.

  The article is not always wrong, though. In 161 news sentences with
  such a noun in the definite dative before a comparative or "á
  eftir"/"á undan", about 40 have "skrefinu á undan", "skrefinu lengra"
  or "skrefinu framar", and a few "árinu eldri", "deginum eldri",
  "höfðinu hærri"; 25 have an object or "frá árinu á undan". So
  "skrefinu" is a difference (MunurMeðGreini) and the three phrases
  with an adjective are listed (MiðstigMeðGreini). The 25 have the
  tree of master again, and the others are as they were.

- "um það bil" as a static phrase lost "um það bil sem": "Um það bil
  sem vélin lenti hófst rigningin". With "sem" it is now a conjunction
  (Tíðartenging), next to "um leið og".

- A test expected "Þrótti" to be a noun; with islenska-data 5.0.1 it
  is the name of a person. The expected string ends before it.

No tree changes in the sample of 5,000 news sentences, in the samples
for the comparative, the ranges and the 17 constructions, or in the
gold development set; matching and reducer parity show no differences
on 1,500 sentences.

Left: a number and a unit before a comparative adverb, after a verb
with a dative object, is still a difference ("treysta tveimur flokkum
betur en áður").

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@vthorsteinsson
vthorsteinsson merged commit 1d40437 into master Dec 4, 2026
12 checks passed
@vthorsteinsson
vthorsteinsson deleted the dates-numbers branch December 4, 2026 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants