public bool CheckFilters(LetterFilters filters, LetterData data) { if (filters.requireDiacritics && !data.IsOfKindCategory(LetterKindCategory.DiacriticCombo)) { return(false); } if (!FilterByDiacritics(filters.excludeDiacritics, data)) { return(false); } if (!FilterByLetterVariations(filters.excludeLetterVariations, data)) { return(false); } if (!FilterByDipthongs(filters.excludeDiphthongs, data)) { return(false); } if (!FilterByKind(!filters.includeAccentedLetters, data, LetterDataKind.AccentedLetter)) { return(false); } if (!FilterByKind(!filters.includeSpecialCharacters, data, LetterDataKind.SpecialChar)) { return(false); } // always skip symbols if (data.IsOfKindCategory(LetterKindCategory.Symbol)) { return(false); } return(true); }
private bool CheckFilters(LetterFilters filters, LetterData data) { if (filters.requireDiacritics && !data.IsOfKindCategory(LetterKindCategory.DiacriticCombo)) { return(false); } if (!FilterByDiacritics(filters.excludeDiacritics, data)) { return(false); } if (!FilterByLetterVariations(filters.excludeLetterVariations, data)) { return(false); } if (!FilterByDipthongs(filters.excludeDiphthongs, data)) { return(false); } // always skip symbols if (data.IsOfKindCategory(LetterKindCategory.Symbol)) { return(false); } return(true); }
public LetterData ConvertToLetterWithForcedForm(LetterData baseForVariation, LetterForm form) { var l = baseForVariation.Clone(); l.ForcedLetterForm = form; return(l); }
public List <LetterData> ExtractLettersWithForms(LetterData baseForVariation) { return(new List <LetterForm>(baseForVariation.GetAvailableForms()).ConvertAll(f => { var l = baseForVariation.Clone(); l.ForcedLetterForm = f; return l; })); }
public bool FilterByKind(bool exclude, LetterData data, LetterDataKind kind) { if (exclude && data.Kind == kind) { return(false); } return(true); }
public bool FilterByDipthongs(bool excludeDiphthongs, LetterData data) { if (excludeDiphthongs && data.Kind == LetterDataKind.Diphthong) { return(false); } return(true); }
public bool WordContainsLetter(WordData selectedWord, LetterData containedLetter, LetterEqualityStrictness letterEqualityStrictness = LetterEqualityStrictness.LetterBase) { //if (containedLetter.Id == "lam_alef") Debug.Log("Looking for lam-alef in " + selectedWord); //foreach (var l in ArabicAlphabetHelper.FindLetter(dbManager, selectedWord, containedLetter)) //if (l.letter.Id == "lam_alef") Debug.Log("Lam alef form " + l.letterForm + " in word " + selectedWord); var lettersInWord = GetLettersInWord(selectedWord); return(lettersInWord.Any(x => x.IsSameLetterAs(containedLetter, letterEqualityStrictness))); }
public bool AnyWordContainsLetter(LetterData letter, IEnumerable <WordData> words, LetterEqualityStrictness equalityStrictness = LetterEqualityStrictness.LetterBase) { var comparer = new StrictLetterDataComparer(equalityStrictness); foreach (var word in words) { if (GetLettersInWord(word).Contains(letter, comparer)) { return(true); } } return(false); }
public int WordContainsLetterTimes(WordData selectedWord, LetterData containedLetter, LetterEqualityStrictness letterEqualityStrictness = LetterEqualityStrictness.LetterBase) { var wordLetters = GetLettersInWord(selectedWord); int count = 0; foreach (var letter in wordLetters) { if (letter.IsSameLetterAs(containedLetter, letterEqualityStrictness)) { count++; } } return(count); }
public bool IsLetterContainedInAnyWord(LetterData letter, List <WordData> words, LetterEqualityStrictness equalityStrictness = LetterEqualityStrictness.LetterBase) { var comparer = new StrictLetterDataComparer(equalityStrictness); foreach (var word in words) { var containedLetters = GetLettersInWord(word); if (containedLetters.Contains(letter, comparer)) { return(true); } } return(false); }
public bool IsSameLetterAs(LetterData other, LetterEqualityStrictness strictness) { bool isEqual = false; switch (strictness) { case LetterEqualityStrictness.LetterOnly: isEqual = string.Equals(_Id, other._Id); break; case LetterEqualityStrictness.WithActualForm: isEqual = string.Equals(_Id, other._Id) && Form == other.Form; break; case LetterEqualityStrictness.WithVisualForm: isEqual = string.Equals(_Id, other._Id) && FormsLookTheSame(Form, other.Form); break; } return(isEqual); }
public bool FilterByLetterVariations(LetterFilters.ExcludeLetterVariations excludeLetterVariations, LetterData data) { switch (excludeLetterVariations) { case LetterFilters.ExcludeLetterVariations.All: if (data.IsOfKindCategory(LetterKindCategory.LetterVariation)) { return(false); } break; case LetterFilters.ExcludeLetterVariations.AllButAlefHamza: if (data.IsOfKindCategory(LetterKindCategory.LetterVariation) && data.Tag != "AlefHamzaVariation") { return(false); } break; default: break; } return(true); }
private bool Equals(LetterData other) { // By default, LetterData uses LetterOnly when comparing (even in collections!) return(IsSameLetterAs(other, LetterEqualityStrictness.LetterOnly)); }
private List <WordData> GetWordsByLetters(WordFilters filters, LetterData[] okLettersArray, LetterData[] tabooLettersArray, LetterEqualityStrictness letterEqualityStrictness = LetterEqualityStrictness.LetterBase) { if (okLettersArray == null) { okLettersArray = new LetterData[] { } } ; if (tabooLettersArray == null) { tabooLettersArray = new LetterData[] { } } ; var okLetters = new HashSet <LetterData>(okLettersArray); var tabooLetters = new HashSet <LetterData>(tabooLettersArray); var comparer = new StrictLetterDataComparer(letterEqualityStrictness); List <WordData> wordsByLetters = dbManager.FindWordData(word => { if (!CheckFilters(filters, word)) { return(false); } var lettersInWord = GetLettersInWord(word); if (tabooLetters.Count > 0) { foreach (var letter in lettersInWord) { if (tabooLetters.Contains(letter, comparer)) { return(false); } } } if (okLetters.Count > 0) { bool hasAllOkLetters = true; foreach (var okLetter in okLetters) { bool hasThisLetter = false; foreach (var letter in lettersInWord) { if (letter.IsSameLetterAs(okLetter, letterEqualityStrictness)) { hasThisLetter = true; break; } } if (!hasThisLetter) { hasAllOkLetters = false; break; } } if (!hasAllOkLetters) { return(false); } } return(true); } ); return(wordsByLetters); }
public List <WordData> GetWordsWithoutLetter(WordFilters filters, LetterData tabooLetter, LetterEqualityStrictness letterEqualityStrictness = LetterEqualityStrictness.Letter) { return(GetWordsByLetters(filters, null, new[] { tabooLetter }, letterEqualityStrictness)); }
public List <WordData> GetWordsWithLetter(WordFilters filters, LetterData okLetter, LetterEqualityStrictness letterEqualityStrictness = LetterEqualityStrictness.LetterBase) { return(GetWordsByLetters(filters, new[] { okLetter }, null, letterEqualityStrictness)); }
public bool FilterByDiacritics(LetterFilters.ExcludeDiacritics excludeDiacritics, LetterData data) { switch (excludeDiacritics) { case LetterFilters.ExcludeDiacritics.All: if (data.IsOfKindCategory(LetterKindCategory.DiacriticCombo)) { return(false); } break; case LetterFilters.ExcludeDiacritics.AllButMain: var symbol = GetSymbolOf(data.Id); if (symbol != null && data.IsOfKindCategory(LetterKindCategory.DiacriticCombo) && symbol.Tag != "MainDiacritic") { return(false); } break; default: break; } return(true); }