structflo-ner 0.2.3__tar.gz → 0.3.0__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.
Files changed (44) hide show
  1. {structflo_ner-0.2.3 → structflo_ner-0.3.0}/PKG-INFO +3 -3
  2. {structflo_ner-0.2.3 → structflo_ner-0.3.0}/README.md +2 -2
  3. structflo_ner-0.3.0/images/ner_visualization.gif +0 -0
  4. {structflo_ner-0.2.3 → structflo_ner-0.3.0}/structflo/ner/__init__.py +1 -1
  5. {structflo_ner-0.2.3 → structflo_ner-0.3.0}/structflo/ner/_examples.py +88 -14
  6. {structflo_ner-0.2.3 → structflo_ner-0.3.0}/structflo/ner/_prompts.py +11 -4
  7. {structflo_ner-0.2.3 → structflo_ner-0.3.0}/.github/workflows/ci.yml +0 -0
  8. {structflo_ner-0.2.3 → structflo_ner-0.3.0}/.github/workflows/publish.yml +0 -0
  9. {structflo_ner-0.2.3 → structflo_ner-0.3.0}/.gitignore +0 -0
  10. {structflo_ner-0.2.3 → structflo_ner-0.3.0}/Makefile +0 -0
  11. {structflo_ner-0.2.3 → structflo_ner-0.3.0}/coverage.xml +0 -0
  12. {structflo_ner-0.2.3 → structflo_ner-0.3.0}/images/fast-viz.png +0 -0
  13. {structflo_ner-0.2.3 → structflo_ner-0.3.0}/images/local-gen-pandas.png +0 -0
  14. {structflo_ner-0.2.3 → structflo_ner-0.3.0}/images/local-gen-viz.png +0 -0
  15. {structflo_ner-0.2.3 → structflo_ner-0.3.0}/images/local-tb-viz.png +0 -0
  16. {structflo_ner-0.2.3 → structflo_ner-0.3.0}/images/struct-flo-ner.png +0 -0
  17. {structflo_ner-0.2.3 → structflo_ner-0.3.0}/notebooks/01_quickstart.ipynb +0 -0
  18. {structflo_ner-0.2.3 → structflo_ner-0.3.0}/notebooks/02_fast_ner.ipynb +0 -0
  19. {structflo_ner-0.2.3 → structflo_ner-0.3.0}/pyproject.toml +0 -0
  20. {structflo_ner-0.2.3 → structflo_ner-0.3.0}/structflo/ner/_display.py +0 -0
  21. {structflo_ner-0.2.3 → structflo_ner-0.3.0}/structflo/ner/_entities.py +0 -0
  22. {structflo_ner-0.2.3 → structflo_ner-0.3.0}/structflo/ner/_mapping.py +0 -0
  23. {structflo_ner-0.2.3 → structflo_ner-0.3.0}/structflo/ner/extractor.py +0 -0
  24. {structflo_ner-0.2.3 → structflo_ner-0.3.0}/structflo/ner/fast/README.md +0 -0
  25. {structflo_ner-0.2.3 → structflo_ner-0.3.0}/structflo/ner/fast/__init__.py +0 -0
  26. {structflo_ner-0.2.3 → structflo_ner-0.3.0}/structflo/ner/fast/_loader.py +0 -0
  27. {structflo_ner-0.2.3 → structflo_ner-0.3.0}/structflo/ner/fast/_matcher.py +0 -0
  28. {structflo_ner-0.2.3 → structflo_ner-0.3.0}/structflo/ner/fast/_normalize.py +0 -0
  29. {structflo_ner-0.2.3 → structflo_ner-0.3.0}/structflo/ner/fast/extractor.py +0 -0
  30. {structflo_ner-0.2.3 → structflo_ner-0.3.0}/structflo/ner/fast/gazetteers/accession_number.yml +0 -0
  31. {structflo_ner-0.2.3 → structflo_ner-0.3.0}/structflo/ner/fast/gazetteers/compound_name.yml +0 -0
  32. {structflo_ner-0.2.3 → structflo_ner-0.3.0}/structflo/ner/fast/gazetteers/disease.yml +0 -0
  33. {structflo_ner-0.2.3 → structflo_ner-0.3.0}/structflo/ner/fast/gazetteers/functional_category.yml +0 -0
  34. {structflo_ner-0.2.3 → structflo_ner-0.3.0}/structflo/ner/fast/gazetteers/gene_name.yml +0 -0
  35. {structflo_ner-0.2.3 → structflo_ner-0.3.0}/structflo/ner/fast/gazetteers/product.yml +0 -0
  36. {structflo_ner-0.2.3 → structflo_ner-0.3.0}/structflo/ner/fast/gazetteers/screening_method.yml +0 -0
  37. {structflo_ner-0.2.3 → structflo_ner-0.3.0}/structflo/ner/fast/gazetteers/strain.yml +0 -0
  38. {structflo_ner-0.2.3 → structflo_ner-0.3.0}/structflo/ner/fast/gazetteers/target.yml +0 -0
  39. {structflo_ner-0.2.3 → structflo_ner-0.3.0}/structflo/ner/profiles.py +0 -0
  40. {structflo_ner-0.2.3 → structflo_ner-0.3.0}/tests/__init__.py +0 -0
  41. {structflo_ner-0.2.3 → structflo_ner-0.3.0}/tests/test_entities.py +0 -0
  42. {structflo_ner-0.2.3 → structflo_ner-0.3.0}/tests/test_extractor.py +0 -0
  43. {structflo_ner-0.2.3 → structflo_ner-0.3.0}/tests/test_fast.py +0 -0
  44. {structflo_ner-0.2.3 → structflo_ner-0.3.0}/uv.lock +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: structflo-ner
3
- Version: 0.2.3
3
+ Version: 0.3.0
4
4
  Summary: Drug discovery NER wrapper around LangExtract — zero-config entity extraction for chemistry and biology.
5
5
  License: Apache-2.0
6
6
  Requires-Python: >=3.10
@@ -43,7 +43,7 @@ Description-Content-Type: text/markdown
43
43
 
44
44
  ---
45
45
 
46
- **structflo.ner** is a lightweight NER library specialized for pharmaceutical and biological sciences. It uses [LangExtract](https://github.com/langextract/langextract) and fuzzy based tools to deliver **zero-configuration** entity extraction.
46
+ **structflo.ner** is a lightweight NER library specialized for pharmaceutical and biological sciences. It uses [LangExtract](https://github.com/google/langextract) and fuzzy based tools to deliver **zero-configuration** entity extraction.
47
47
 
48
48
  It ships with two extraction engines:
49
49
 
@@ -111,7 +111,7 @@ Any model served by [Ollama](https://ollama.com/) works gemma, llama, mistral,
111
111
 
112
112
 
113
113
  Render results as color-coded, interactive HTML directly in Jupyter notebooks:
114
- ![Results](images/local-gen-viz.png)
114
+ ![Results](images/ner_visualization.gif)
115
115
 
116
116
 
117
117
  To get a PANDAS dataframe.
@@ -30,7 +30,7 @@
30
30
 
31
31
  ---
32
32
 
33
- **structflo.ner** is a lightweight NER library specialized for pharmaceutical and biological sciences. It uses [LangExtract](https://github.com/langextract/langextract) and fuzzy based tools to deliver **zero-configuration** entity extraction.
33
+ **structflo.ner** is a lightweight NER library specialized for pharmaceutical and biological sciences. It uses [LangExtract](https://github.com/google/langextract) and fuzzy based tools to deliver **zero-configuration** entity extraction.
34
34
 
35
35
  It ships with two extraction engines:
36
36
 
@@ -98,7 +98,7 @@ Any model served by [Ollama](https://ollama.com/) works gemma, llama, mistral,
98
98
 
99
99
 
100
100
  Render results as color-coded, interactive HTML directly in Jupyter notebooks:
101
- ![Results](images/local-gen-viz.png)
101
+ ![Results](images/ner_visualization.gif)
102
102
 
103
103
 
104
104
  To get a PANDAS dataframe.
@@ -63,7 +63,7 @@ from structflo.ner.profiles import (
63
63
  EntityProfile,
64
64
  )
65
65
 
66
- __version__ = "0.2.3"
66
+ __version__ = "0.3.0"
67
67
 
68
68
  __all__ = [
69
69
  # Main classes
@@ -166,7 +166,12 @@ _BIOACTIVITY_EXAMPLE_1 = lx.data.ExampleData(
166
166
  lx.data.Extraction(
167
167
  extraction_class="bioactivity",
168
168
  extraction_text="IC50 of 2.3 nM",
169
- attributes={"value": "2.3", "unit": "nM", "assay_type": "IC50"},
169
+ attributes={
170
+ "value": "2.3",
171
+ "unit": "nM",
172
+ "assay_type": "IC50",
173
+ "compound_name": "Compound 7",
174
+ },
170
175
  ),
171
176
  lx.data.Extraction(
172
177
  extraction_class="assay",
@@ -176,7 +181,12 @@ _BIOACTIVITY_EXAMPLE_1 = lx.data.ExampleData(
176
181
  lx.data.Extraction(
177
182
  extraction_class="bioactivity",
178
183
  extraction_text="EC50 of 45 nM",
179
- attributes={"value": "45", "unit": "nM", "assay_type": "EC50"},
184
+ attributes={
185
+ "value": "45",
186
+ "unit": "nM",
187
+ "assay_type": "EC50",
188
+ "compound_name": "Compound 7",
189
+ },
180
190
  ),
181
191
  lx.data.Extraction(
182
192
  extraction_class="assay",
@@ -190,7 +200,12 @@ _BIOACTIVITY_EXAMPLE_1 = lx.data.ExampleData(
190
200
  lx.data.Extraction(
191
201
  extraction_class="bioactivity",
192
202
  extraction_text="Ki = 0.8 nM",
193
- attributes={"value": "0.8", "unit": "nM", "assay_type": "Ki"},
203
+ attributes={
204
+ "value": "0.8",
205
+ "unit": "nM",
206
+ "assay_type": "Ki",
207
+ "compound_name": "Compound 7",
208
+ },
194
209
  ),
195
210
  ],
196
211
  )
@@ -317,7 +332,12 @@ _FULL_EXAMPLE_1 = lx.data.ExampleData(
317
332
  lx.data.Extraction(
318
333
  extraction_class="bioactivity",
319
334
  extraction_text="IC50 of 0.033 µM",
320
- attributes={"value": "0.033", "unit": "µM", "assay_type": "IC50"},
335
+ attributes={
336
+ "value": "0.033",
337
+ "unit": "µM",
338
+ "assay_type": "IC50",
339
+ "compound_name": "Gefitinib",
340
+ },
321
341
  ),
322
342
  lx.data.Extraction(
323
343
  extraction_class="assay",
@@ -332,7 +352,12 @@ _FULL_EXAMPLE_1 = lx.data.ExampleData(
332
352
  lx.data.Extraction(
333
353
  extraction_class="bioactivity",
334
354
  extraction_text="IC50 of 0.4 µM",
335
- attributes={"value": "0.4", "unit": "µM", "assay_type": "IC50"},
355
+ attributes={
356
+ "value": "0.4",
357
+ "unit": "µM",
358
+ "assay_type": "IC50",
359
+ "compound_name": "Gefitinib",
360
+ },
336
361
  ),
337
362
  lx.data.Extraction(
338
363
  extraction_class="mechanism_of_action",
@@ -418,7 +443,13 @@ _TB_EXAMPLE_1 = lx.data.ExampleData(
418
443
  lx.data.Extraction(
419
444
  extraction_class="bioactivity",
420
445
  extraction_text="MIC of 0.03 ug/mL",
421
- attributes={"value": "0.03", "unit": "ug/mL", "assay_type": "MIC", "strain": "H37Rv"},
446
+ attributes={
447
+ "value": "0.03",
448
+ "unit": "ug/mL",
449
+ "assay_type": "MIC",
450
+ "strain": "H37Rv",
451
+ "compound_name": "Bedaquiline",
452
+ },
422
453
  ),
423
454
  lx.data.Extraction(
424
455
  extraction_class="assay",
@@ -491,12 +522,24 @@ _TB_EXAMPLE_2 = lx.data.ExampleData(
491
522
  lx.data.Extraction(
492
523
  extraction_class="bioactivity",
493
524
  extraction_text="MIC of 1 ng/mL",
494
- attributes={"value": "1", "unit": "ng/mL", "assay_type": "MIC", "strain": "H37Rv"},
525
+ attributes={
526
+ "value": "1",
527
+ "unit": "ng/mL",
528
+ "assay_type": "MIC",
529
+ "strain": "H37Rv",
530
+ "compound_name": "BTZ043",
531
+ },
495
532
  ),
496
533
  lx.data.Extraction(
497
534
  extraction_class="bioactivity",
498
535
  extraction_text="MIC of 4 ng/mL",
499
- attributes={"value": "4", "unit": "ng/mL", "assay_type": "MIC", "strain": "Erdman"},
536
+ attributes={
537
+ "value": "4",
538
+ "unit": "ng/mL",
539
+ "assay_type": "MIC",
540
+ "strain": "Erdman",
541
+ "compound_name": "BTZ043",
542
+ },
500
543
  ),
501
544
  lx.data.Extraction(
502
545
  extraction_class="compound_name",
@@ -510,7 +553,12 @@ _TB_EXAMPLE_2 = lx.data.ExampleData(
510
553
  lx.data.Extraction(
511
554
  extraction_class="bioactivity",
512
555
  extraction_text="MIC of 0.6 ng/mL",
513
- attributes={"value": "0.6", "unit": "ng/mL", "assay_type": "MIC"},
556
+ attributes={
557
+ "value": "0.6",
558
+ "unit": "ng/mL",
559
+ "assay_type": "MIC",
560
+ "compound_name": "PBTZ169",
561
+ },
514
562
  ),
515
563
  lx.data.Extraction(
516
564
  extraction_class="mechanism_of_action",
@@ -566,7 +614,12 @@ _TB_EXAMPLE_3 = lx.data.ExampleData(
566
614
  lx.data.Extraction(
567
615
  extraction_class="bioactivity",
568
616
  extraction_text="IC50 of 85 nM",
569
- attributes={"value": "85", "unit": "nM", "assay_type": "IC50"},
617
+ attributes={
618
+ "value": "85",
619
+ "unit": "nM",
620
+ "assay_type": "IC50",
621
+ "compound_name": "Compound 14a",
622
+ },
570
623
  ),
571
624
  lx.data.Extraction(
572
625
  extraction_class="screening_method",
@@ -584,7 +637,13 @@ _TB_EXAMPLE_3 = lx.data.ExampleData(
584
637
  lx.data.Extraction(
585
638
  extraction_class="bioactivity",
586
639
  extraction_text="MIC90 of 0.5 uM",
587
- attributes={"value": "0.5", "unit": "uM", "assay_type": "MIC90", "strain": "H37Rv"},
640
+ attributes={
641
+ "value": "0.5",
642
+ "unit": "uM",
643
+ "assay_type": "MIC90",
644
+ "strain": "H37Rv",
645
+ "compound_name": "Compound 14a",
646
+ },
588
647
  ),
589
648
  lx.data.Extraction(
590
649
  extraction_class="assay",
@@ -594,7 +653,12 @@ _TB_EXAMPLE_3 = lx.data.ExampleData(
594
653
  lx.data.Extraction(
595
654
  extraction_class="bioactivity",
596
655
  extraction_text="EC50 of 1.2 uM",
597
- attributes={"value": "1.2", "unit": "uM", "assay_type": "EC50"},
656
+ attributes={
657
+ "value": "1.2",
658
+ "unit": "uM",
659
+ "assay_type": "EC50",
660
+ "compound_name": "Compound 14a",
661
+ },
598
662
  ),
599
663
  lx.data.Extraction(
600
664
  extraction_class="assay",
@@ -604,7 +668,12 @@ _TB_EXAMPLE_3 = lx.data.ExampleData(
604
668
  lx.data.Extraction(
605
669
  extraction_class="bioactivity",
606
670
  extraction_text="MIC of 3.1 uM",
607
- attributes={"value": "3.1", "unit": "uM", "assay_type": "MIC"},
671
+ attributes={
672
+ "value": "3.1",
673
+ "unit": "uM",
674
+ "assay_type": "MIC",
675
+ "compound_name": "Compound 14a",
676
+ },
608
677
  ),
609
678
  lx.data.Extraction(
610
679
  extraction_class="assay",
@@ -614,7 +683,12 @@ _TB_EXAMPLE_3 = lx.data.ExampleData(
614
683
  lx.data.Extraction(
615
684
  extraction_class="bioactivity",
616
685
  extraction_text="CC50 >50 uM",
617
- attributes={"value": ">50", "unit": "uM", "assay_type": "CC50"},
686
+ attributes={
687
+ "value": ">50",
688
+ "unit": "uM",
689
+ "assay_type": "CC50",
690
+ "compound_name": "Compound 14a",
691
+ },
618
692
  ),
619
693
  ],
620
694
  )
@@ -18,9 +18,12 @@ BIOLOGY_PROMPT = (
18
18
 
19
19
  BIOACTIVITY_PROMPT = (
20
20
  "Extract bioactivity measurements and assay data from the text. "
21
- "Include: potency values (IC50, EC50, Ki, Kd, GI50, CC50), selectivity ratios, "
21
+ "Include: potency values (IC50, MIC, EC50, Ki, Kd, GI50, CC50), selectivity ratios, "
22
22
  "percent inhibition values, and Hill coefficients. "
23
- "For each value, capture the numeric value, unit (nM, µM, mM), and measurement type. "
23
+ "For each value, capture the numeric value, unit (nM, µM, mM, µg/mL, ng/mL), and measurement type. "
24
+ "Also capture the compound — its name, code name, or identifier (e.g. 'Compound 7', 'BTZ043', "
25
+ "'CHEMBL1234', 'SACC-3000') — that the measurement applies to, as a 'compound_name' attribute, "
26
+ "if it can be identified from the surrounding context. "
24
27
  "Also extract assay descriptions: cell lines used (e.g. 'HeLa', 'A549'), assay formats "
25
28
  "(e.g. 'cell viability', 'binding assay', 'enzymatic assay'), and organisms."
26
29
  )
@@ -40,8 +43,9 @@ FULL_PROMPT = (
40
43
  "- Chemical entities: compound names (generic, IUPAC, code names, brand names), "
41
44
  "SMILES strings (only if explicitly written), CAS numbers, molecular formulas.\n"
42
45
  "- Biological targets: protein names, gene names, receptor names, enzyme names, pathways.\n"
43
- "- Bioactivity data: IC50, EC50, Ki, Kd, and other potency/selectivity measurements "
44
- "with their numeric values and units.\n"
46
+ "- Bioactivity data: IC50, MIC, EC50, Ki, Kd, and other potency/selectivity measurements "
47
+ "with their numeric values, units, and the compound name or identifier they apply to "
48
+ "(captured as a 'compound_name' attribute).\n"
45
49
  "- Assay information: cell lines, assay formats, experimental organisms.\n"
46
50
  "- Diseases and indications: cancer types, disease names, therapeutic areas.\n"
47
51
  "- Mechanisms of action: binding modes, inhibition types, selectivity descriptions.\n"
@@ -52,6 +56,9 @@ FULL_PROMPT = (
52
56
 
53
57
  TB_PROMPT = (
54
58
  "Extract drug discovery entities from this tuberculosis research text.\n\n"
59
+ "For each bioactivity measurement (IC50, MIC, MIC90, EC50, CC50, etc.), capture the "
60
+ "compound name, code, or identifier it belongs to as a 'compound_name' attribute "
61
+ "(e.g. 'BTZ043 showed a MIC of 1 ng/mL' → compound_name: 'BTZ043').\n\n"
55
62
  "DISAMBIGUATION RULES:\n"
56
63
  "- Mycobacterial proteins (e.g. ClpC1, DprE1, InhA, AtpE, MmpL3, QcrB) "
57
64
  "are biological targets, NOT compounds.\n"
File without changes
File without changes
File without changes