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 refiner::refine_author;
32pub use refiner::refine_copyright;
33pub use types::{AuthorDetection, CopyrightDetection, HolderDetection};
34
35pub fn detect_copyrights(
36    content: &str,
37    max_runtime: Option<Duration>,
38) -> (
39    Vec<CopyrightDetection>,
40    Vec<HolderDetection>,
41    Vec<AuthorDetection>,
42) {
43    if let Some(max_runtime) = max_runtime {
44        detector::detect_copyrights_from_text_with_deadline(content, Some(max_runtime))
45    } else {
46        detector::detect_copyrights_from_text(content)
47    }
48}