Repository navigation
Commit fc8b11f
authored
fix: count dates written with a multi-character date separator as the culture's own (#186)
The profiler counts, per culture, how many dates are written with that
culture's own date separator
(`CultureParseCounts.DatesWithOwnSeparator`). That count breaks the tie
between cultures that read every value as a date: it decides which
culture's extremes `ColumnFacts` publishes and the order of date
hypotheses (#58).
**Defect.** The separator was kept only when it was one character; a
longer one became `'\0'` and was never matched. 55 .NET cultures
separate with more than one character: `". "` (27 — hu, ko, bs, hr-BA,
en-HU, en-SI and others, e.g. `2024. 01. 15.`) and a right-to-left mark
followed by `/` (28 Arabic cultures, e.g. `15/1/2024`). For them the
count was always zero, so a column of Hungarian-written dates ranked
en-US first whenever en-US read the same dates, only because `en-US`
sorts before `hu-HU`.
**Change.** `CultureAccumulator` keeps the culture's separator as a
string and matches it whole, ordinal (`string.Contains(string,
StringComparison.Ordinal)`, which allocates nothing). The match runs
only for values that already read as a date under that culture, as
before; an empty separator never counts. One-character separators (de-DE
`.`, en-US `/`) count exactly as before. The `DatesWithOwnSeparator`
docs say the separator is matched whole.
**Tests** (`AmbiguousDateTests`), each failing before the change except
the one-character case:
- de-DE and en-US dates still count as written with their own separator;
- under hu-HU, `2024. 01. 15.`-style dates count as written with its own
separator;
- with en-US and hu-HU both reading those dates, the hu-HU date
hypothesis now ranks first;
- under ar-EG, dates written with the host's ar-EG separator count as
its own. The separator comes from the host's ICU data, so this test
skips where ar-EG's separator is one character or such dates do not
read; on macOS it runs and passes.
**Measured**, full analysis, minimum of 3 runs each, main → branch:
5M-row csv 13,848 → 13,652 ms; 3M-row csv 9,553 → 9,656 ms. Within noise
(other work shared the machine).
Refs #184.1 parent e4008fa commit fc8b11f
3 files changed
Lines changed: 69 additions & 13 deletions
File tree
- src/TriasDev.Tabular/Analysis
- tests/TriasDev.Tabular.Tests/Analysis
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
515 | 515 | | |
516 | 516 | | |
517 | 517 | | |
518 | | - | |
519 | | - | |
520 | | - | |
521 | | - | |
522 | | - | |
523 | | - | |
524 | | - | |
525 | | - | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
526 | 526 | | |
527 | 527 | | |
528 | 528 | | |
| |||
720 | 720 | | |
721 | 721 | | |
722 | 722 | | |
723 | | - | |
| 723 | + | |
| 724 | + | |
724 | 725 | | |
725 | 726 | | |
726 | 727 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
26 | | - | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
3 | 4 | | |
| |||
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
20 | | - | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
21 | 24 | | |
22 | 25 | | |
23 | 26 | | |
24 | 27 | | |
25 | | - | |
| 28 | + | |
26 | 29 | | |
27 | 30 | | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
28 | 34 | | |
29 | 35 | | |
30 | 36 | | |
| |||
73 | 79 | | |
74 | 80 | | |
75 | 81 | | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
76 | 130 | | |
0 commit comments