Пример #1
0
    public List <ExampleSentence> GetSentencesForItem(LearningSetItem item)
    {
        string kanji = item.FirstKanji();

        if (kanji == null)
        {
            kanji = item.FirstReading();                 // in case of kana only, e.g. suru, coffee
        }
        // sentences where the nouns array contains the kanji, or the conjugations array contains a conjugated form of the kanji
        // jumping through a hoop backwards!
        List <ExampleSentence> examples = sentences.Where(s => s.nouns.Contains(kanji) ||
                                                          s.conjugations.Where(c => GetDictionaryFormForConjugation(c) == kanji).Count() > 0).ToList();

        if (examples.Count > 5)
        {
            examples = Randomer.FromList(examples, 5);
        }
        return(examples);
    }
Пример #2
0
    public List <Kanji> GetKanjiForItem(LearningSetItem item)
    {
        List <Kanji> kanjiList  = new List <Kanji> ();
        string       firstKanji = item.FirstKanji();

        if (firstKanji == null)
        {
            return(kanjiList);                    // if the item is kana only, this will trigger
        }
        List <string> itemKanji = firstKanji.Select(k => $"{k}").ToList();

        foreach (string iKanji in itemKanji)
        {
            Kanji foundKanji = kanji.Where(k => k.kanji == iKanji).FirstOrDefault();
            if (foundKanji != null)
            {
                kanjiList.Add(foundKanji);
            }
        }

        return(kanjiList);
    }