Repository navigation
Dates, numbers and measures; the difference before a comparative - #96
Conversation
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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."
| ), | ||
| ( | ||
| "Í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", |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
"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>
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
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
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").FsÁEftirUndan), not an adverb and a preposition, and take the difference in front.parse_phrases_1()inbintokenizer.py). Only "hundrað", "þúsund", "milljón" etc. multiply the number word before them now.Prefs.confnow has the noun first.FjárhæðarBil,PrósentubilTil), with "á bilinu" as a prefix of a number. For this theamountandprósentaterminals 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
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".Measurements
GREYNIR_MATCHING_PARITY,GREYNIR_REDUCER_PARITY) show no differences on 1,500 sentences with all four commits.Known limits
talaterminal in any case, so "13 milljónir" passes for a genitive.These are in the backlog in
CLAUDE.md, with what was done.After review
Three comments, all confirmed, fixed in the fourth commit:
_gralso matches the form with the article. A lemma literal can now have the variant_ángr, the name that the format of aNounPhrasehas for the indefinite form. It is matched in Python and natively (TF_NO_ARTICLEinematcher.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.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 intest/test_native_matching.pyfor the_ángrvariant, 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