Skip to content

Add script to predict and mark required phrases in license rules - #5262

Open
Kaushik-Kumar-CEG wants to merge 1 commit into
aboutcode-org:developfrom
Kaushik-Kumar-CEG:gsoc/inject-ml-phrases
Open

Add script to predict and mark required phrases in license rules#5262
Kaushik-Kumar-CEG wants to merge 1 commit into
aboutcode-org:developfrom
Kaushik-Kumar-CEG:gsoc/inject-ml-phrases

Conversation

@Kaushik-Kumar-CEG

@Kaushik-Kumar-CEG Kaushik-Kumar-CEG commented Aug 9, 2026

Copy link
Copy Markdown

Part of #5243. Depends on #5222.

Adds a command that loads the hardened required phrase model, predicts BIOES spans for eligible license rules, validates the candidates with ScanCode's existing helpers, and marks accepted phrases with {{ }}.

The command:

  • accepts a local final model directory or Hugging Face repository
  • validates the final model and its published artifact hashes before inference
  • preserves complete-word token alignment when input is truncated
  • skips rules that already contain required phrases or cannot be updated
  • applies changes in memory and writes each changed rule once
  • supports expression filtering, dry runs, limits, and verbose output
  • records ml_model as the phrase source

An installable package version is also available in scancode-required-phrases on branch gsoc/prediction-injection. It includes the add-model-required-phrases entry point, tests, and documentation. Its complete test suite passes with 185 tests, and its documentation and distributions build successfully.

The license index must be rebuilt after writing rules

disclosure : used Claude to help review and clean up few bugs in script

@Kaushik-Kumar-CEG Kaushik-Kumar-CEG changed the title Add tool to mark required phrases using the trained tagger Add script to predict and mark required phrases in license rules Aug 9, 2026
@Kaushik-Kumar-CEG
Kaushik-Kumar-CEG marked this pull request as draft August 9, 2026 16:25
@Kaushik-Kumar-CEG
Kaushik-Kumar-CEG marked this pull request as ready for review September 7, 2026 13:40
Signed-off-by: Kaushik Kumar <kaushikrjpm10@gmail.com>

@Shriprasad-P Shriprasad-P left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review

PR: Add script to predict and mark required phrases in license rules

Touched: etc/scripts/dataset_pipeline/add_ml_phrases.py, etc/scripts/dataset_pipeline/test_add_ml_phrases.py

  • Addresses a concrete correctness/reliability issue based on the title and diff.
  • Security-sensitive change — please double-check edge cases and defaults.
  • Diff is fairly large (+655/-0); a short summary of risk areas from the author would help reviewers.

Commenting as a drive-by reviewer after reading the diff. Happy to look again if maintainers want a deeper pass on a specific file.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants