Want to contribute? Fork me on Codeberg.org!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
759 B

use wana_kana::{ConvertJapanese, IsJapaneseStr};
pub fn lookup(input: &str) -> Option<&jisho::Entry> {
let input = input.trim();
for word in jisho::lookup(input) {
if
// If input has no kanji,
// we can just compare the input to the reading verbatim
// ensuring both are hiragana
(input.is_kana() && input.to_hiragana() == word.reading.to_hiragana()) ||
// Otherwise, we have to ensure that the input
// is verbosely the same.
// However, this will cause problems for some words.
// For example, 照り焼き will be accepted but 照焼 won't.
(input == word.kanji) {
return Some(word);
}
}
return None;
}