Skip to main content

provenant/copyright/
mod.rs

1// SPDX-FileCopyrightText: Provenant contributors
2// SPDX-License-Identifier: Apache-2.0
3
4//! Copyright detection module.
5//!
6//! Detects copyright statements, holder names, and author information
7//! from source code files using a four-stage pipeline:
8//! 1. Text preparation (normalization)
9//! 2. Candidate line selection
10//! 3. Lexing (POS tagging) and parsing (grammar rules)
11//! 4. Refinement and junk filtering
12
13use std::time::Duration;
14
15mod candidates;
16mod credits;
17mod detector;
18mod detector_input_normalization;
19pub mod golden_utils;
20mod grammar;
21mod hints;
22mod lexer;
23mod line_tracking;
24mod parser;
25mod patterns;
26mod prepare;
27mod refiner;
28mod types;
29
30pub use credits::{detect_credits_authors, is_credits_file};
31pub(crate) use prepare::prepare_text_line;
32pub(crate) use refiner::refine_author;
33pub use refiner::refine_copyright;
34pub use types::{AuthorDetection, CopyrightDetection, HolderDetection};
35
36pub fn detect_copyrights(
37    content: &str,
38    max_runtime: Option<Duration>,
39) -> (
40    Vec<CopyrightDetection>,
41    Vec<HolderDetection>,
42    Vec<AuthorDetection>,
43) {
44    if let Some(max_runtime) = max_runtime {
45        detector::detect_copyrights_from_text_with_deadline(content, Some(max_runtime))
46    } else {
47        detector::detect_copyrights_from_text(content)
48    }
49}