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.
16 lines
697 B
16 lines
697 B
use wana_kana::{ConvertJapanese, IsJapaneseStr};
|
|
|
|
pub fn lookup(input: &str) -> Option<&jisho::Entry> {
|
|
let input = input.trim();
|
|
jisho::lookup(input).into_iter().find(|&word| (
|
|
// 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)))
|
|
}
|