Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 8 additions & 11 deletions autobase-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,21 +121,18 @@ fn generate_base_for_font(
.script()
.map(|x| supported.contains(x))
.unwrap_or(false)
});
// We want to filter out any words which are in the exclusions. But:
// - We can't clone or modify a wordlist
// - We can create a wordlist from an iterator but we then lose the metadata
// - We can't create new metadata objects or change the metadata on an existing wordlist
// - We can't add a filter function into par_check after par_iter because the function can't go across threads
// - We can't add a filter function into par_check before par_iter because we need Wordlist.par_iter to produce a ParWordListIter
// So there's not much we can do except get a large number of exemplars and hope for the best.
})
.map(|word_list| {
// Note: this will be quite slow if the list of exclusions is large
word_list.filter(|word| config.exclusions.iter().any(|exclusion| exclusion == word))
})
.collect::<Vec<_>>();
let reports = wordlists
.iter()
// Cartesian product relevant word lists with instances
.flat_map(|word_list| instances.iter().zip(iter::repeat(word_list)))
.par_bridge()
.map(|(reporter, word_list)| {
reporter.par_check(word_list, Some(args.words_per_list), 10000)
})
.map(|(reporter, word_list)| reporter.par_check(word_list, Some(args.words_per_list), 1))
.collect::<Result<Vec<_>, _>>()?;
let mut reports_by_script: BTreeMap<String, Vec<Report>> = BTreeMap::new();
for report in reports.into_iter() {
Expand Down
24 changes: 2 additions & 22 deletions autobase/src/base_script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,33 +23,13 @@ impl MinMax {
let (mut highest, mut highest_word) = if r.exemplars.is_empty() {
(None, "<none>".to_string())
} else {
let h = r
.exemplars
.highest()
.iter()
.find(|w| {
!config
.exclusions
.iter()
.any(|excluded_pattern| w.word.contains(excluded_pattern))
})
.unwrap();
let h = r.exemplars.highest().first().unwrap();
(Some(h.extremes.highest() as i16), h.word.to_string())
};
let (mut lowest, mut lowest_word) = if r.exemplars.is_empty() {
(None, "<none>".to_string())
} else {
let l = r
.exemplars
.lowest()
.iter()
.find(|w| {
!config
.exclusions
.iter()
.any(|excluded_pattern| w.word.contains(excluded_pattern))
})
.unwrap();
let l = r.exemplars.lowest().first().unwrap();
(Some(l.extremes.lowest() as i16), l.word.to_string())
};
if let Some(ov) = override_ {
Expand Down