public static bool ContainsAny(FlagSet a, FlagSet b) { if (a == null || a.IsEmpty || b == null || b.IsEmpty) { return(false); } if (a.Count == 1) { return(b.Contains(a[0])); } if (b.Count == 1) { return(a.Contains(b[0])); } if (a.Count > b.Count) { Swapper.Swap(ref a, ref b); } foreach (var item in a) { if (b.Contains(item)) { return(true); } } return(false); }
private bool AddWordCapitalized(string word, FlagSet flags, MorphSet morphs, CapitalizationType capType) { // add inner capitalized forms to handle the following allcap forms: // Mixed caps: OpenOffice.org -> OPENOFFICE.ORG // Allcaps with suffixes: CIA's -> CIA'S if ( ( capType == CapitalizationType.Huh || capType == CapitalizationType.HuhInit || (capType == CapitalizationType.All && flags.HasItems) ) && !flags.Contains(Affix.ForbiddenWord) ) { flags = Builder.Dedup(FlagSet.Union(flags, SpecialFlags.OnlyUpcaseFlag)); var textInfo = Affix.Culture.TextInfo; var initCapBuilder = StringBuilderPool.Get(word); if (initCapBuilder.Length > 0) { initCapBuilder[0] = textInfo.ToUpper(initCapBuilder[0]); for (var i = 1; i < initCapBuilder.Length; i++) { initCapBuilder[i] = textInfo.ToLower(initCapBuilder[i]); } } return(AddWord(StringBuilderPool.GetStringAndReturn(initCapBuilder), flags, morphs, true)); } return(false); }