Skip to content

Fix is_http for segmentation model to use token-based detection#669

Draft
de-code wants to merge 1 commit into
mainfrom
fix-is-http-for-segmentation-model-to-use-token-based-detection
Draft

Fix is_http for segmentation model to use token-based detection#669
de-code wants to merge 1 commit into
mainfrom
fix-is-http-for-segmentation-model-to-use-token-based-detection

Conversation

@de-code

@de-code de-code commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

part of https://github.com/eLifePathways/ScienceBeam2.0/issues/102

The segmentation model's FeatureDef called get_str_is_http(), which reads self.is_http. However, SegmentationLineFeaturesProvider reuses a single SegmentationLineFeatures instance and never sets is_http in its line loop, so the feature always returned '0'.

Switched to get_str_is_http_token_based() (token_text.lower().startswith ('http')), which matches GROBID's Pattern.compile("http(s)?").find() check on the first token of each line. This affects 11 docs with 287 total Δlabels in the segmentation model, 142 of which cascade into header detection and downstream affiliation extraction.

part of eLifePathways/ScienceBeam2.0#88

The segmentation model's FeatureDef called get_str_is_http(), which
reads self.is_http. However, SegmentationLineFeaturesProvider reuses a
single SegmentationLineFeatures instance and never sets is_http in its
line loop, so the feature always returned '0'.

Switched to get_str_is_http_token_based() (token_text.lower().startswith
('http')), which matches GROBID's Pattern.compile("http(s)?").find()
check on the first token of each line. This affects 11 docs with 287
total Δlabels in the segmentation model, 142 of which cascade into
header detection and downstream affiliation extraction.
@github-actions

Copy link
Copy Markdown

ScienceBeam Parser Evaluation

Overall (280 docs across 6 corpora)

grobid 0.9.0-crf (default): 280 docs | sciencebeam-parser:main-dc866983-20260616.1044 (grobid_crf): 280 docs | sciencebeam-parser:pr-669-fd92fdfd-20260616.1814 (grobid_crf): 280 docs

Field (method) Type grobid 0.9.0-crf (default) sciencebeam-parser:main-dc866983-20260616.1044 (grobid_crf) sciencebeam-parser:pr-669-fd92fdfd-20260616.1814 (grobid_crf) Δ grobid 0.9.0-crf (default) Δ sciencebeam-parser:main-dc866983-20260616.1044 (grobid_crf)
title (exact) string 0.517 0.513 0.509 -0.008 -0.004
title (levenshtein) string 0.636 0.643 0.633 -0.004 -0.010
title (edit_sim) string 0.631 0.636 0.630 -0.001 -0.006
abstract (levenshtein) string 0.640 0.636 0.636 -0.004 +0.000
abstract (edit_sim) string 0.660 0.660 0.658 -0.001 -0.001
author_full_names (levenshtein) partial_ulist 0.734 0.731 0.731 -0.004 -0.000
author_full_names (edit_sim) partial_ulist 0.740 0.745 0.745 +0.005 -0.000
affiliation_text (levenshtein) partial_ulist 0.443 0.443 0.440 -0.003 -0.003
affiliation_text (edit_sim) partial_ulist 0.558 0.542 0.539 -0.018 -0.003
keywords (levenshtein) partial_ulist 0.479 0.000 0.000 -0.479 +0.000
keywords (edit_sim) partial_ulist 0.444 0.000 0.000 -0.444 +0.000
body_section_titles (levenshtein) partial_list 0.228 0.222 0.221 -0.007 -0.001
body_section_titles (edit_sim) partial_list 0.228 0.227 0.226 -0.002 -0.001
acknowledgement (levenshtein) string 0.454 0.385 0.385 -0.069 +0.000
acknowledgement (edit_sim) string 0.463 0.399 0.397 -0.066 -0.001
first_reference_text (levenshtein) string 0.366 0.372 0.372 +0.006 +0.000
first_reference_text (edit_sim) string 0.504 0.507 0.507 +0.003 +0.000
reference_title (levenshtein) partial_list 0.320 0.319 0.320 -0.000 +0.001
reference_title (edit_sim) partial_list 0.329 0.337 0.337 +0.008 +0.001
reference_doi (levenshtein) partial_ulist 0.544 0.427 0.426 -0.118 -0.000
reference_doi (edit_sim) partial_ulist 0.489 0.398 0.396 -0.093 -0.002
biorxiv (47 docs)

grobid 0.9.0-crf (default): 47 docs | sciencebeam-parser:main-dc866983-20260616.1044 (grobid_crf): 47 docs | sciencebeam-parser:pr-669-fd92fdfd-20260616.1814 (grobid_crf): 47 docs

Field (method) Type grobid 0.9.0-crf (default) sciencebeam-parser:main-dc866983-20260616.1044 (grobid_crf) sciencebeam-parser:pr-669-fd92fdfd-20260616.1814 (grobid_crf) Δ grobid 0.9.0-crf (default) Δ sciencebeam-parser:main-dc866983-20260616.1044 (grobid_crf)
title (exact) string 0.867 0.840 0.840 -0.028 +0.000
title (levenshtein) string 0.956 0.956 0.956 +0.000 +0.000
title (edit_sim) string 0.942 0.942 0.942 +0.000 +0.000
abstract (levenshtein) string 0.779 0.779 0.779 +0.000 +0.000
abstract (edit_sim) string 0.773 0.780 0.771 -0.002 -0.009
author_full_names (levenshtein) partial_ulist 0.977 0.975 0.975 -0.002 +0.000
author_full_names (edit_sim) partial_ulist 0.946 0.951 0.951 +0.005 +0.000
affiliation_text (levenshtein) partial_ulist 0.877 0.816 0.816 -0.060 +0.000
affiliation_text (edit_sim) partial_ulist 0.877 0.821 0.821 -0.056 +0.000
keywords (levenshtein) partial_ulist 0.835 0.000 0.000 -0.835 +0.000
keywords (edit_sim) partial_ulist 0.834 0.000 0.000 -0.834 +0.000
body_section_titles (levenshtein) partial_list 0.456 0.376 0.373 -0.083 -0.003
body_section_titles (edit_sim) partial_list 0.432 0.373 0.371 -0.062 -0.002
acknowledgement (levenshtein) string 0.732 0.548 0.548 -0.184 +0.000
acknowledgement (edit_sim) string 0.731 0.586 0.586 -0.146 +0.000
first_reference_text (levenshtein) string 0.905 0.905 0.905 +0.000 +0.000
first_reference_text (edit_sim) string 0.869 0.869 0.869 +0.000 +0.000
reference_title (levenshtein) partial_list 0.694 0.730 0.733 +0.038 +0.003
reference_title (edit_sim) partial_list 0.653 0.690 0.693 +0.039 +0.003
reference_doi (levenshtein) partial_ulist 0.865 0.858 0.860 -0.005 +0.002
reference_doi (edit_sim) partial_ulist 0.824 0.821 0.823 -0.001 +0.002
ore (49 docs)

grobid 0.9.0-crf (default): 49 docs | sciencebeam-parser:main-dc866983-20260616.1044 (grobid_crf): 49 docs | sciencebeam-parser:pr-669-fd92fdfd-20260616.1814 (grobid_crf): 49 docs

Field (method) Type grobid 0.9.0-crf (default) sciencebeam-parser:main-dc866983-20260616.1044 (grobid_crf) sciencebeam-parser:pr-669-fd92fdfd-20260616.1814 (grobid_crf) Δ grobid 0.9.0-crf (default) Δ sciencebeam-parser:main-dc866983-20260616.1044 (grobid_crf)
title (exact) string 0.537 0.515 0.492 -0.045 -0.023
title (levenshtein) string 0.600 0.639 0.580 -0.020 -0.059
title (edit_sim) string 0.717 0.742 0.711 -0.006 -0.031
abstract (levenshtein) string 0.693 0.693 0.693 +0.000 +0.000
abstract (edit_sim) string 0.738 0.740 0.740 +0.002 +0.000
author_full_names (levenshtein) partial_ulist 0.802 0.798 0.797 -0.005 -0.001
author_full_names (edit_sim) partial_ulist 0.792 0.794 0.793 +0.001 -0.001
affiliation_text (levenshtein) partial_ulist 0.564 0.507 0.502 -0.062 -0.005
affiliation_text (edit_sim) partial_ulist 0.577 0.514 0.509 -0.068 -0.005
keywords (levenshtein) partial_ulist 0.297 0.000 0.000 -0.297 +0.000
keywords (edit_sim) partial_ulist 0.292 0.000 0.000 -0.292 +0.000
body_section_titles (levenshtein) partial_list 0.198 0.228 0.223 +0.025 -0.004
body_section_titles (edit_sim) partial_list 0.232 0.271 0.268 +0.036 -0.002
acknowledgement (levenshtein) string 0.921 0.885 0.885 -0.035 +0.000
acknowledgement (edit_sim) string 0.935 0.881 0.875 -0.061 -0.006
first_reference_text (levenshtein) string 0.444 0.469 0.469 +0.024 +0.000
first_reference_text (edit_sim) string 0.620 0.606 0.606 -0.013 +0.000
reference_title (levenshtein) partial_list 0.229 0.283 0.284 +0.055 +0.001
reference_title (edit_sim) partial_list 0.262 0.312 0.312 +0.050 +0.001
reference_doi (levenshtein) partial_ulist 0.641 0.033 0.032 -0.610 -0.001
reference_doi (edit_sim) partial_ulist 0.494 0.010 0.009 -0.485 -0.000
pkp (50 docs)

grobid 0.9.0-crf (default): 50 docs | sciencebeam-parser:main-dc866983-20260616.1044 (grobid_crf): 50 docs | sciencebeam-parser:pr-669-fd92fdfd-20260616.1814 (grobid_crf): 50 docs

Field (method) Type grobid 0.9.0-crf (default) sciencebeam-parser:main-dc866983-20260616.1044 (grobid_crf) sciencebeam-parser:pr-669-fd92fdfd-20260616.1814 (grobid_crf) Δ grobid 0.9.0-crf (default) Δ sciencebeam-parser:main-dc866983-20260616.1044 (grobid_crf)
title (exact) string 0.592 0.592 0.592 +0.000 +0.000
title (levenshtein) string 0.649 0.649 0.649 +0.000 +0.000
title (edit_sim) string 0.542 0.542 0.542 +0.000 +0.000
abstract (levenshtein) string 0.750 0.750 0.750 +0.000 +0.000
abstract (edit_sim) string 0.722 0.722 0.722 -0.000 +0.000
author_full_names (levenshtein) partial_ulist 0.836 0.847 0.847 +0.010 +0.000
author_full_names (edit_sim) partial_ulist 0.819 0.849 0.849 +0.030 +0.000
affiliation_text (levenshtein) partial_ulist 0.400 0.435 0.435 +0.035 +0.000
affiliation_text (edit_sim) partial_ulist 0.470 0.466 0.466 -0.004 +0.000
keywords (levenshtein) partial_ulist 0.000 0.000 0.000 +0.000 +0.000
keywords (edit_sim) partial_ulist 0.000 0.000 0.000 +0.000 +0.000
body_section_titles (levenshtein) partial_list 0.000 0.000 0.000 +0.000 +0.000
body_section_titles (edit_sim) partial_list 0.000 0.000 0.000 +0.000 +0.000
acknowledgement (levenshtein) string 0.000 0.000 0.000 +0.000 +0.000
acknowledgement (edit_sim) string 0.000 0.000 0.000 +0.000 +0.000
first_reference_text (levenshtein) string 0.000 0.000 0.000 +0.000 +0.000
first_reference_text (edit_sim) string 0.000 0.000 0.000 +0.000 +0.000
reference_title (levenshtein) partial_list 0.000 0.000 0.000 +0.000 +0.000
reference_title (edit_sim) partial_list 0.000 0.000 0.000 +0.000 +0.000
reference_doi (levenshtein) partial_ulist 0.000 0.000 0.000 +0.000 +0.000
reference_doi (edit_sim) partial_ulist 0.000 0.000 0.000 +0.000 +0.000
scielo_br (50 docs)

grobid 0.9.0-crf (default): 50 docs | sciencebeam-parser:main-dc866983-20260616.1044 (grobid_crf): 50 docs | sciencebeam-parser:pr-669-fd92fdfd-20260616.1814 (grobid_crf): 50 docs

Field (method) Type grobid 0.9.0-crf (default) sciencebeam-parser:main-dc866983-20260616.1044 (grobid_crf) sciencebeam-parser:pr-669-fd92fdfd-20260616.1814 (grobid_crf) Δ grobid 0.9.0-crf (default) Δ sciencebeam-parser:main-dc866983-20260616.1044 (grobid_crf)
title (exact) string 0.462 0.485 0.485 +0.023 +0.000
title (levenshtein) string 0.485 0.485 0.485 +0.000 +0.000
title (edit_sim) string 0.512 0.512 0.512 +0.000 +0.000
abstract (levenshtein) string 0.697 0.677 0.677 -0.020 +0.000
abstract (edit_sim) string 0.666 0.652 0.652 -0.013 +0.000
author_full_names (levenshtein) partial_ulist 0.607 0.592 0.592 -0.015 +0.000
author_full_names (edit_sim) partial_ulist 0.658 0.653 0.653 -0.005 +0.000
affiliation_text (levenshtein) partial_ulist 0.000 0.000 0.000 +0.000 +0.000
affiliation_text (edit_sim) partial_ulist 0.298 0.295 0.295 -0.003 +0.000
keywords (levenshtein) partial_ulist 0.538 0.000 0.000 -0.538 +0.000
keywords (edit_sim) partial_ulist 0.515 0.000 0.000 -0.515 +0.000
body_section_titles (levenshtein) partial_list 0.265 0.291 0.291 +0.026 +0.000
body_section_titles (edit_sim) partial_list 0.275 0.295 0.295 +0.020 +0.000
acknowledgement (levenshtein) string 0.667 0.571 0.571 -0.095 +0.000
acknowledgement (edit_sim) string 0.704 0.618 0.618 -0.086 +0.000
first_reference_text (levenshtein) string 0.083 0.043 0.043 -0.041 +0.000
first_reference_text (edit_sim) string 0.399 0.394 0.394 -0.004 +0.000
reference_title (levenshtein) partial_list 0.388 0.318 0.318 -0.070 +0.000
reference_title (edit_sim) partial_list 0.407 0.365 0.365 -0.042 +0.000
reference_doi (levenshtein) partial_ulist 0.934 0.897 0.897 -0.038 +0.000
reference_doi (edit_sim) partial_ulist 0.890 0.842 0.842 -0.048 +0.000
scielo_mx (34 docs)

grobid 0.9.0-crf (default): 34 docs | sciencebeam-parser:main-dc866983-20260616.1044 (grobid_crf): 34 docs | sciencebeam-parser:pr-669-fd92fdfd-20260616.1814 (grobid_crf): 34 docs

Field (method) Type grobid 0.9.0-crf (default) sciencebeam-parser:main-dc866983-20260616.1044 (grobid_crf) sciencebeam-parser:pr-669-fd92fdfd-20260616.1814 (grobid_crf) Δ grobid 0.9.0-crf (default) Δ sciencebeam-parser:main-dc866983-20260616.1044 (grobid_crf)
title (exact) string 0.057 0.057 0.057 +0.000 +0.000
title (levenshtein) string 0.489 0.489 0.489 +0.000 +0.000
title (edit_sim) string 0.474 0.474 0.474 +0.000 +0.000
abstract (levenshtein) string 0.111 0.111 0.111 +0.000 +0.000
abstract (edit_sim) string 0.385 0.386 0.386 +0.001 +0.000
author_full_names (levenshtein) partial_ulist 0.670 0.670 0.670 +0.000 +0.000
author_full_names (edit_sim) partial_ulist 0.654 0.654 0.654 +0.000 +0.000
affiliation_text (levenshtein) partial_ulist 0.099 0.143 0.143 +0.044 +0.000
affiliation_text (edit_sim) partial_ulist 0.423 0.424 0.424 +0.001 +0.000
keywords (levenshtein) partial_ulist 0.598 0.000 0.000 -0.598 +0.000
keywords (edit_sim) partial_ulist 0.556 0.000 0.000 -0.556 +0.000
body_section_titles (levenshtein) partial_list 0.000 0.000 0.000 +0.000 +0.000
body_section_titles (edit_sim) partial_list 0.000 0.000 0.000 +0.000 +0.000
acknowledgement (levenshtein) string 0.000 0.000 0.000 +0.000 +0.000
acknowledgement (edit_sim) string 0.000 0.000 0.000 +0.000 +0.000
first_reference_text (levenshtein) string 0.432 0.432 0.432 +0.000 +0.000
first_reference_text (edit_sim) string 0.538 0.540 0.540 +0.002 +0.000
reference_title (levenshtein) partial_list 0.327 0.326 0.326 -0.000 +0.001
reference_title (edit_sim) partial_list 0.342 0.345 0.346 +0.004 +0.001
reference_doi (levenshtein) partial_ulist 0.000 0.000 0.000 +0.000 +0.000
reference_doi (edit_sim) partial_ulist 0.000 0.000 0.000 +0.000 +0.000
scielo_preprints-jats (50 docs)

grobid 0.9.0-crf (default): 50 docs | sciencebeam-parser:main-dc866983-20260616.1044 (grobid_crf): 50 docs | sciencebeam-parser:pr-669-fd92fdfd-20260616.1814 (grobid_crf): 50 docs

Field (method) Type grobid 0.9.0-crf (default) sciencebeam-parser:main-dc866983-20260616.1044 (grobid_crf) sciencebeam-parser:pr-669-fd92fdfd-20260616.1814 (grobid_crf) Δ grobid 0.9.0-crf (default) Δ sciencebeam-parser:main-dc866983-20260616.1044 (grobid_crf)
title (exact) string 0.462 0.462 0.462 +0.000 +0.000
title (levenshtein) string 0.611 0.611 0.611 +0.000 +0.000
title (edit_sim) string 0.571 0.572 0.571 +0.000 -0.001
abstract (levenshtein) string 0.649 0.649 0.649 +0.000 +0.000
abstract (edit_sim) string 0.595 0.600 0.600 +0.004 +0.000
author_full_names (levenshtein) partial_ulist 0.509 0.499 0.500 -0.009 +0.001
author_full_names (edit_sim) partial_ulist 0.557 0.553 0.554 -0.003 +0.001
affiliation_text (levenshtein) partial_ulist 0.636 0.686 0.674 +0.038 -0.013
affiliation_text (edit_sim) partial_ulist 0.677 0.712 0.700 +0.023 -0.012
keywords (levenshtein) partial_ulist 0.662 0.000 0.000 -0.662 +0.000
keywords (edit_sim) partial_ulist 0.522 0.000 0.000 -0.522 +0.000
body_section_titles (levenshtein) partial_list 0.388 0.375 0.375 -0.013 +0.000
body_section_titles (edit_sim) partial_list 0.367 0.361 0.361 -0.006 +0.000
acknowledgement (levenshtein) string 0.286 0.200 0.200 -0.086 +0.000
acknowledgement (edit_sim) string 0.286 0.200 0.200 -0.086 +0.000
first_reference_text (levenshtein) string 0.387 0.438 0.438 +0.050 +0.000
first_reference_text (edit_sim) string 0.635 0.667 0.667 +0.031 +0.000
reference_title (levenshtein) partial_list 0.304 0.283 0.283 -0.020 -0.000
reference_title (edit_sim) partial_list 0.333 0.331 0.331 -0.002 -0.000
reference_doi (levenshtein) partial_ulist 0.671 0.654 0.651 -0.020 -0.003
reference_doi (edit_sim) partial_ulist 0.592 0.606 0.595 +0.003 -0.012

@de-code

de-code commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator Author

For some reasons this actually caused more regressions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant