Skip to content

EthiopianDateParser: fix capture-group arity mismatch in dateRegex2/3 - #850

Closed
ManasBagul23 wants to merge 1 commit into
dbpedia:masterfrom
ManasBagul23:fix-ethiopian-date-regex-arity
Closed

ManasBagul23 wants to merge 1 commit into
dbpedia:masterfrom
ManasBagul23:fix-ethiopian-date-regex-arity

Conversation

@ManasBagul23

@ManasBagul23 ManasBagul23 commented Sep 27, 2026 •

Copy link
Copy Markdown

Fixes #851 (split out from #845, item C).

dateRegex2 and dateRegex3 each declared 4 capturing groups (month/day plus a redundant extra pair of parens wrapped around the \b...\b day boundary: (\b(0?[1-9]|[12][0-9]|3[01])\b)), but catchGeezDate destructures each match into exactly 3 variables:

for (dateRegex2(month, day, year) <- List(dateString)) ...
for (dateRegex3(day, month, year) <- List(dateString)) ...

Regex.unapplySeq requires the extractor pattern's arity to match the regex's group count exactly, so a 4-group regex bound to a 3-variable pattern never matches anything — these two regexes (of the five total) have been dead code since they were written.

Fix: drop the outer, redundant capturing parens around \b(...)\b, which were never used for anything (the day value is already captured by the inner group) — \b is a zero-width boundary assertion and does not need its own group. This brings both regexes down to 3 groups, matching the existing destructuring pattern, without changing what either regex actually matches.

Verification: standalone Java regex check mirroring the exact pattern structure (java.util.regex has the same group-counting semantics scala.util.matching.Regex wraps): before the fix, Pattern.compile(...).groupCount() reports 4 for both; after, 3. Confirmed the patterns still match their intended date shapes (<month> <day> <year> and <day> <month> <year>) unchanged. No Scala/sbt toolchain available locally to run the project's own test suite.

Prepared with AI assistance; I reviewed the changes.

dateRegex2 and dateRegex3 each declared 4 capturing groups (month/day
plus a redundant extra pair of parens wrapped around the \b...\b day
boundary: `(\b(0?[1-9]|[12][0-9]|3[01])\b)`), but catchGeezDate
destructures each match into exactly 3 variables:

    for (dateRegex2(month, day, year) <- List(dateString)) ...
    for (dateRegex3(day, month, year) <- List(dateString)) ...

Regex.unapplySeq requires the extractor pattern's arity to match the
regex's group count exactly, so a 4-group regex bound to a 3-variable
pattern never matches anything -- these two regexes (of the five total)
have been dead code since they were written.

Fix: drop the outer, redundant capturing parens around \b(...)\b, which
were never used for anything (the day value is already captured by the
inner group) -- \b is a zero-width boundary assertion and does not need
its own group. This brings both regexes down to 3 groups, matching the
existing destructuring pattern, without changing what either regex
actually matches.

Verified with a standalone Java regex check mirroring the exact pattern
structure (java.util.regex has the same group-counting semantics
scala.util.matching.Regex wraps): before the fix, Pattern.compile(...).
groupCount() reports 4 for both; after, 3. Confirmed the patterns still
match their intended date shapes (`<month> <day> <year>` and `<day>
<month> <year>`) unchanged. No Scala/sbt toolchain available locally to
run the project's own test suite.

Related to dbpedia#845 (item C)
Copilot AI lite review requested due to automatic review settings September 27, 2026 16:22

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 4c97463a-5289-4b59-bd5a-dfd72db2c47c

📥 Commits

Reviewing files that changed from the base of the PR and between e3dfe8b and 6030119.

📒 Files selected for processing (1)
  • core/src/main/scala/org/dbpedia/extraction/dataparser/EthiopianDateParser.scala

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

The Ethiopian date parser removes nested capture groups from two date regexes. The resulting captures match the month/day/year and day/month/year extraction order used by catchGeezDate.

Changes

Ethiopian date parsing

Layer / File(s) Summary
Date regex capture order
core/src/main/scala/org/dbpedia/extraction/dataparser/EthiopianDateParser.scala
dateRegex2 and dateRegex3 no longer add nested capture groups around day and month-name patterns. Their captures align with the argument order used by catchGeezDate.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~5 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 60301

No actionable merge-blocking risk is established in this change. The relevant tests were inspected but not run, so normal project checks should still be completed.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely identifies the main change: fixing the capture-group arity mismatch in dateRegex2 and dateRegex3.
✨ Finishing Touches 💡 1
🧪 Generate unit tests (beta)
  • Create a new PR
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sonarqubecloud

Copy link
Copy Markdown

@ManasBagul23

Copy link
Copy Markdown
Author

Same situation as #849 — PR #846 (merged as c870f5d) already fixes this exact arity mismatch (dateRegex2/3 switched to non-capturing (?:...) groups) as part of a broader pass over #845. Closing this as superseded. I'll close issue #851 too since it's covered by the same merge — thanks for the review @jimkont.

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.

EthiopianDateParser: dateRegex2/3 never match due to a capture-group arity mismatch

3 participants