/// <summary>Creates a new <see cref="ICUNormalizer2FilterFactory"/>.</summary> public ICUNormalizer2FilterFactory(IDictionary <string, string> args) : base(args) { string name = Get(args, "name", "nfkc_cf"); string mode = Get(args, "mode", new string[] { "compose", "decompose" }, "compose"); Normalizer2 normalizer = Normalizer2.GetInstance (null, name, "compose".Equals(mode, StringComparison.Ordinal) ? Normalizer2Mode.Compose : Normalizer2Mode.Decompose); string filter = Get(args, "filter"); if (filter != null) { UnicodeSet set = new UnicodeSet(filter); if (set.Any()) { set.Freeze(); normalizer = new FilteredNormalizer2(normalizer, set); } } if (args.Count > 0) { throw new ArgumentException(string.Format(J2N.Text.StringFormatter.CurrentCulture, "Unknown parameters: {0}", args)); } this.normalizer = normalizer; }
/// <summary>Creates a new <see cref="ICUNormalizer2CharFilterFactory"/>.</summary> public ICUNormalizer2CharFilterFactory(IDictionary <string, string> args) : base(args) { string name = Get(args, "name", "nfkc_cf"); string mode = Get(args, "mode", new string[] { "compose", "decompose" }, "compose"); Normalizer2 normalizer = Normalizer2.GetInstance (null, name, "compose".Equals(mode) ? Normalizer2Mode.Compose : Normalizer2Mode.Decompose); string filter = Get(args, "filter"); if (filter != null) { UnicodeSet set = new UnicodeSet(filter); if (set.Any()) { set.Freeze(); normalizer = new FilteredNormalizer2(normalizer, set); } } if (args.Count > 0) { throw new ArgumentException("Unknown parameters: " + args); } this.normalizer = normalizer; }
/// <summary> /// Create a new <see cref="ICUTransformFilter"/> that transforms text on the given stream. /// </summary> /// <param name="input"><see cref="TokenStream"/> to filter.</param> /// <param name="transform">Transliterator to transform the text.</param> public ICUTransformFilter(TokenStream input, Transliterator transform) : base(input) { this.transform = transform; this.termAtt = AddAttribute <ICharTermAttribute>(); /* * This is cheating, but speeds things up a lot. * If we wanted to use pkg-private APIs we could probably do better. */ #pragma warning disable 612, 618 if (transform.Filter == null && transform is RuleBasedTransliterator) #pragma warning restore 612, 618 { UnicodeSet sourceSet = transform.GetSourceSet(); if (sourceSet != null && sourceSet.Any()) { transform.Filter = sourceSet; } } }