Metadata-Version: 2.4
Name: h-rots
Version: 0.1.1
Summary: Deterministic structural inference and semantic serialization of complex HTML tables for RAG
Author: H-ROTS contributors
License-Expression: Apache-2.0
Project-URL: Homepage, https://github.com/hallymgitoslab/H-ROTS
Project-URL: Repository, https://github.com/hallymgitoslab/H-ROTS
Project-URL: Issues, https://github.com/hallymgitoslab/H-ROTS/issues
Project-URL: Research, https://github.com/hallymgitoslab/H-ROTS/tree/paper
Keywords: rag,html,tables,serialization,document-processing
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Text Processing :: Markup :: HTML
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: beautifulsoup4>=4.12
Requires-Dist: lxml>=4.9
Dynamic: license-file

# H-ROTS

**Semantic table preprocessing for retrieval-augmented generation (RAG)**

H-ROTS transforms complex HTML tables into semantic records and retrieval-ready text. It resolves hierarchical headers, merged cells, row labels and supported contextual transitions before indexing. No LLM calls, model training, GPU or embedding service are needed.

- **FullPath**: explicit hierarchical semantic paths.
- **Compact**: shared-prefix serialization with reconstruction of supported intermediate records.
- Python API and command-line interface; CPU-only preprocessing.

This `main` branch contains the installable Python library and command-line interface.

## Architecture

H-ROTS converts HTML tables into ordered intermediate semantic records before serialization. FullPath and Compact are two representations of these same records.

```mermaid
flowchart TD
    A["Complex HTML table"] --> B["Structural inference"]
    B --> C["Semantic context integration"]
    C --> D["Intermediate semantic records"]
    D --> E["FullPath"]
    D --> F["Compact"]
    F --> G["Compact decoder"]
    G -.-> D
    E --> H["Downstream RAG"]
    F --> H
```

H-ROTS runs on the CPU without LLM calls or model training. Retrieval and answer generation are outside the library's scope. Compact decoding reconstructs supported intermediate records, not the original HTML or visual layout.

## Installation

Requires Python 3.10 or newer.

Install or upgrade from [PyPI](https://pypi.org/project/h-rots/) when the package is available:

```bash
python -m pip install --upgrade h-rots
```

To install this exact version after it has been published to PyPI:

```bash
python -m pip install h-rots==0.1.1
```

For the current development checkout, install directly from GitHub:

```bash
python -m pip install "h-rots @ git+https://github.com/hallymgitoslab/H-ROTS.git@main"
```

Check the installed version:

```bash
h-rots --version
```

See the [release history](https://github.com/hallymgitoslab/H-ROTS/releases) and [changelog](CHANGELOG.md).

## Quick start

```python
from h_rots import parse, serialize, decode, convert

html = """
<table>
  <thead>
    <tr><th rowspan="2">Department</th><th colspan="2">2026</th></tr>
    <tr><th>Applications</th><th>Admissions</th></tr>
  </thead>
  <tbody>
    <tr><th>Computer Science</th><td>120</td><td>40</td></tr>
    <tr><th>Mathematics</th><td>90</td><td>30</td></tr>
  </tbody>
</table>
"""

records = parse(html)
print(serialize(records, mode="fullpath"))
compact = serialize(records, mode="compact")
print(compact)
assert decode(compact) == records

# Direct HTML-to-text conversion (also retains supported captions).
text = convert(html, mode="compact")
```

## CLI

```bash
h-rots table.html --mode fullpath
h-rots table.html --mode compact -o table.compact.txt
h-rots table.compact.txt --mode decode -o records.json
h-rots table.html --mode json
python -m h_rots table.html --mode fullpath
```

Use `-` or omit the input path to read UTF-8 from stdin. The CLI's Compact mode serializes intermediate records without a caption so it can be decoded directly.

## API

| Function | Purpose |
| --- | --- |
| `parse(html)` | Parse the first table to ordered semantic records. |
| `serialize(records, mode="fullpath")` | Serialize records as FullPath or Compact. |
| `decode(text)` | Reconstruct supported intermediate records from Compact. |
| `convert(html, mode="fullpath")` | Convert the first table to text, including supported captions. |
| `html_tables_to_markdown_text(html)` | Render multiple top-level tables with the research FullPath convenience function. |

Original research entry points are also exported from `h_rots` for migration. See [API documentation](docs/api.md) and [examples](examples/basic.py).

## Design and scope

The library does not implement retrieval, answer generation or general table reasoning. Heuristic inference can be ambiguous; Compact reconstructs supported intermediate records, not original HTML or visual layout. Token savings depend on the input. Process untrusted HTML with appropriate input size and resource limits in your application.

## Research and citation

A research manuscript accompanying H-ROTS is in preparation for publication. The manuscript, formal citation, and detailed research findings will be announced after acceptance, when disclosure is appropriate. No acceptance or publication status is claimed at this time.

## Development and release

```bash
python -m pip install -e .
python -m unittest discover -s tests -v
python -m pip install build twine
python -m build
python -m twine check dist/*
```

See [release guide](docs/releasing.md) for PyPI Trusted Publishing. Research-only experiment scripts are not included in the installable package.

## Project contributors

| GitHub | Role |
| --- | --- |
| [@hallymgitoslab](https://github.com/hallymgitoslab) | Lead Developer |
| [@hero707](https://github.com/hero707) | Project Support |
| [@Iamjunseok](https://github.com/Iamjunseok) | Development Support |
| [@waitinghm-creator](https://github.com/waitinghm-creator) | Development Support |

These are project contribution roles, not a declaration of manuscript authorship or author contributions.

## Acknowledgments
This research was supported by the ANCHOR program(Glocal University30) through the Gangwon ANCHOR Center, funded by the Ministry of Education(MOE) and the Gangwon State(G.S.),Republic of Korea.(2026-ANCHOR-10-009)

The authors also acknowledge Hallym University for its support.

## License

Original H-ROTS software and documentation are licensed under [Apache-2.0](LICENSE). Third-party dependencies and datasets retain their respective licenses. Research data is not distributed in this package.
