Matching substrings works

Want to try also using something like this for finding spelling mistakes etc.
https://github.com/life4/textdistance.rs

Going to have to try to do some combination though to ensure exact substring
matches, even when missing the latter half, still work well. Maybe... I dunno
will have to try.
This commit is contained in:
2025-08-16 21:38:34 +01:00
parent 72fa35d41a
commit 6558a31619
3 changed files with 30 additions and 8 deletions

View File

@@ -1,5 +1,5 @@
use clap::Parser;
use scryfall_deser::get_all_card_names;
use scryfall_deser::get_all_lowercase_card_names;
use scryfall_deser::get_local_cache_folder;
use scryfall_deser::init_db;
use scryfall_deser::update_db_with_file;
@@ -20,13 +20,21 @@ fn main() {
// TODO - actually download and update
path.push("oracle-cards-20250814210711.json");
update_db_with_file(path);
return;
}
let card_name = args.remainder;
if card_name.is_empty() {
panic!("You need to put some card text to search");
}
let search_string = card_name.join(" ");
dbg!(search_string);
let cards = get_all_card_names();
dbg!(cards);
dbg!(&search_string);
let cards = get_all_lowercase_card_names();
dbg!(&cards);
let mut matching_cards = Vec::new();
for card in cards {
if card.contains(&search_string) {
matching_cards.push(card);
}
}
dbg!(matching_cards);
}