Struct askalono::ScanStrategy [−][src]
pub struct ScanStrategy<'a> { /* fields omitted */ }
A ScanStrategy
can be used as a high-level wrapped over a Store
's
analysis logic.
A strategy configured here can be run repeatedly to scan a document for multiple licenses, or to automatically optimize to locate texts within a larger text.
Examples
use askalono::{ScanStrategy, Store}; let store = Store::new(); // [...] let strategy = ScanStrategy::new(&store) .confidence_threshold(0.9) .optimize(true); let results = strategy.scan(&"my text to scan".into())?;
Methods
impl<'a> ScanStrategy<'a>
[src]
impl<'a> ScanStrategy<'a>
pub fn new(store: &'a Store) -> ScanStrategy<'a>
[src]
pub fn new(store: &'a Store) -> ScanStrategy<'a>
Construct a new scanning strategy tied to the given Store
.
By default, the strategy has conservative defaults and won't perform any deeper investigaton into the contents of files.
pub fn mode(self, mode: ScanMode) -> Self
[src]
pub fn mode(self, mode: ScanMode) -> Self
Set the scanning mode.
See ScanMode for a description of options. The default mode is Elimination, which is a fast, good general-purpose matcher.
pub fn confidence_threshold(self, confidence_threshold: f32) -> Self
[src]
pub fn confidence_threshold(self, confidence_threshold: f32) -> Self
Set the confidence threshold for this strategy.
The overall license match must meet this number in order to be
reported. Additionally, if contained licenses are reported in the scan
(when optimize
is enabled), they'll also need to meet this bar.
Set this to 1.0 for only exact matches, and 0.0 to report even the weakest match.
pub fn shallow_limit(self, shallow_limit: f32) -> Self
[src]
pub fn shallow_limit(self, shallow_limit: f32) -> Self
Set a fast-exit parameter that allows the strategy to skip the rest of a scan for strong matches.
This should be set higher than the confidence threshold; ideally close to 1.0. If the overall match score is above this limit, the scanner will return early and not bother performing deeper checks.
This is really only useful in conjunction with optimize
. A value of
0.0 will fast-return on any match meeting the confidence threshold,
while a value of 1.0 will only stop on a perfect match.
pub fn optimize(self, optimize: bool) -> Self
[src]
pub fn optimize(self, optimize: bool) -> Self
Indicate whether a deeper scan should be performed.
This is ignored if the shallow limit is met. It's not enabled by
default, however, so if you want deeper results you should set
shallow_limit
fairly high and enable this.
pub fn max_passes(self, max_passes: u16) -> Self
[src]
pub fn max_passes(self, max_passes: u16) -> Self
The maximum number of identifications to perform before exiting a scan of a single text.
This is largely to prevent misconfigurations and infinite loop scenarios, but if you have a document with a large number of licenses then you may want to tune this to a value above the number of licenses you expect to be identified.
pub fn step_size(self, step_size: usize) -> Self
[src]
pub fn step_size(self, step_size: usize) -> Self
Configure the scanning interval (in lines) for TopDown mode.
A smaller step size will be more accurate at a significant cost of speed.
pub fn scan(&self, text: &TextData) -> Result<ScanResult, Error>
[src]
pub fn scan(&self, text: &TextData) -> Result<ScanResult, Error>
Scan the given text content using this strategy's configured preferences.
Returns a ScanResult
containing all discovered information.
Auto Trait Implementations
impl<'a> Send for ScanStrategy<'a>
impl<'a> Send for ScanStrategy<'a>
impl<'a> Sync for ScanStrategy<'a>
impl<'a> Sync for ScanStrategy<'a>