public override bool IsSingular(string word) { EDesignUtil.CheckArgumentNull(word, "word"); if (_userDictionary.ExistsInFirst(word)) { return(true); } if (_userDictionary.ExistsInSecond(word)) { return(false); } if (IsUninflective(word) || _knownSingluarWords.Contains(word.ToLower(Culture))) { return(true); } if (!IsNoOpWord(word) && Singularize(word).Equals(word)) { return(true); } return(false); }
/// <summary> /// Factory method for PluralizationService. Only support english pluralization. /// Please set the PluralizationService on the System.Data.Entity.Design.EntityModelSchemaGenerator /// to extend the service to other locales. /// </summary> /// <param name="culture">CultureInfo</param> /// <returns>PluralizationService</returns> public static PluralizationService CreateService(CultureInfo culture) { EDesignUtil.CheckArgumentNull(culture, "culture"); if (culture.TwoLetterISOLanguageName == "en") { return(new EnglishPluralizationService()); } throw new NotImplementedException(); //throw new NotImplementedException(Strings.UnsupportedLocaleForPluralizationServices(culture.DisplayName)); }
private bool IsUninflective(string word) { EDesignUtil.CheckArgumentNull(word, "word"); if (PluralizationServiceUtil.DoesWordContainSuffix(word, _uninflectiveSuffixList, Culture) || (!word.ToLower(Culture).Equals(word) && word.EndsWith("ese", false, Culture)) || _uninflectiveWordList.Contains(word.ToLowerInvariant())) { return(true); } return(false); }
/// <summary> /// This method allow you to add word to internal PluralizationService of English. /// If the singluar or the plural value was already added by this method, then an ArgumentException will be thrown. /// </summary> /// <param name="singular"></param> /// <param name="plural"></param> public void AddWord(string singular, string plural) { EDesignUtil.CheckArgumentNull(singular, "singular"); EDesignUtil.CheckArgumentNull(plural, "plural"); if (_userDictionary.ExistsInSecond(plural)) { throw new ArgumentException($"Duplicate entry in user dictionary: plural '{plural}'"); } if (_userDictionary.ExistsInFirst(singular)) { throw new ArgumentException($"Duplicate entry in user dictionary: singular '{singular}'"); } _userDictionary.AddValue(singular, plural); }
public override string Singularize(string word) { EDesignUtil.CheckArgumentNull(word, "word"); return(Capitalize(word, InternalSingularize)); }