opensanctions / opensanctions/poliloom

Filter hidden elements in text extraction to match browser visibility behavior

Open
#45 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

loom
Dominant language
Python
Stars
22
Forks
2
PR merge metrics
No merged PRs in 30d

Description

Problem

Currently, our text extraction from Wikipedia and other websites includes hidden elements that browsers don't render. This causes issues with proof line matching between extracted text and what users see in the GUI.

Example issue: Wikipedia infoboxes contain hidden spans like <span style="display:none">(1977-08-21)</span> that appear in our extracted text but are invisible in browsers.

Current Behavior

Our enrichment pipeline extracts text using:

soup = BeautifulSoup(html_content, "html.parser")
text = soup.get_text()

This includes ALL text content, including hidden elements.

Expected Behavior

Text extraction should match what browsers display, excluding:

  • Elements with display: none
  • Elements with visibility: hidden
  • Elements with hidden attribute
  • Script/style/noscript tags (already excluded by GUI highlighter)

GUI Highlighting Logic Reference

Our text highlighter at /poliloom-gui/src/lib/textHighlighter.ts:34-41 already excludes SCRIPT, STYLE, and NOSCRIPT elements but doesn't handle CSS-hidden elements.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the enrichment pipeline code containing the shown BeautifulSoup text extraction, then compare it with the exclusions in /poliloom-gui/src/lib/textHighlighter.ts:34-41. The change is done when extracted text excludes CSS-hidden elements, hidden attributes, and script/style/noscript content so proof-line matching follows browser-visible text.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.