Skip to content

StringParser: emit the captured small-tag text, not the literal string "$1" - #856

Open
ManasBagul23 wants to merge 1 commit into
dbpedia:masterfrom
ManasBagul23:fix-stringparser-small-tag-literal-dollar1
Open

ManasBagul23 wants to merge 1 commit into
dbpedia:masterfrom
ManasBagul23:fix-stringparser-small-tag-literal-dollar1

Conversation

@ManasBagul23

@ManasBagul23 ManasBagul23 commented Oct 15, 2026 •

Copy link
Copy Markdown

Problem

`postProcess` replaces `...` tags using `smallTagRegex.replaceAllIn(text, (m: Match) => ... "($1)" ...)`. This uses `Regex.replaceAllIn`'s `Match => String` overload, which uses the returned string verbatim (it is run through `Matcher.quoteReplacement` before being applied) -- unlike the separate String-replacement overload, it does not expand `$1` group references. So every non-empty `...` tag was replaced with the literal four characters `( $ 1 )`, not its actual content.

Confirmed with a direct `java.util.regex` reproduction of the exact `appendReplacement`/`quoteReplacement` mechanism `Regex.replaceAllIn` uses: the old code turns `"(extra info)"` into the literal text `"($1)"`; the fix produces `"(extra info)"` as intended.

`StringParser.parse` backs the large majority of plain-text infobox property extraction across the whole framework, so this corrupts any such text containing a `` tag with non-empty content.

Fix

Concatenate the actual captured group instead of writing a literal $1 placeholder.

Fixes #855

Summary by CodeRabbit

  • Bug Fixes
    • Text inside <small> tags is now preserved in parentheses when processed. Empty <small> content continues to be removed.

…g "$1"

postProcess replaces <small>...</small> tags using
smallTagRegex.replaceAllIn(text, (m: Match) => ... "($1)" ...). This uses
Regex.replaceAllIn Match => String overload, which uses the returned string
verbatim (it is run through Matcher.quoteReplacement before being applied)
-- unlike the separate String-replacement overload, it does not expand
"$1" group references. So every non-empty <small>...</small> tag was
replaced with the literal four characters ( $ 1 ), not its actual content.

Confirmed with a direct java.util.regex reproduction of the exact
appendReplacement/quoteReplacement mechanism Regex.replaceAllIn uses: the
old code turns "<small>(extra info)</small>" into the literal text
"($1)"; the fix produces "(extra info)" as intended.

StringParser.parse backs the large majority of plain-text infobox property
extraction across the whole framework, so this corrupts any such text
containing a <small> tag with non-empty content.

Fixed by concatenating the actual captured group instead of writing a
literal $1 placeholder.
Copilot AI balanced review requested due to automatic review settings October 15, 2026 19:04

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 15, 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: d193256e-a7d1-46e0-8f3e-6b7da8246a23
📥 Commits

Reviewing files that changed from the base of the PR and between b66cb8b and 5793c1d.

📒 Files selected for processing: 1
  • core/src/main/scala/org/dbpedia/extraction/dataparser/StringParser.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

StringParser.postProcess now places captured nonempty <small> content inside parentheses. It continues to remove empty content.

Changes: Small-tag replacement

Layer / File(s) Summary
Post-process replacement
core/src/main/scala/org/dbpedia/extraction/dataparser/StringParser.scala
Nonempty <small> content is replaced with the captured text inside parentheses instead of the literal ($1). Empty content is still removed.

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Bug fix · Severity of issue fixed: Low

Merge Risk: ⚪ Minimal · up to 5793c

The change corrects the small-tag text output as intended. No actionable merge risk was identified; it appears ready for normal checks.

Pre-merge checks: Passed 5
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: emitting captured -tag text instead of the literal "$1".
Linked Issues check Passed Directly linked issue #855 requires StringParser.postProcess to preserve captured text from non-empty <small>...</small> tags instead of emitting literal ($1). The supplied change summary states…
Out of Scope Changes check Passed The supplied change summary contains one focused change in StringParser.postProcess: it replaces the literal ($1) result with captured <small> content. This change directly implements issue #855…
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.

StringParser.postProcess replaces <small> tag content with the literal text "($1)"

2 participants