-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #89 from dsietz/development
Close Issue #88
- Loading branch information
Showing
7 changed files
with
78 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
extern crate test_data_generation; | ||
|
||
use std::path::Path; | ||
use test_data_generation::{Profile}; | ||
|
||
fn main() { | ||
// This example demonstrates the ability to conitnuously add new analyzed data to an existing profile. | ||
let profile_file = "./tests/samples/demo-03"; | ||
let mut profile = match Path::new(profile_file).exists() { | ||
true => { | ||
// use existing file | ||
Profile::from_file(profile_file) | ||
}, | ||
false => { | ||
// create new file | ||
println!("Creating new profile: {}", profile_file); | ||
Profile::new_with_id("demo-03".to_string()) | ||
}, | ||
}; | ||
|
||
// analyze the first data set and save the profile. | ||
profile.analyze("Jonny"); | ||
profile.analyze("Jon"); | ||
profile.analyze("Johnathon"); | ||
profile.analyze("John"); | ||
profile.analyze("Jonathon"); | ||
profile.pre_generate(); | ||
profile.save(&profile_file).unwrap(); | ||
println!("My new name is {}", profile.generate().to_string()); | ||
|
||
// analyze the second data set and add it to the saved profile. | ||
let mut profile2 = Profile::from_file(profile_file); | ||
profile2.analyze("Chris"); | ||
profile2.analyze("Kris"); | ||
profile2.analyze("Christopher"); | ||
profile2.analyze("Christian"); | ||
profile2.analyze("Krissy"); | ||
profile2.pre_generate(); | ||
profile2.save(&profile_file).unwrap(); | ||
println!("My new name is {}", profile2.generate().to_string()); | ||
|
||
// analyze the third data set and add it to the saved profile. | ||
let mut profile3 = Profile::from_file(profile_file); | ||
profile3.analyze("Dan"); | ||
profile3.analyze("Danny"); | ||
profile3.analyze("Danyl"); | ||
profile3.analyze("Dannie"); | ||
profile3.analyze("Danathon"); | ||
profile3.pre_generate(); | ||
profile3.save(&profile_file).unwrap(); | ||
println!("My new name is {}", profile3.generate().to_string()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"id":"demo-03","patterns":{"Cccvc":1,"Cccvccvccvc":1,"Cccvccvvc":1,"Ccvc":1,"Ccvccc":1,"Cvc":2,"Cvcc":1,"Cvccc":3,"Cvccvccvc":1,"Cvccvv":1,"Cvcvccvc":2},"pattern_total":15,"pattern_keys":["Cccvc","Cccvccvccvc","Cccvccvvc","Ccvc","Ccvccc","Cvc","Cvcc","Cvccc","Cvccvccvc","Cvccvv","Cvcvccvc"],"pattern_vals":[1,1,1,1,1,2,1,3,1,1,2],"pattern_percentages":[["Cvccc",20.0],["Cvc",13.333333333333334],["Cvcvccvc",13.333333333333334],["Cccvc",6.666666666666667],["Cccvccvccvc",6.666666666666667],["Cccvccvvc",6.666666666666667],["Ccvc",6.666666666666667],["Ccvccc",6.666666666666667],["Cvcc",6.666666666666667],["Cvccvccvc",6.666666666666667],["Cvccvv",6.666666666666667]],"pattern_ranks":[["Cvccc",20.0],["Cvc",33.333333333333336],["Cvcvccvc",46.66666666666667],["Cccvc",53.333333333333336],["Cccvccvccvc",60.0],["Cccvccvvc",66.66666666666667],["Ccvc",73.33333333333334],["Ccvccc",80.00000000000001],["Cvcc",86.66666666666669],["Cvccvccvc",93.33333333333336],["Cvccvv",100.00000000000003]],"sizes":{"3":2,"4":2,"5":4,"6":2,"8":2,"9":2,"11":1},"size_total":15,"size_ranks":[[5,26.666666666666668],[3,40.0],[4,53.333333333333336],[6,66.66666666666667],[8,80.0],[9,93.33333333333333],[11,100.0]],"processors":4,"facts":[[{"key":"J","prior_key":null,"next_key":"o","pattern_placeholder":"C","starts_with":1,"ends_with":0,"index_offset":0},{"key":"y","prior_key":"n","next_key":null,"pattern_placeholder":"c","starts_with":0,"ends_with":1,"index_offset":4},{"key":"J","prior_key":null,"next_key":"o","pattern_placeholder":"C","starts_with":1,"ends_with":0,"index_offset":0},{"key":"J","prior_key":null,"next_key":"o","pattern_placeholder":"C","starts_with":1,"ends_with":0,"index_offset":0},{"key":"a","prior_key":"n","next_key":"t","pattern_placeholder":"v","starts_with":0,"ends_with":0,"index_offset":4},{"key":"n","prior_key":"o","next_key":null,"pattern_placeholder":"c","starts_with":0,"ends_with":1,"index_offset":8},{"key":"J","prior_key":null,"next_key":"o","pattern_placeholder":"C","starts_with":1,"ends_with":0,"index_offset":0},{"key":"J","prior_key":null,"next_key":"o","pattern_placeholder":"C","starts_with":1,"ends_with":0,"index_offset":0},{"key":"t","prior_key":"a","next_key":"h","pattern_placeholder":"c","starts_with":0,"ends_with":0,"index_offset":4},{"key":"C","prior_key":null,"next_key":"h","pattern_placeholder":"C","starts_with":1,"ends_with":0,"index_offset":0},{"key":"s","prior_key":"i","next_key":null,"pattern_placeholder":"c","starts_with":0,"ends_with":1,"index_offset":4},{"key":"K","prior_key":null,"next_key":"r","pattern_placeholder":"C","starts_with":1,"ends_with":0,"index_offset":0},{"key":"C","prior_key":null,"next_key":"h","pattern_placeholder":"C","starts_with":1,"ends_with":0,"index_offset":0},{"key":"s","prior_key":"i","next_key":"t","pattern_placeholder":"c","starts_with":0,"ends_with":0,"index_offset":4},{"key":"h","prior_key":"p","next_key":"e","pattern_placeholder":"c","starts_with":0,"ends_with":0,"index_offset":8},{"key":"C","prior_key":null,"next_key":"h","pattern_placeholder":"C","starts_with":1,"ends_with":0,"index_offset":0},{"key":"s","prior_key":"i","next_key":"t","pattern_placeholder":"c","starts_with":0,"ends_with":0,"index_offset":4},{"key":"n","prior_key":"a","next_key":null,"pattern_placeholder":"c","starts_with":0,"ends_with":1,"index_offset":8},{"key":"K","prior_key":null,"next_key":"r","pattern_placeholder":"C","starts_with":1,"ends_with":0,"index_offset":0},{"key":"s","prior_key":"s","next_key":"y","pattern_placeholder":"c","starts_with":0,"ends_with":0,"index_offset":4},{"key":"D","prior_key":null,"next_key":"a","pattern_placeholder":"C","starts_with":1,"ends_with":0,"index_offset":0},{"key":"D","prior_key":null,"next_key":"a","pattern_placeholder":"C","starts_with":1,"ends_with":0,"index_offset":0},{"key":"y","prior_key":"n","next_key":null,"pattern_placeholder":"c","starts_with":0,"ends_with":1,"index_offset":4},{"key":"D","prior_key":null,"next_key":"a","pattern_placeholder":"C","starts_with":1,"ends_with":0,"index_offset":0},{"key":"l","prior_key":"y","next_key":null,"pattern_placeholder":"c","starts_with":0,"ends_with":1,"index_offset":4},{"key":"D","prior_key":null,"next_key":"a","pattern_placeholder":"C","starts_with":1,"ends_with":0,"index_offset":0},{"key":"i","prior_key":"n","next_key":"e","pattern_placeholder":"v","starts_with":0,"ends_with":0,"index_offset":4},{"key":"D","prior_key":null,"next_key":"a","pattern_placeholder":"C","starts_with":1,"ends_with":0,"index_offset":0},{"key":"t","prior_key":"a","next_key":"h","pattern_placeholder":"c","starts_with":0,"ends_with":0,"index_offset":4}],[{"key":"o","prior_key":"J","next_key":"n","pattern_placeholder":"v","starts_with":0,"ends_with":0,"index_offset":1},{"key":"o","prior_key":"J","next_key":"n","pattern_placeholder":"v","starts_with":0,"ends_with":0,"index_offset":1},{"key":"o","prior_key":"J","next_key":"h","pattern_placeholder":"v","starts_with":0,"ends_with":0,"index_offset":1},{"key":"t","prior_key":"a","next_key":"h","pattern_placeholder":"c","starts_with":0,"ends_with":0,"index_offset":5},{"key":"o","prior_key":"J","next_key":"h","pattern_placeholder":"v","starts_with":0,"ends_with":0,"index_offset":1},{"key":"o","prior_key":"J","next_key":"n","pattern_placeholder":"v","starts_with":0,"ends_with":0,"index_offset":1},{"key":"h","prior_key":"t","next_key":"o","pattern_placeholder":"c","starts_with":0,"ends_with":0,"index_offset":5},{"key":"h","prior_key":"C","next_key":"r","pattern_placeholder":"c","starts_with":0,"ends_with":0,"index_offset":1},{"key":"r","prior_key":"K","next_key":"i","pattern_placeholder":"c","starts_with":0,"ends_with":0,"index_offset":1},{"key":"h","prior_key":"C","next_key":"r","pattern_placeholder":"c","starts_with":0,"ends_with":0,"index_offset":1},{"key":"t","prior_key":"s","next_key":"o","pattern_placeholder":"c","starts_with":0,"ends_with":0,"index_offset":5},{"key":"e","prior_key":"h","next_key":"r","pattern_placeholder":"v","starts_with":0,"ends_with":0,"index_offset":9},{"key":"h","prior_key":"C","next_key":"r","pattern_placeholder":"c","starts_with":0,"ends_with":0,"index_offset":1},{"key":"t","prior_key":"s","next_key":"i","pattern_placeholder":"c","starts_with":0,"ends_with":0,"index_offset":5},{"key":"r","prior_key":"K","next_key":"i","pattern_placeholder":"c","starts_with":0,"ends_with":0,"index_offset":1},{"key":"y","prior_key":"s","next_key":null,"pattern_placeholder":"c","starts_with":0,"ends_with":1,"index_offset":5},{"key":"a","prior_key":"D","next_key":"n","pattern_placeholder":"v","starts_with":0,"ends_with":0,"index_offset":1},{"key":"a","prior_key":"D","next_key":"n","pattern_placeholder":"v","starts_with":0,"ends_with":0,"index_offset":1},{"key":"a","prior_key":"D","next_key":"n","pattern_placeholder":"v","starts_with":0,"ends_with":0,"index_offset":1},{"key":"a","prior_key":"D","next_key":"n","pattern_placeholder":"v","starts_with":0,"ends_with":0,"index_offset":1},{"key":"e","prior_key":"i","next_key":null,"pattern_placeholder":"v","starts_with":0,"ends_with":1,"index_offset":5},{"key":"a","prior_key":"D","next_key":"n","pattern_placeholder":"v","starts_with":0,"ends_with":0,"index_offset":1},{"key":"h","prior_key":"t","next_key":"o","pattern_placeholder":"c","starts_with":0,"ends_with":0,"index_offset":5}],[{"key":"n","prior_key":"o","next_key":"n","pattern_placeholder":"c","starts_with":0,"ends_with":0,"index_offset":2},{"key":"n","prior_key":"o","next_key":null,"pattern_placeholder":"c","starts_with":0,"ends_with":1,"index_offset":2},{"key":"h","prior_key":"o","next_key":"n","pattern_placeholder":"c","starts_with":0,"ends_with":0,"index_offset":2},{"key":"h","prior_key":"t","next_key":"o","pattern_placeholder":"c","starts_with":0,"ends_with":0,"index_offset":6},{"key":"h","prior_key":"o","next_key":"n","pattern_placeholder":"c","starts_with":0,"ends_with":0,"index_offset":2},{"key":"n","prior_key":"o","next_key":"a","pattern_placeholder":"c","starts_with":0,"ends_with":0,"index_offset":2},{"key":"o","prior_key":"h","next_key":"n","pattern_placeholder":"v","starts_with":0,"ends_with":0,"index_offset":6},{"key":"r","prior_key":"h","next_key":"i","pattern_placeholder":"c","starts_with":0,"ends_with":0,"index_offset":2},{"key":"i","prior_key":"r","next_key":"s","pattern_placeholder":"v","starts_with":0,"ends_with":0,"index_offset":2},{"key":"r","prior_key":"h","next_key":"i","pattern_placeholder":"c","starts_with":0,"ends_with":0,"index_offset":2},{"key":"o","prior_key":"t","next_key":"p","pattern_placeholder":"v","starts_with":0,"ends_with":0,"index_offset":6},{"key":"r","prior_key":"e","next_key":null,"pattern_placeholder":"c","starts_with":0,"ends_with":1,"index_offset":10},{"key":"r","prior_key":"h","next_key":"i","pattern_placeholder":"c","starts_with":0,"ends_with":0,"index_offset":2},{"key":"i","prior_key":"t","next_key":"a","pattern_placeholder":"v","starts_with":0,"ends_with":0,"index_offset":6},{"key":"i","prior_key":"r","next_key":"s","pattern_placeholder":"v","starts_with":0,"ends_with":0,"index_offset":2},{"key":"n","prior_key":"a","next_key":null,"pattern_placeholder":"c","starts_with":0,"ends_with":1,"index_offset":2},{"key":"n","prior_key":"a","next_key":"n","pattern_placeholder":"c","starts_with":0,"ends_with":0,"index_offset":2},{"key":"n","prior_key":"a","next_key":"y","pattern_placeholder":"c","starts_with":0,"ends_with":0,"index_offset":2},{"key":"n","prior_key":"a","next_key":"n","pattern_placeholder":"c","starts_with":0,"ends_with":0,"index_offset":2},{"key":"n","prior_key":"a","next_key":"a","pattern_placeholder":"c","starts_with":0,"ends_with":0,"index_offset":2},{"key":"o","prior_key":"h","next_key":"n","pattern_placeholder":"v","starts_with":0,"ends_with":0,"index_offset":6}],[{"key":"n","prior_key":"n","next_key":"y","pattern_placeholder":"c","starts_with":0,"ends_with":0,"index_offset":3},{"key":"n","prior_key":"h","next_key":"a","pattern_placeholder":"c","starts_with":0,"ends_with":0,"index_offset":3},{"key":"o","prior_key":"h","next_key":"n","pattern_placeholder":"v","starts_with":0,"ends_with":0,"index_offset":7},{"key":"n","prior_key":"h","next_key":null,"pattern_placeholder":"c","starts_with":0,"ends_with":1,"index_offset":3},{"key":"a","prior_key":"n","next_key":"t","pattern_placeholder":"v","starts_with":0,"ends_with":0,"index_offset":3},{"key":"n","prior_key":"o","next_key":null,"pattern_placeholder":"c","starts_with":0,"ends_with":1,"index_offset":7},{"key":"i","prior_key":"r","next_key":"s","pattern_placeholder":"v","starts_with":0,"ends_with":0,"index_offset":3},{"key":"s","prior_key":"i","next_key":null,"pattern_placeholder":"c","starts_with":0,"ends_with":1,"index_offset":3},{"key":"i","prior_key":"r","next_key":"s","pattern_placeholder":"v","starts_with":0,"ends_with":0,"index_offset":3},{"key":"p","prior_key":"o","next_key":"h","pattern_placeholder":"c","starts_with":0,"ends_with":0,"index_offset":7},{"key":"i","prior_key":"r","next_key":"s","pattern_placeholder":"v","starts_with":0,"ends_with":0,"index_offset":3},{"key":"a","prior_key":"i","next_key":"n","pattern_placeholder":"v","starts_with":0,"ends_with":0,"index_offset":7},{"key":"s","prior_key":"i","next_key":"s","pattern_placeholder":"c","starts_with":0,"ends_with":0,"index_offset":3},{"key":"n","prior_key":"n","next_key":"y","pattern_placeholder":"c","starts_with":0,"ends_with":0,"index_offset":3},{"key":"y","prior_key":"n","next_key":"l","pattern_placeholder":"c","starts_with":0,"ends_with":0,"index_offset":3},{"key":"n","prior_key":"n","next_key":"i","pattern_placeholder":"c","starts_with":0,"ends_with":0,"index_offset":3},{"key":"a","prior_key":"n","next_key":"t","pattern_placeholder":"v","starts_with":0,"ends_with":0,"index_offset":3},{"key":"n","prior_key":"o","next_key":null,"pattern_placeholder":"c","starts_with":0,"ends_with":1,"index_offset":7}]]} |