Beispiel #1
0
        /// <summary>
        /// tranformsf the hex string of the glyph into the corresponding char
        /// </summary>
        /// <returns>The drawing string</returns>
        /// <param name="word">WordData.</param>
        public string GetWordDrawing(WordData word)
        {
            //Debug.Log("the int of hex:" + word.Drawing + " is " + int.Parse(word.Drawing, NumberStyles.HexNumber));
            if (word.Drawing != "")
            {
                string drawingHexCode = word.Drawing;
                if (AppManager.I.SpecificEdition.Edition == AppEditions.LearnEnglish_Ceibal && word.DrawingCeibal != "")
                {
                    drawingHexCode = word.DrawingCeibal;
                }

                if (int.TryParse(drawingHexCode, NumberStyles.HexNumber, CultureInfo.CurrentCulture, out int result))
                {
                    return(((char)result).ToString());
                }
                return("");
            }
            return("");
        }
Beispiel #2
0
        public List <LetterData> GetLettersInWord(WordData wordData, bool keepBasesOnly = false)
        {
            // @note: this will always retrieve all letters with their forms, the strictness will then define whether that has any consequence or not
            List <LetterData> letters = null;
            var dictCache             = wordsToLetterCache;

            if (!dictCache.ContainsKey(wordData.Id))
            {
                var parts = LanguageSwitcher.I.GetHelper(LanguageUse.Learning).SplitWord(dbManager, wordData, separateVariations: false);
                letters = parts.ConvertAll(x => ConvertToLetterWithForcedForm(x.letter, x.letterForm));
                dictCache[wordData.Id] = letters;
            }
            letters = dictCache[wordData.Id];

            if (keepBasesOnly)
            {
                letters = letters.ConvertAll(ld => ConvertToLetterWithForcedForm(ld.Base, ld.Form));
            }

            return(letters);
        }
Beispiel #3
0
 private bool CheckFilters(WordFilters filters, WordData data)
 {
     if (filters.excludeArticles && data.Article != WordDataArticle.None)
     {
         return(false);
     }
     if (filters.requireDrawings && !data.HasDrawing())
     {
         return(false);
     }
     if (filters.excludeColorWords && data.Category == WordDataCategory.Color)
     {
         return(false);
     }
     if (filters.excludePluralDual && data.Form != WordDataForm.Singular)
     {
         return(false);
     }
     if (filters.excludeDiacritics && WordHasDiacriticCombo(data))
     {
         return(false);
     }
     if (filters.excludeLetterVariations && WordHasLetterVariations(data))
     {
         return(false);
     }
     if (filters.requireDiacritics && !WordHasDiacriticCombo(data))
     {
         return(false);
     }
     if (filters.excludeDipthongs && WordHasDipthongs(data))
     {
         return(false);
     }
     return(true);
 }
Beispiel #4
0
        public bool WordHasSpecialCharacters(WordData selectedWord)
        {
            var wordLetters = GetLettersInWord(selectedWord);

            return(wordLetters.Any(x => x.IsOfKindCategory(LetterKindCategory.SpecialChar)));
        }
Beispiel #5
0
        public bool WordContainsDuplicateLetters(WordData selectedWord, LetterEqualityStrictness letterEqualityStrictness = LetterEqualityStrictness.LetterBase)
        {
            var wordLetters = GetLettersInWord(selectedWord);

            return(wordLetters.GroupBy(x => x.Id).Any(g => g.Count() > 1));
        }
Beispiel #6
0
 private bool Equals(WordData other)
 {
     return(IsSameAs(other, DefaultStrictness));
 }