Skip to main content

provenant/copyright/
mod.rs

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