Skip to content

DisambiguationExtractor: do not crash for a language missing from the title-suffix map - #852

Open
ManasBagul23 wants to merge 1 commit into
dbpedia:masterfrom
ManasBagul23:fix-disambiguationextractor-unmapped-language
Open

ManasBagul23 wants to merge 1 commit into
dbpedia:masterfrom
ManasBagul23:fix-disambiguationextractor-unmapped-language

Conversation

@ManasBagul23

@ManasBagul23 ManasBagul23 commented Oct 12, 2026 •

Copy link
Copy Markdown

Fixes #616

DisambiguationExtractorConfig.disambiguationTitlePartMap only covers the roughly two dozen languages whose disambiguation-page title suffix (e.g. " (disambiguation)" for en) has been added to it. The extractor looked the current language up via the map's unsafe apply(), which throws NoSuchElementException for any language not in the map — this crashed construction of the extractor itself, not just one page, for every language enabled for extraction (dump or live server) that is missing from this map.

#616's own example ("ro") has since been added to the map and no longer reproduces, but the same unsafe lookup remains for every other language still missing from it — sv, sl, hr, tr, lv, cy, be, az, hy, bn, ur, vi and more, all of which appear in real extraction.default.properties-style language lists and are not in this map today.

Changed to getOrElse with a logged warning and an empty-string fallback: with nothing stripped, cleanPageTitle keeps the page's full decoded title instead of crashing extractor construction for that language. ExtractionManager.scala already handles the identical class of problem (a language missing from a lookup map) with getOrElse plus a warning log a few files over — this follows the same established pattern.

Summary by CodeRabbit

  • Bug Fixes
    • Disambiguation extraction now continues with an empty title suffix when a language’s wiki code has no configured suffix, rather than failing. A warning is logged in this case.

… title-suffix map

DisambiguationExtractorConfig.disambiguationTitlePartMap only covers the
roughly two dozen languages whose disambiguation-page title suffix
(e.g. " (disambiguation)" for en) has been added to it. The extractor
looked the current language up via the maps unsafe apply(), which
throws NoSuchElementException for any language not in the map -- this
crashed construction of the extractor itself, not just one page, for
every language enabled for extraction (dump or live server) that is
missing from this map.

#616s own example ("ro") has since been added to the map and no longer
reproduces, but the same unsafe lookup remains for every other language
still missing from it -- sv, sl, hr, tr, lv, cy, be, az, hy, bn, ur, vi
and more, all of which appear in real extraction.default.properties-style
language lists and are not in this map today.

Changed to getOrElse with a logged warning and an empty-string fallback:
with nothing stripped, cleanPageTitle keeps the pages full decoded
title instead of crashing extractor construction for that language.
ExtractionManager.scala already handles the identical class of problem
(a language missing from a lookup map) with getOrElse plus a warning
log a few files over; this follows the same established pattern.

Fixes dbpedia#616.
Copilot AI balanced review requested due to automatic review settings October 12, 2026 18:47

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 Oct 12, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

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: ad2f0143-3663-4664-b504-8a8dffb872ce

📥 Commits

Reviewing files that changed from the base of the PR and between b66cb8b and 473ffb7.


📒 Files selected for processing (1)
  • core/src/main/scala/org/dbpedia/extraction/mappings/DisambiguationExtractor.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

DisambiguationExtractor now logs a warning and uses an empty title suffix when a language wiki code is not configured in the suffix map.

Changes

Missing title suffix handling

Layer / File(s) Summary
Fallback and warning
core/src/main/scala/org/dbpedia/extraction/mappings/DisambiguationExtractor.scala
The extractor uses an empty suffix and logs a warning when the language wiki code is missing from disambiguationTitlePartMap.

Priority: ➖ Normal

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

Change: Bug fix · Severity of issue fixed: Medium


Merge Risk: ⚪ Minimal · up to 473ff

No actionable merge-blocking risk is established; the fallback retains the full decoded title when no suffix is configured.

Pre-merge checks | Passed 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: preventing crashes when a language is absent from the title-suffix map.
Linked Issues check Passed Issue #616 requires removal of the NoSuchElementException during DisambiguationExtractor construction for an unmapped language such as ro. The reviewed source uses `disambiguationTitlePartMap.ge…
Out of Scope Changes check Passed The available change summary reports changes only in DisambiguationExtractor.scala. The added logger, warning, and fallback directly support the issue objective. No unrelated change is shown. The wh…
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…

✨ Finishing Touches 💡 1
🧪 Generate unit tests (beta)
  • Create a new PR

🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

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.

Disambiguation extractor check

2 participants