natural-pdf 0.2.10__py3-none-any.whl → 0.2.11__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- natural_pdf/analyzers/guides.py +122 -30
- {natural_pdf-0.2.10.dist-info → natural_pdf-0.2.11.dist-info}/METADATA +1 -1
- {natural_pdf-0.2.10.dist-info → natural_pdf-0.2.11.dist-info}/RECORD +7 -7
- {natural_pdf-0.2.10.dist-info → natural_pdf-0.2.11.dist-info}/WHEEL +0 -0
- {natural_pdf-0.2.10.dist-info → natural_pdf-0.2.11.dist-info}/entry_points.txt +0 -0
- {natural_pdf-0.2.10.dist-info → natural_pdf-0.2.11.dist-info}/licenses/LICENSE +0 -0
- {natural_pdf-0.2.10.dist-info → natural_pdf-0.2.11.dist-info}/top_level.txt +0 -0
natural_pdf/analyzers/guides.py
CHANGED
@@ -4246,12 +4246,26 @@ class _ColumnAccessor:
|
|
4246
4246
|
"""Return number of columns (vertical guides - 1)."""
|
4247
4247
|
return max(0, len(self._guides.vertical) - 1)
|
4248
4248
|
|
4249
|
-
def __getitem__(self, index: int) -> "Region":
|
4250
|
-
"""Get column at the specified index."""
|
4251
|
-
|
4252
|
-
|
4253
|
-
|
4254
|
-
|
4249
|
+
def __getitem__(self, index: Union[int, slice]) -> Union["Region", "ElementCollection"]:
|
4250
|
+
"""Get column at the specified index or slice."""
|
4251
|
+
from natural_pdf.elements.element_collection import ElementCollection
|
4252
|
+
|
4253
|
+
if isinstance(index, slice):
|
4254
|
+
# Handle slice notation - return multiple columns
|
4255
|
+
columns = []
|
4256
|
+
num_cols = len(self)
|
4257
|
+
|
4258
|
+
# Convert slice to range of indices
|
4259
|
+
start, stop, step = index.indices(num_cols)
|
4260
|
+
for i in range(start, stop, step):
|
4261
|
+
columns.append(self._guides.column(i))
|
4262
|
+
|
4263
|
+
return ElementCollection(columns)
|
4264
|
+
else:
|
4265
|
+
# Handle negative indexing
|
4266
|
+
if index < 0:
|
4267
|
+
index = len(self) + index
|
4268
|
+
return self._guides.column(index)
|
4255
4269
|
|
4256
4270
|
|
4257
4271
|
class _RowAccessor:
|
@@ -4264,12 +4278,26 @@ class _RowAccessor:
|
|
4264
4278
|
"""Return number of rows (horizontal guides - 1)."""
|
4265
4279
|
return max(0, len(self._guides.horizontal) - 1)
|
4266
4280
|
|
4267
|
-
def __getitem__(self, index: int) -> "Region":
|
4268
|
-
"""Get row at the specified index."""
|
4269
|
-
|
4270
|
-
|
4271
|
-
|
4272
|
-
|
4281
|
+
def __getitem__(self, index: Union[int, slice]) -> Union["Region", "ElementCollection"]:
|
4282
|
+
"""Get row at the specified index or slice."""
|
4283
|
+
from natural_pdf.elements.element_collection import ElementCollection
|
4284
|
+
|
4285
|
+
if isinstance(index, slice):
|
4286
|
+
# Handle slice notation - return multiple rows
|
4287
|
+
rows = []
|
4288
|
+
num_rows = len(self)
|
4289
|
+
|
4290
|
+
# Convert slice to range of indices
|
4291
|
+
start, stop, step = index.indices(num_rows)
|
4292
|
+
for i in range(start, stop, step):
|
4293
|
+
rows.append(self._guides.row(i))
|
4294
|
+
|
4295
|
+
return ElementCollection(rows)
|
4296
|
+
else:
|
4297
|
+
# Handle negative indexing
|
4298
|
+
if index < 0:
|
4299
|
+
index = len(self) + index
|
4300
|
+
return self._guides.row(index)
|
4273
4301
|
|
4274
4302
|
|
4275
4303
|
class _CellAccessor:
|
@@ -4278,33 +4306,82 @@ class _CellAccessor:
|
|
4278
4306
|
def __init__(self, guides: "Guides"):
|
4279
4307
|
self._guides = guides
|
4280
4308
|
|
4281
|
-
def __getitem__(self, key) -> Union["Region", "_CellRowAccessor"]:
|
4309
|
+
def __getitem__(self, key) -> Union["Region", "_CellRowAccessor", "ElementCollection"]:
|
4282
4310
|
"""
|
4283
4311
|
Get cell(s) at the specified position.
|
4284
4312
|
|
4285
4313
|
Supports:
|
4286
|
-
- guides.cells[row, col] -
|
4287
|
-
- guides.cells[row][col] - nested
|
4314
|
+
- guides.cells[row, col] - single cell
|
4315
|
+
- guides.cells[row][col] - single cell (nested)
|
4316
|
+
- guides.cells[row, :] - all cells in a row
|
4317
|
+
- guides.cells[:, col] - all cells in a column
|
4318
|
+
- guides.cells[:, :] - all cells
|
4319
|
+
- guides.cells[row][:] - all cells in a row (nested)
|
4288
4320
|
"""
|
4321
|
+
from natural_pdf.elements.element_collection import ElementCollection
|
4322
|
+
|
4289
4323
|
if isinstance(key, tuple) and len(key) == 2:
|
4290
|
-
# Direct tuple access: guides.cells[row, col]
|
4291
4324
|
row, col = key
|
4292
|
-
|
4293
|
-
|
4294
|
-
|
4295
|
-
|
4296
|
-
|
4297
|
-
|
4325
|
+
|
4326
|
+
# Handle slices for row and/or column
|
4327
|
+
if isinstance(row, slice) or isinstance(col, slice):
|
4328
|
+
cells = []
|
4329
|
+
num_rows = len(self._guides.rows)
|
4330
|
+
num_cols = len(self._guides.columns)
|
4331
|
+
|
4332
|
+
# Convert slices to ranges
|
4333
|
+
if isinstance(row, slice):
|
4334
|
+
row_indices = range(*row.indices(num_rows))
|
4335
|
+
else:
|
4336
|
+
# Single row index
|
4337
|
+
if row < 0:
|
4338
|
+
row = num_rows + row
|
4339
|
+
row_indices = [row]
|
4340
|
+
|
4341
|
+
if isinstance(col, slice):
|
4342
|
+
col_indices = range(*col.indices(num_cols))
|
4343
|
+
else:
|
4344
|
+
# Single column index
|
4345
|
+
if col < 0:
|
4346
|
+
col = num_cols + col
|
4347
|
+
col_indices = [col]
|
4348
|
+
|
4349
|
+
# Collect all cells in the specified ranges
|
4350
|
+
for r in row_indices:
|
4351
|
+
for c in col_indices:
|
4352
|
+
cells.append(self._guides.cell(r, c))
|
4353
|
+
|
4354
|
+
return ElementCollection(cells)
|
4355
|
+
else:
|
4356
|
+
# Both are integers - single cell access
|
4357
|
+
# Handle negative indexing for both row and col
|
4358
|
+
if row < 0:
|
4359
|
+
row = len(self._guides.rows) + row
|
4360
|
+
if col < 0:
|
4361
|
+
col = len(self._guides.columns) + col
|
4362
|
+
return self._guides.cell(row, col)
|
4363
|
+
elif isinstance(key, slice):
|
4364
|
+
# First level slice: guides.cells[:] - return all rows as accessors
|
4365
|
+
# For now, let's return all cells flattened
|
4366
|
+
cells = []
|
4367
|
+
num_rows = len(self._guides.rows)
|
4368
|
+
row_indices = range(*key.indices(num_rows))
|
4369
|
+
|
4370
|
+
for r in row_indices:
|
4371
|
+
for c in range(len(self._guides.columns)):
|
4372
|
+
cells.append(self._guides.cell(r, c))
|
4373
|
+
|
4374
|
+
return ElementCollection(cells)
|
4298
4375
|
elif isinstance(key, int):
|
4299
4376
|
# First level of nested access: guides.cells[row]
|
4300
4377
|
# Handle negative indexing for row
|
4301
4378
|
if key < 0:
|
4302
4379
|
key = len(self._guides.rows) + key
|
4303
|
-
# Return a row accessor that allows [col] indexing
|
4380
|
+
# Return a row accessor that allows [col] or [:] indexing
|
4304
4381
|
return _CellRowAccessor(self._guides, key)
|
4305
4382
|
else:
|
4306
4383
|
raise TypeError(
|
4307
|
-
f"Cell indices must be integers or tuple of two integers, got {type(key)}"
|
4384
|
+
f"Cell indices must be integers, slices, or tuple of two integers/slices, got {type(key)}"
|
4308
4385
|
)
|
4309
4386
|
|
4310
4387
|
|
@@ -4315,9 +4392,24 @@ class _CellRowAccessor:
|
|
4315
4392
|
self._guides = guides
|
4316
4393
|
self._row = row
|
4317
4394
|
|
4318
|
-
def __getitem__(self, col: int) -> "Region":
|
4319
|
-
"""Get cell at [row][col]."""
|
4320
|
-
|
4321
|
-
|
4322
|
-
|
4323
|
-
|
4395
|
+
def __getitem__(self, col: Union[int, slice]) -> Union["Region", "ElementCollection"]:
|
4396
|
+
"""Get cell at [row][col] or all cells in row with [row][:]."""
|
4397
|
+
from natural_pdf.elements.element_collection import ElementCollection
|
4398
|
+
|
4399
|
+
if isinstance(col, slice):
|
4400
|
+
# Handle slice notation - return all cells in this row
|
4401
|
+
cells = []
|
4402
|
+
num_cols = len(self._guides.columns)
|
4403
|
+
|
4404
|
+
# Convert slice to range of indices
|
4405
|
+
start, stop, step = col.indices(num_cols)
|
4406
|
+
for c in range(start, stop, step):
|
4407
|
+
cells.append(self._guides.cell(self._row, c))
|
4408
|
+
|
4409
|
+
return ElementCollection(cells)
|
4410
|
+
else:
|
4411
|
+
# Handle single column index
|
4412
|
+
# Handle negative indexing for column
|
4413
|
+
if col < 0:
|
4414
|
+
col = len(self._guides.columns) + col
|
4415
|
+
return self._guides.cell(self._row, col)
|
@@ -2,7 +2,7 @@ natural_pdf/__init__.py,sha256=N4pR0LbuPEnUYFZqbdVqc_FGKldgwPQc1wjJhYKTBBM,3417
|
|
2
2
|
natural_pdf/cli.py,sha256=0zO9ZoRiP8JmyGBaVavrMATnvbARWTl7WD2PEefu9BM,4061
|
3
3
|
natural_pdf/text_mixin.py,sha256=eFCiHj6Okcw3aum4955BepcI2NPRalkf9UFFVTc_H30,4012
|
4
4
|
natural_pdf/analyzers/__init__.py,sha256=3XGoNq3OgiVkZP7tOdeP5XVUl7fDgyztdA8DlOcMLXg,1138
|
5
|
-
natural_pdf/analyzers/guides.py,sha256=
|
5
|
+
natural_pdf/analyzers/guides.py,sha256=GQZHjl7wUpaxAKRpv4cyQf1SJuccMSjpngBKFCKNHK4,181795
|
6
6
|
natural_pdf/analyzers/shape_detection_mixin.py,sha256=mgpyJ4jIulz9l9HCqThabJIsLSrXh9BB2AmLxUoHmw0,62584
|
7
7
|
natural_pdf/analyzers/text_options.py,sha256=qEkDaYWla0rIM_gszEOsu52q7C_dAfV81P2HLJZM2sw,3333
|
8
8
|
natural_pdf/analyzers/text_structure.py,sha256=3WWusi-BI0krUnJxB05DD6XmKj5qRNvQBqH7zOQGm1M,28451
|
@@ -107,7 +107,7 @@ natural_pdf/vision/results.py,sha256=F2zXG3MVZIpOUvPkJHotOq6-9rFz68BaO_8pnSndlOs
|
|
107
107
|
natural_pdf/vision/similarity.py,sha256=YH8legN-t9uf1b_XULi4JLNDaRfPNKQwU1FZ4Qu08jY,11740
|
108
108
|
natural_pdf/widgets/__init__.py,sha256=QTVaUmsw__FCweFYZebwPssQxxUFUMd0wpm_cUbGZJY,181
|
109
109
|
natural_pdf/widgets/viewer.py,sha256=KW3JogdR2TMg2ECUMYp8hwd060hfg8EsYBWxb5IEzBY,24942
|
110
|
-
natural_pdf-0.2.
|
110
|
+
natural_pdf-0.2.11.dist-info/licenses/LICENSE,sha256=9zfwINwJlarbDmdh6iJV4QUG54QSJlSAUcnC1YiC_Ns,1074
|
111
111
|
optimization/memory_comparison.py,sha256=0i_foFSRmppj-fY069qjwH36s_zkx-1L2ASAAlepWzA,6541
|
112
112
|
optimization/pdf_analyzer.py,sha256=HjrmTgu2qchxPeDckc5kjgxppGwd40UESrYS9Myj7pY,19352
|
113
113
|
optimization/performance_analysis.py,sha256=JBXnR9hc7Ix7YCnt3EJPSpsyqIUgKsc7GEffQ_TDCBk,13033
|
@@ -124,8 +124,8 @@ tools/bad_pdf_eval/llm_enrich.py,sha256=mCh4KGi1HmIkzGjj5rrHz1Osd7sEX1IZ_FW08H1t
|
|
124
124
|
tools/bad_pdf_eval/llm_enrich_with_retry.py,sha256=XUtPF1hUvqd3frDXT0wDTXoonuAivhjM5vgFdZ-tm0A,9373
|
125
125
|
tools/bad_pdf_eval/reporter.py,sha256=e1g__mkSB4q02p3mGWOwMhvFs7F2HJosNBxup0-LkyU,400
|
126
126
|
tools/bad_pdf_eval/utils.py,sha256=hR95XQ7qf7Cu6BdyX0L7ggGVx-ah5sK0jHWblTJUUic,4896
|
127
|
-
natural_pdf-0.2.
|
128
|
-
natural_pdf-0.2.
|
129
|
-
natural_pdf-0.2.
|
130
|
-
natural_pdf-0.2.
|
131
|
-
natural_pdf-0.2.
|
127
|
+
natural_pdf-0.2.11.dist-info/METADATA,sha256=RBk1DrwdyTY0cJvFdWqfvM2hMd4OY30Lc0BlXopknD4,6960
|
128
|
+
natural_pdf-0.2.11.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
129
|
+
natural_pdf-0.2.11.dist-info/entry_points.txt,sha256=1R_KMv7g60UBBpRqGfw7bppsMNGdayR-iJlb9ohEk_8,81
|
130
|
+
natural_pdf-0.2.11.dist-info/top_level.txt,sha256=80t0F2ZeX4vN4Ke5iTflcOk_PN_0USn33ha3X6X86Ik,36
|
131
|
+
natural_pdf-0.2.11.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|