A detected layout region on a page.
When layout detection is enabled, each page may have layout regions identifying different content types (text, pictures, tables, etc.) with confidence scores and spatial positions.
Fields
:class- Layout class name (e.g. "picture", "table", "text", "section_header"):confidence- Detection confidence score (0.0 to 1.0):bounding_box- Map with x0, y0, x1, y1 coordinates, or nil:area_fraction- Fraction of page area covered (0.0 to 1.0)
Examples
iex> region = %Kreuzberg.LayoutRegion{
...> class: "picture",
...> confidence: 0.95,
...> area_fraction: 0.3
...> }
iex> region.class
"picture"
Summary
Types
Functions
Creates a LayoutRegion struct from a map.
Parameters
data- A map containing layout region fields
Returns
A LayoutRegion struct with properly typed fields.
Examples
iex> Kreuzberg.LayoutRegion.from_map(%{"class" => "table", "confidence" => 0.9, "area_fraction" => 0.2})
%Kreuzberg.LayoutRegion{class: "table", confidence: 0.9, area_fraction: 0.2}
Converts a LayoutRegion struct to a map.
Parameters
region- ALayoutRegionstruct
Returns
A map with string keys representing all fields.
Examples
iex> region = %Kreuzberg.LayoutRegion{class: "picture", confidence: 0.95, area_fraction: 0.3}
iex> Kreuzberg.LayoutRegion.to_map(region)
%{"class" => "picture", "confidence" => 0.95, "bounding_box" => nil, "area_fraction" => 0.3}