tablassert 17.0.0__tar.gz → 17.0.1__tar.gz
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.
- {tablassert-17.0.0 → tablassert-17.0.1}/PKG-INFO +1 -1
- {tablassert-17.0.0 → tablassert-17.0.1}/pyproject.toml +1 -1
- {tablassert-17.0.0 → tablassert-17.0.1}/src/tablassert/fullmap.py +34 -18
- {tablassert-17.0.0 → tablassert-17.0.1}/LICENSE +0 -0
- {tablassert-17.0.0 → tablassert-17.0.1}/README.md +0 -0
- {tablassert-17.0.0 → tablassert-17.0.1}/rust/Cargo.lock +0 -0
- {tablassert-17.0.0 → tablassert-17.0.1}/rust/Cargo.toml +0 -0
- {tablassert-17.0.0 → tablassert-17.0.1}/rust/examples/count_tables.rs +0 -0
- {tablassert-17.0.0 → tablassert-17.0.1}/rust/src/fullmap.rs +0 -0
- {tablassert-17.0.0 → tablassert-17.0.1}/rust/src/json.rs +0 -0
- {tablassert-17.0.0 → tablassert-17.0.1}/rust/src/lib.rs +0 -0
- {tablassert-17.0.0 → tablassert-17.0.1}/rust/src/ndjson.rs +0 -0
- {tablassert-17.0.0 → tablassert-17.0.1}/rust/src/uuid.rs +0 -0
- {tablassert-17.0.0 → tablassert-17.0.1}/rust/tests/build_golden.rs +0 -0
- {tablassert-17.0.0 → tablassert-17.0.1}/rust/tests/common/mod.rs +0 -0
- {tablassert-17.0.0 → tablassert-17.0.1}/rust/tests/extract_prebuilt.rs +0 -0
- {tablassert-17.0.0 → tablassert-17.0.1}/src/tablassert/__init__.py +0 -0
- {tablassert-17.0.0 → tablassert-17.0.1}/src/tablassert/_lazy.py +0 -0
- {tablassert-17.0.0 → tablassert-17.0.1}/src/tablassert/agent.py +0 -0
- {tablassert-17.0.0 → tablassert-17.0.1}/src/tablassert/biolink.py +0 -0
- {tablassert-17.0.0 → tablassert-17.0.1}/src/tablassert/cli.py +0 -0
- {tablassert-17.0.0 → tablassert-17.0.1}/src/tablassert/coerce.py +0 -0
- {tablassert-17.0.0 → tablassert-17.0.1}/src/tablassert/distill.py +0 -0
- {tablassert-17.0.0 → tablassert-17.0.1}/src/tablassert/enums.py +0 -0
- {tablassert-17.0.0 → tablassert-17.0.1}/src/tablassert/errors.py +0 -0
- {tablassert-17.0.0 → tablassert-17.0.1}/src/tablassert/extras.py +0 -0
- {tablassert-17.0.0 → tablassert-17.0.1}/src/tablassert/graph_target.py +0 -0
- {tablassert-17.0.0 → tablassert-17.0.1}/src/tablassert/ingests.py +0 -0
- {tablassert-17.0.0 → tablassert-17.0.1}/src/tablassert/lib.py +0 -0
- {tablassert-17.0.0 → tablassert-17.0.1}/src/tablassert/log.py +0 -0
- {tablassert-17.0.0 → tablassert-17.0.1}/src/tablassert/models.py +0 -0
- {tablassert-17.0.0 → tablassert-17.0.1}/src/tablassert/nlp.py +0 -0
- {tablassert-17.0.0 → tablassert-17.0.1}/src/tablassert/progress.py +0 -0
- {tablassert-17.0.0 → tablassert-17.0.1}/src/tablassert/qc.py +0 -0
- {tablassert-17.0.0 → tablassert-17.0.1}/src/tablassert/rig.py +0 -0
- {tablassert-17.0.0 → tablassert-17.0.1}/src/tablassert/rs.pyi +0 -0
- {tablassert-17.0.0 → tablassert-17.0.1}/src/tablassert/study.py +0 -0
- {tablassert-17.0.0 → tablassert-17.0.1}/src/tablassert/utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "tablassert"
|
|
3
|
-
version = "17.0.
|
|
3
|
+
version = "17.0.1"
|
|
4
4
|
description = "Extract knowledge assertions from tabular data into NCATS Translator-compliant KGX NDJSON — declaratively, with entity resolution and quality control built in."
|
|
5
5
|
authors = [
|
|
6
6
|
{ name = "Skye Lane Goetz", email = "sgoetz@isbscience.org" }
|
|
@@ -289,31 +289,37 @@ def distinct(lf: pl.LazyFrame, l1: str, l2: str, col: str = "term") -> pl.LazyFr
|
|
|
289
289
|
|
|
290
290
|
|
|
291
291
|
def deduplicate_result(result: pl.DataFrame, column_context: bool) -> pl.DataFrame:
|
|
292
|
-
"""Sort and de-duplicate fullmap matches
|
|
292
|
+
"""Sort and de-duplicate fullmap matches while retaining tied best candidates.
|
|
293
293
|
|
|
294
294
|
When ``column_context`` is set, a per-category ``FREQUENCY`` column is
|
|
295
295
|
attached and used as a high-priority tiebreaker (more common categories
|
|
296
|
-
first).
|
|
296
|
+
first). Lower-ranked rows are removed, but every distinct CURIE sharing a
|
|
297
|
+
term's complete best ranking tuple is retained. Repeated rows for the same
|
|
298
|
+
``(term, CURIE)`` pair collapse to one row.
|
|
297
299
|
|
|
298
300
|
Args:
|
|
299
301
|
result: Joined matches with a ``CATEGORY_NAME`` column.
|
|
300
302
|
column_context: Whether to compute/use the frequency tiebreaker.
|
|
301
303
|
|
|
302
304
|
Returns:
|
|
303
|
-
DataFrame with one
|
|
305
|
+
DataFrame with one or more best-ranked rows per ``term``, unique by
|
|
306
|
+
``(term, CURIE)``.
|
|
304
307
|
"""
|
|
305
|
-
|
|
308
|
+
ranking_columns: list[str] = ["term", "PR", "NLP_LEVEL"]
|
|
306
309
|
descending: list[bool] = [False, False, False]
|
|
307
310
|
|
|
308
311
|
if column_context:
|
|
309
312
|
frequency: pl.DataFrame = result.group_by("CATEGORY_NAME").agg(pl.len().alias("FREQUENCY"))
|
|
310
313
|
result = result.join(frequency, on="CATEGORY_NAME", how="left")
|
|
311
314
|
|
|
312
|
-
|
|
315
|
+
ranking_columns += ["FREQUENCY"]
|
|
313
316
|
descending += [True]
|
|
314
317
|
|
|
315
|
-
result = result.sort(
|
|
316
|
-
|
|
318
|
+
result = result.sort(ranking_columns, descending=descending)
|
|
319
|
+
best_tiers: pl.DataFrame = result.select(ranking_columns).unique(subset=["term"], keep="first")
|
|
320
|
+
result = result.join(best_tiers, on=ranking_columns, how="inner")
|
|
321
|
+
result = result.unique(subset=["term", "CURIE"], keep="first")
|
|
322
|
+
return result.sort([*ranking_columns, "CURIE"], descending=[*descending, False])
|
|
317
323
|
|
|
318
324
|
|
|
319
325
|
def _category_values(categories: list[Any]) -> list[str]:
|
|
@@ -357,7 +363,9 @@ def filter_and_rank(
|
|
|
357
363
|
exclude_regex: Regex patterns; any CURIE matching one is dropped.
|
|
358
364
|
|
|
359
365
|
Returns:
|
|
360
|
-
Ranked matches DataFrame with one
|
|
366
|
+
Ranked matches DataFrame with one or more best-ranked rows per term,
|
|
367
|
+
retaining distinct tied CURIEs and collapsing duplicate ``(term, CURIE)``
|
|
368
|
+
rows.
|
|
361
369
|
"""
|
|
362
370
|
# Resolve_batch reuses one shared redb fetch per column.
|
|
363
371
|
if raw.height == 0:
|
|
@@ -476,8 +484,10 @@ def _coalesce_expr(col: str, suffix: str, base: str, prefix: str, cast_str: bool
|
|
|
476
484
|
def join_matches(lf: pl.LazyFrame, col: str, matches: pl.DataFrame, tag: str = "_two", drop_unresolved: bool = True) -> pl.LazyFrame:
|
|
477
485
|
"""Join ranked fullmap matches back into ``lf`` for one column.
|
|
478
486
|
|
|
479
|
-
|
|
480
|
-
|
|
487
|
+
A source row may expand to one output row per distinct best-ranked CURIE
|
|
488
|
+
when the fullmap ranking heuristics tie. Coalesces level-one and level-two
|
|
489
|
+
hits per row (level one wins when present) and emits derived
|
|
490
|
+
``<col>_name``, ``<col>_category``,
|
|
481
491
|
``<col>_taxon``, ``<col>_source``, ``<col>_source_version`` and
|
|
482
492
|
``<col>_nlp_level`` columns.
|
|
483
493
|
|
|
@@ -493,8 +503,9 @@ def join_matches(lf: pl.LazyFrame, col: str, matches: pl.DataFrame, tag: str = "
|
|
|
493
503
|
edge and the null-stripper omits the qualifier key.
|
|
494
504
|
|
|
495
505
|
Returns:
|
|
496
|
-
New LazyFrame with resolved columns
|
|
497
|
-
|
|
506
|
+
New LazyFrame with resolved columns. Tied best-ranked CURIEs are
|
|
507
|
+
returned as separate rows; rows whose ``col`` did not match are dropped
|
|
508
|
+
unless ``drop_unresolved`` is False.
|
|
498
509
|
|
|
499
510
|
Notes:
|
|
500
511
|
Split out of ``resolve`` so ``resolve_batch`` can apply per-column
|
|
@@ -517,8 +528,9 @@ def _join_matches_eager(df: pl.DataFrame, col: str, matches: pl.DataFrame, tag:
|
|
|
517
528
|
when False the row is kept and the resolved columns stay null.
|
|
518
529
|
|
|
519
530
|
Returns:
|
|
520
|
-
DataFrame with resolved columns
|
|
521
|
-
|
|
531
|
+
DataFrame with resolved columns. Tied best-ranked CURIEs are returned as
|
|
532
|
+
separate rows; rows whose ``col`` did not match are dropped unless
|
|
533
|
+
``drop_unresolved`` is False.
|
|
522
534
|
"""
|
|
523
535
|
l1: str = col
|
|
524
536
|
l2: str = l1 + tag
|
|
@@ -573,8 +585,10 @@ def resolve_batch(
|
|
|
573
585
|
|
|
574
586
|
Each column still gets its own taxon/prioritize/avoid filtering and its own
|
|
575
587
|
join back into ``lf``. Taxon constraints apply to every taxon-bearing
|
|
576
|
-
match while retaining rows with no taxon metadata (TAXON_ID 0);
|
|
577
|
-
|
|
588
|
+
match while retaining rows with no taxon metadata (TAXON_ID 0); distinct
|
|
589
|
+
best-ranked CURIEs tied by all heuristics are retained as separate output
|
|
590
|
+
rows. Only the redb round trip itself (``rs.lookup_fullmap_terms``) is pooled
|
|
591
|
+
across columns.
|
|
578
592
|
|
|
579
593
|
Args:
|
|
580
594
|
lf: Source LazyFrame.
|
|
@@ -589,7 +603,8 @@ def resolve_batch(
|
|
|
589
603
|
column is processed, used to drive fine-grained progress UX.
|
|
590
604
|
|
|
591
605
|
Returns:
|
|
592
|
-
LazyFrame with resolved columns added.
|
|
606
|
+
LazyFrame with resolved columns added. A source row may produce one row
|
|
607
|
+
per distinct CURIE when the best ranking tier is tied.
|
|
593
608
|
|
|
594
609
|
Raises:
|
|
595
610
|
TablassertError: ``resolve-bad-specs`` when two specs share a column, or a
|
|
@@ -694,7 +709,8 @@ def resolve(
|
|
|
694
709
|
tag: Suffix used to derive the level-two column name.
|
|
695
710
|
|
|
696
711
|
Returns:
|
|
697
|
-
LazyFrame with resolved columns added.
|
|
712
|
+
LazyFrame with resolved columns added. A source row may produce one row
|
|
713
|
+
per distinct CURIE when the best ranking tier is tied.
|
|
698
714
|
"""
|
|
699
715
|
return resolve_batch(
|
|
700
716
|
lf,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|