1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
// Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
use askalono::{Store, TextData};
use std::path::Path;
// Note: this example is stupid slow because it loads and parses licenses
// each run instead of persisting to a cache file. Expect runs to take ~20s;
// 19.99s of that to be loading license data.
fn main() {
// create a new license text store
let mut store = Store::new();
// load up data from SPDX JSON files, opting to not embed full text
println!("Loading SPDX data, this may take a while...");
store
.load_spdx(
Path::new(concat!(
env!("CARGO_MANIFEST_DIR"),
"/datasets/modules/spdx-license-list-data/json/details"
)),
false,
)
.unwrap();
// load input text
println!("Parsing input text");
let input: TextData = include_str!("../LICENSE").into();
// do the heavy lifting
println!("Scoring licenses");
let matched = store.analyze(&input);
println!("{:?}", matched);
}
|