예제 #1
0
 public DataProxySelectionEvent(LearningSetItem compound, NavType navType, List <Kanji> kanjiChoices, List <ExampleSentence> sentenceChoices)
 {
     this.navType         = navType;
     this.compound        = compound;
     this.kanjiChoices    = kanjiChoices;
     this.sentenceChoices = sentenceChoices;
 }
예제 #2
0
        private List <LearningSetItem> SpeciesToItems(List <SpeciesT> species)
        {
            List <LearningSetItem> setItems = new List <LearningSetItem>();

            foreach (SpeciesT sp in species)
            {
                foreach (ImgDb img in sp.Imgs)
                {
                    LearningSetItem newItem = new LearningSetItem
                    {
                        Name            = sp.Name,
                        Description     = sp.Description,
                        Class           = sp.Class,
                        Classification  = sp.Classification,
                        Size            = sp.Size,
                        Use             = sp.Use,
                        OccurencesWorld = sp.OccurencesWorld,
                        Ecosystems      = sp.Ecosystems,
                        OccurenceCR     = sp.OccurenceCR,
                        Protection      = sp.Protection,
                        EcoFunction     = sp.EcoFunction,
                        ImgPath         = img.ImgPath,
                        ImgName         = img.ImgName,
                        ImgDescription  = img.ImgDescription,
                        ImgType         = img.ImgType
                    };
                    setItems.Add(newItem);
                }
            }
            return(setItems);
        }
예제 #3
0
    public void DisplayFirst(DataProxyEvent e)
    {
        if (e.type != DataProxyEventType.Start)
        {
            return;
        }
        LearningSetItem startItem = extendedSet.GetItemForCompound("一");

        SetCurrentData(startItem);
    }
예제 #4
0
 public DataProxySelectionEvent(DataProxyChoicesEvent e, NavType navType)
 {
     this.navType         = navType;
     this.sentence        = e.currentEvent.sentence;
     this.sentenceChoices = e.currentEvent.sentenceChoices;
     this.compound        = e.currentEvent.compound;
     this.compoundChoices = e.currentEvent.compoundChoices;
     this.kanji           = e.currentEvent.kanji;
     this.kanjiChoices    = e.currentEvent.kanjiChoices;
 }
예제 #5
0
    private void DisplayLearningItem(LearningSetItem item)
    {
        Source source      = item.data.Values.First();
        string kanji       = JoinData(source.kanji, ", ");
        string reading     = JoinData(source.readings, ", ");
        string romaji      = new KanaTools().HiraganaToRomaji(reading);
        string fullReading = $"{romaji}\n{reading}";

        _japanese.text = kanji != "" ? kanji : fullReading;
        _reading.text  = kanji != "" ? fullReading : "";
        _senses.text   = JoinData(source.senses, "\n");
    }
예제 #6
0
 public static bool Validate(LearningSet set, LearningSetItem item)
 {
     if (item.Class > set.Class)
     {
         return(false);
     }
     if (set.OccurenceCR != OccurenceCREnum.neuvedeno && item.OccurenceCR != set.OccurenceCR)
     {
         return(false);
     }
     return(true);
 }
예제 #7
0
        public IActionResult Slide(int learningSetID, int item)
        {
            ViewBag.item = item;
            LearningSet set = _context.LearningSets.Include(x => x.Items)
                              .Single(x => x.LearningSetID == learningSetID);

            item = item >= set.NumberOfItems ? set.NumberOfItems - 1 : item;
            item = item < 0 ? 0 : item;

            LearningSetItem currentItem = set.Items.ElementAt(item);

            ViewBag.item = item;
            return(View(currentItem));
        }
예제 #8
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);
    }
예제 #9
0
 public void SetCurrentData(System.Object data)
 {
     _currentItem     = null;
     _currentKanji    = null;
     _currentSentence = null;
     if (data is LearningSetItem)
     {
         _currentItem = data as LearningSetItem;
         EventBus.Instance.Raise(new DataProxySelectionEvent(_currentItem, NavType.Display, GetKanjiForItem(_currentItem), GetSentencesForItem(_currentItem)));
     }
     else if (data is ExampleSentence)
     {
         _currentSentence = data as ExampleSentence;
         EventBus.Instance.Raise(new DataProxySelectionEvent(_currentSentence, NavType.Display, GetItemsForSentence(_currentSentence)));
     }
     else if (data is Kanji)
     {
         _currentKanji = data as Kanji;
         EventBus.Instance.Raise(new DataProxySelectionEvent(_currentKanji, NavType.Display, extendedSet.GetItemsForKanji(_currentKanji)));
     }
 }
예제 #10
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);
    }
예제 #11
0
    private bool TestNounsAndConjugationsArePresentInLearningSets()
    {
        string        errors = "";
        List <string> nouns  = GetAllNounsFromSentenceData().Distinct().ToList();

        nouns.Sort();
        List <string> conjs = GetDictionaryFormsFromConjugations().Distinct().ToList();

        conjs.Sort();

        List <string> allItems = nouns.Union(conjs).ToList();

        List <string> missingItems = new List <string> ();

        foreach (string item in allItems)
        {
            LearningSetItem lsItem = proxy.extendedSet.GetItemForCompound(item);
            if (lsItem == null)
            {
                missingItems.Add(item);
            }
        }

        if (missingItems.Count > 0)
        {
            errors = $"LearningSet was missing {missingItems.Count} items for {string.Join(", ", missingItems)}";
        }

        if (errors == "")
        {
            Debug.Log("All nouns and conjugations have learning items");
            return(true);
        }

        Debug.Log(errors);
        return(false);
    }
예제 #12
0
    private void DisplayLearningItem(LearningSetItem item)
    {
        Source source = item.data.Values.First();

        _japanese.text = JoinData(source.kanji, ", ");
    }