Skip to main content
QUICK REVIEW

[Paper Review] Inscriptis -- A Python-based HTML to text conversion library optimized for knowledge extraction from the Web

Albert Weichselbraun|arXiv (Cornell University)|Jul 12, 2021
Topic ModelingComputer Science14 references7 citations
TL;DR

Inscriptis is a Python-based HTML-to-text conversion library designed for high-fidelity knowledge extraction from web content. It preserves spatial layout and semantic structure by interpreting HTML and CSS attributes, outperforming tools like Lynx, HTML2text, and BeautifulSoup in handling complex layouts such as nested tables, while supporting customizable annotations for downstream NLP tasks.

ABSTRACT

Inscriptis provides a library, command line client and Web service for converting HTML to plain text. Its development has been triggered by the need to obtain accurate text representations for knowledge extraction tasks that preserve the spatial alignment of text without drawing upon heavyweight, browser-based solutions such as Selenium. In contrast to related software packages, Inscriptis (i) provides a layout-aware conversion of HTML that more closely resembles the rendering obtained from standard Web browsers; and (ii) supports annotation rules, i.e., user-provided mappings that allow for annotating the extracted text based on structural and semantic information encoded in HTML tags and attributes. These unique features ensure that downstream knowledge extraction components can operate on accurate text representations, and may even use information on the semantics and structure of the original HTML document.

Motivation & Objective

  • To address the lack of layout-aware HTML-to-text conversion in existing tools for knowledge extraction.
  • To provide accurate text representations that preserve spatial alignment of text elements as rendered in web browsers.
  • To support downstream NLP tasks by preserving structural and semantic metadata from HTML and CSS.
  • To enable better performance in entity recognition, sentiment analysis, and keyword extraction by maintaining proximity and formatting cues.
  • To offer extensible annotation support for integration into research pipelines and manual annotation workflows.

Proposed method

  • Uses a layout-aware parsing engine that interprets HTML and CSS properties such as display, white-space, margin-top, and vertical-align.
  • Applies a rule-based system to interpret alignment attributes (e.g., align, valign) and preserve text positioning in the output.
  • Supports user-defined annotation rules mapping HTML elements and attributes to semantic labels.
  • Generates structured output in multiple formats, including JSONL for doccano, XML, and annotated HTML.
  • Processes complex HTML constructs like nested tables and nested lists without collapsing or misaligning content.
  • Offers a command-line interface and Web service for integration into data pipelines and research workflows.

Experimental results

Research questions

  • RQ1How can HTML-to-text conversion be improved to preserve spatial layout and semantic structure for knowledge extraction?
  • RQ2To what extent does layout-aware conversion enhance downstream NLP performance compared to standard tools?
  • RQ3Can user-defined annotation rules improve the utility of extracted text for entity recognition and sentiment analysis?
  • RQ4How does Inscriptis compare to browser-emulating tools like Selenium in terms of accuracy and performance?
  • RQ5What is the impact of preserving structural metadata (e.g., bold, italic, headings) on downstream NLP tasks?

Key findings

  • Inscriptis correctly renders complex HTML constructs such as nested tables, avoiding misalignment issues seen in tools like Lynx.
  • It outperforms popular libraries like HTML2text, BeautifulSoup, and Cheerio in preserving spatial text arrangement and semantic structure.
  • The library supports layout-aware conversion by interpreting a broad subset of HTML and CSS properties affecting text positioning.
  • Annotation rules allow downstream components to leverage structural and semantic cues from the original HTML, improving NLP task accuracy.
  • Inscriptis has been adopted in multiple national and European research projects, including MedMon, ReTV, and EPOCH, and is used in commercial platforms like webLyzard.
  • With over 135,000 downloads from PyPI since 2016, Inscriptis demonstrates strong adoption and reliability in research and production environments.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.