Changing how to use textdifference thing

I think it'd be better to use text difference if a substring isn't found.

I realised afterwards that I think this is how Scryfall does it anyway.
This commit is contained in:
2025-08-17 00:34:03 +01:00
parent 6558a31619
commit 9a9f42bc1e
3 changed files with 38 additions and 21 deletions

View File

@@ -3,6 +3,7 @@ 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;
use textdistance::str::damerau_levenshtein;
#[derive(Parser, Debug)]
#[command(version, about, long_about = None)]
@@ -27,14 +28,17 @@ fn main() {
panic!("You need to put some card text to search");
}
let search_string = card_name.join(" ");
dbg!(&search_string);
//dbg!(&search_string);
let cards = get_all_lowercase_card_names();
dbg!(&cards);
//dbg!(&cards);
let mut matching_cards = Vec::new();
for card in cards {
if card.contains(&search_string) {
matching_cards.push(card);
matching_cards.push(card.clone());
}
}
dbg!(matching_cards);
if matching_cards.is_empty() {
// Do some distance checking stuff
}
//dbg!(matching_cards);
}