Skip to content

Commit 972386e

Browse files
committed
fix(parser): also drop short license-tail fragments
The license sentence splits across rows; the final 'scholarly works.' fragment slipped through. Drop short (<=4 word) rows that contain a license-tail fragment, guarded by length so real prose using the phrase in a full sentence is kept.
1 parent b201d78 commit 972386e

2 files changed

Lines changed: 25 additions & 3 deletions

File tree

pkg/parser/boilerplate_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ func TestIsBoilerplateLine(t *testing.T) {
1010
"This work is licensed under a Creative Commons Attribution 4.0 License.",
1111
"arXiv:1706.03762v7 [cs.CL] 2 Aug 2023",
1212
"Preprint. Under review.",
13+
"scholarly works.", // short license-tail fragment
1314
}
1415
for _, s := range boiler {
1516
if !isBoilerplateLine(s) {
@@ -24,6 +25,7 @@ func TestIsBoilerplateLine(t *testing.T) {
2425
"Results",
2526
"References",
2627
"Recommendation: initiate low-dose therapy (evidence grade A).",
28+
"This study was published in several scholarly works over the past decade.", // 'scholarly works' inside real prose
2729
}
2830
for _, s := range content {
2931
if isBoilerplateLine(s) {

pkg/parser/pdf.go

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -478,10 +478,22 @@ var boilerplateSignatures = []string{
478478
"preprint submitted to",
479479
}
480480

481+
// boilerplateFragments are short tails of a license sentence that the
482+
// PDF splits onto their own row (e.g. "...journalistic or scholarly
483+
// works." → a lone "scholarly works." row). These are too generic to
484+
// match anywhere in a line, so we only drop them when the whole row
485+
// is a short fragment (≤ 4 words) — real prose using the phrase lives
486+
// inside a longer sentence.
487+
var boilerplateFragments = []string{
488+
"scholarly works",
489+
"journalistic or",
490+
"or scholarly",
491+
}
492+
481493
// isBoilerplateLine reports whether a row is publisher/license noise.
482-
// Matches the curated signature list, plus the bare arXiv id stamp
483-
// ("arXiv:2401.01234v2 [cs.CL] 5 Jan 2024") that arXiv prints down
484-
// the page margin.
494+
// Matches the curated signature list, the bare arXiv id stamp
495+
// ("arXiv:2401.01234v2 [cs.CL] 5 Jan 2024"), and short license-tail
496+
// fragments.
485497
func isBoilerplateLine(s string) bool {
486498
low := strings.ToLower(strings.TrimSpace(s))
487499
for _, sig := range boilerplateSignatures {
@@ -493,6 +505,14 @@ func isBoilerplateLine(s string) bool {
493505
if strings.HasPrefix(low, "arxiv:") && len(low) > 6 && low[6] >= '0' && low[6] <= '9' {
494506
return true
495507
}
508+
// Short license-tail fragments.
509+
if len(strings.Fields(low)) <= 4 {
510+
for _, frag := range boilerplateFragments {
511+
if strings.Contains(low, frag) {
512+
return true
513+
}
514+
}
515+
}
496516
return false
497517
}
498518

0 commit comments

Comments
 (0)