Esempio n. 1
0
        internal RBBINode(int t)
        {
            this.fPrecedence = precZero;
            IBM.ICU.Impl.Assert.Assrt(t < nodeTypeLimit);
            fSerialNum = ++gLastSerial;
            fType      = t;

            fFirstPosSet = new HashedSet();
            fLastPosSet  = new HashedSet();
            fFollowPos   = new HashedSet();
            if (t == opCat)
            {
                fPrecedence = precOpCat;
            }
            else if (t == opOr)
            {
                fPrecedence = precOpOr;
            }
            else if (t == opStart)
            {
                fPrecedence = precStart;
            }
            else if (t == opLParen)
            {
                fPrecedence = precLParen;
            }
            else
            {
                fPrecedence = precZero;
            }
        }
Esempio n. 2
0
 public virtual ISet <K> KeySet()
 {
     if (keySet == null)
     {
         keySet = new AnonymousSet(this);
     }
     return(keySet);
 }
Esempio n. 3
0
 /// <summary>
 /// Gets a sample object in the equivalence set for a.
 /// </summary>
 ///
 public Object GetSample(Object a)
 {
     ILOG.J2CsMapping.Collections.ISet aPartitionSet = (ISet)ILOG.J2CsMapping.Collections.Collections.Get(toPartitionSet, a);
     if (aPartitionSet == null)
     {
         return(a);    // singleton
     }
     return(new ILOG.J2CsMapping.Collections.IteratorAdapter(aPartitionSet.GetEnumerator()).Next());
 }
Esempio n. 4
0
 public bool AreEquivalent(Object source1, Object source2)
 {
     ILOG.J2CsMapping.Collections.ISet s = (ISet)ILOG.J2CsMapping.Collections.Collections.Get(source_Set, source1);
     if (s == null)
     {
         return(false);
     }
     return(ILOG.J2CsMapping.Collections.Collections.Contains(source2, s));
 }
Esempio n. 5
0
 public virtual bool Contains(Object o)
 {
     ILOG.J2CsMapping.Collections.ISet set = (ISet)ILOG.J2CsMapping.Collections.Collections.Get(m, o);
     if (set == null)
     {
         return(false);
     }
     return(ILOG.J2CsMapping.Collections.Collections.Contains(o, set));
 }
Esempio n. 6
0
 public ILOG.J2CsMapping.Collections.ISet GetEquivalences(Object source)
 {
     ILOG.J2CsMapping.Collections.ISet s = (ISet)ILOG.J2CsMapping.Collections.Collections.Get(source_Set, source);
     if (s == null)
     {
         return(null);
     }
     return(ILOG.J2CsMapping.Collections.Generics.Collections.UnmodifiableSet(s));
 }
Esempio n. 7
0
            public override String GetInternal(int depth, ILOG.J2CsMapping.Collections.ISet alreadySeen)
            {
                String result = CheckName(name, alreadySeen);

                if (result.StartsWith("$"))
                {
                    return(result);
                }
                return(source.ToString());
            }
Esempio n. 8
0
 protected internal bool HandlesKey(ICUService.Key key)
 {
     if (key != null)
     {
         String id = key.CurrentID();
         ILOG.J2CsMapping.Collections.ISet supported = GetSupportedIDs();
         return(ILOG.J2CsMapping.Collections.Collections.Contains(id, supported));
     }
     return(false);
 }
Esempio n. 9
0
 /// <summary>
 /// Returns an unmodifiable set of all the equivalent objects
 /// </summary>
 ///
 public ILOG.J2CsMapping.Collections.ISet GetEquivalences(Object a)
 {
     ILOG.J2CsMapping.Collections.ISet aPartitionSet = (ISet)ILOG.J2CsMapping.Collections.Collections.Get(toPartitionSet, a);
     if (aPartitionSet == null)       // manufacture an equivalence
     {
         aPartitionSet = new HashedSet();
         ILOG.J2CsMapping.Collections.Generics.Collections.Add(aPartitionSet, a);
     }
     return(ILOG.J2CsMapping.Collections.Generics.Collections.UnmodifiableSet(aPartitionSet));
 }
Esempio n. 10
0
            public override String GetInternal(int depth, ILOG.J2CsMapping.Collections.ISet alreadySeen)
            {
                String result = CheckName(name, alreadySeen);

                if (result.StartsWith("$"))
                {
                    return(result);
                }
                return(IBM.ICU.Charset.Pick.Indent(depth) + result + "QUOTE("
                       + item.GetInternal(depth + 1, alreadySeen) + ")");
            }
Esempio n. 11
0
        /*
         * + "weight = integer '%';" +
         * "range = '{' integer (',' integer?)? '}' weight*;" + "quote = '@';" +
         * "star = '*' weight*;" + "plus = '+' weight*;" + "maybe = '?' weight?;" +
         * "quantifier = range | star | maybe | plus;" +
         * "core = string | unicodeSet | '(' alternation ')';" +
         * "sequence = (core quantifier*)+;" +
         * "alternation = sequence (weight? ('|' sequence weight?)+)?;" +
         * "rule = string '=' alternation;";
         *
         *
         * Match 0 or more times + Match 1 or more times ? Match 1 or 0 times {n}
         * Match exactly n times {n,} Match at least n times {n,m} Match at least n
         * but not more than m times
         */

        public BNF(Random random_0, Quoter quoter_1)
        {
            this.map       = new Hashtable();
            this.variables = new HashedSet();
            this.pick      = null;
            this.target    = null;
            this.maxRepeat = 99;
            this.random    = random_0;
            this.quoter    = quoter_1;
            t = new Tokenizer();
        }
Esempio n. 12
0
 public ILOG.J2CsMapping.Collections.ISet GetEquivalenceSets()
 {
     ILOG.J2CsMapping.Collections.ISet result = new HashedSet();
     for (IIterator it = new ILOG.J2CsMapping.Collections.IteratorAdapter(new ILOG.J2CsMapping.Collections.ListSet(toPartitionSet.Keys).GetEnumerator()); it.HasNext();)
     {
         Object item = it.Next();
         ILOG.J2CsMapping.Collections.ISet partition = (ISet)ILOG.J2CsMapping.Collections.Collections.Get(toPartitionSet, item);
         ILOG.J2CsMapping.Collections.Generics.Collections.Add(result, ILOG.J2CsMapping.Collections.Generics.Collections.UnmodifiableSet(partition));
     }
     return(result);
 }
Esempio n. 13
0
            internal int[] fDtran;     // Transitions out of this state.
            // indexed by input character
            // contents is int index of dest state
            // in RBBITableBuilder.fDStates

            internal RBBIStateDescriptor(int maxInputSymbol)
            {
                fTagVals   = new SortedSet();
                fPositions = new HashedSet();
                fDtran     = new int[maxInputSymbol + 1]; // fDtran needs to be
                                                          // pre-sized.
                                                          // It is indexed by input
                                                          // symbols, and will
                                                          // hold the next state number
                                                          // for each
                                                          // symbol.
            }
Esempio n. 14
0
            /// <summary>
            /// Override of superclass method.
            /// </summary>
            ///
            public override void UpdateVisibleIDs(IDictionary result)
            {
                ILOG.J2CsMapping.Collections.ISet visibleIDs = IBM.ICU.Impl.ICUResourceBundle
                                                               .GetAvailableLocaleNameSet(bundleName); // only visible ids
                IIterator iter = new ILOG.J2CsMapping.Collections.IteratorAdapter(visibleIDs.GetEnumerator());

                while (iter.HasNext())
                {
                    String id_0 = (String)iter.Next();
                    ILOG.J2CsMapping.Collections.Collections.Put(result, id_0, this);
                }
            }
Esempio n. 15
0
            static CalifornioLanguageFactory()
            {
                HashedSet result = new HashedSet();

                ILOG.J2CsMapping.Collections.Generics.Collections.AddAll(IBM.ICU.Impl.ICUResourceBundle
                                                                         .GetAvailableLocaleNameSet(), result);
                ILOG.J2CsMapping.Collections.Generics.Collections.Add(result, californio);
                ILOG.J2CsMapping.Collections.Generics.Collections.Add(result, valley);
                ILOG.J2CsMapping.Collections.Generics.Collections.Add(result, surfer);
                ILOG.J2CsMapping.Collections.Generics.Collections.Add(result, geek);
                supportedIDs = ILOG.J2CsMapping.Collections.Generics.Collections.UnmodifiableSet(result);
            }
Esempio n. 16
0
        /// <exclude/>
        /// <summary>
        /// Simple implementation of permutation. <br>
        /// <b>Warning: The strings are not guaranteed to be in any particular
        /// order.</b>
        /// </summary>
        ///
        /// <param name="source">the string to find permutations for</param>
        /// <param name="skipZeros">set to true to skip characters with canonical combining classzero</param>
        /// <param name="output">the set to add the results to</param>
        public static void Permute(String source, bool skipZeros, ILOG.J2CsMapping.Collections.ISet output)
        {
            // TODO: optimize
            // if (PROGRESS) System.out.println("Permute: " + source);

            // optimization:
            // if zero or one character, just return a set with it
            // we check for length < 2 to keep from counting code points all the
            // time
            if (source.Length <= 2 && IBM.ICU.Text.UTF16.CountCodePoint(source) <= 1)
            {
                ILOG.J2CsMapping.Collections.Generics.Collections.Add(output, source);
                return;
            }

            // otherwise iterate through the string, and recursively permute all the
            // other characters
            ILOG.J2CsMapping.Collections.ISet subpermute = new HashedSet();
            int cp;

            for (int i = 0; i < source.Length; i += IBM.ICU.Text.UTF16.GetCharCount(cp))
            {
                cp = IBM.ICU.Text.UTF16.CharAt(source, i);

                // optimization:
                // if the character is canonical combining class zero,
                // don't permute it
                if (skipZeros && i != 0 && IBM.ICU.Lang.UCharacter.GetCombiningClass(cp) == 0)
                {
                    // System.out.println("Skipping " +
                    // Utility.hex(UTF16.valueOf(source, i)));
                    continue;
                }

                // see what the permutations of the characters before and after this
                // one are
                ILOG.J2CsMapping.Collections.Collections.Clear(subpermute);
                Permute(source.Substring(0, (i) - (0))
                        + source.Substring(i + IBM.ICU.Text.UTF16.GetCharCount(cp)), skipZeros,
                        subpermute);

                // prefix this character to all of them
                String    chStr = IBM.ICU.Text.UTF16.ValueOf(source, i);
                IIterator it    = new ILOG.J2CsMapping.Collections.IteratorAdapter(subpermute.GetEnumerator());
                while (it.HasNext())
                {
                    String piece = chStr + (String)it.Next();
                    // if (PROGRESS) System.out.println("  Piece: " + piece);
                    ILOG.J2CsMapping.Collections.Generics.Collections.Add(output, piece);
                }
            }
        }
Esempio n. 17
0
 /// <summary>
 /// returns true iff a is equivalent to b (or a.equals b)
 /// </summary>
 ///
 public bool IsEquivalent(Object a, Object b)
 {
     if (a.Equals(b))
     {
         return(true);
     }
     ILOG.J2CsMapping.Collections.ISet aPartitionSet = (ISet)ILOG.J2CsMapping.Collections.Collections.Get(toPartitionSet, a);
     if (aPartitionSet == null)
     {
         return(false);
     }
     return(ILOG.J2CsMapping.Collections.Collections.Contains(b, aPartitionSet));
 }
Esempio n. 18
0
 internal String CheckName(String name_0, ILOG.J2CsMapping.Collections.ISet alreadySeen)
 {
     if (name_0 == null)
     {
         return("");
     }
     if (ILOG.J2CsMapping.Collections.Collections.Contains(name_0, alreadySeen))
     {
         return(name_0);
     }
     ILOG.J2CsMapping.Collections.Generics.Collections.Add(alreadySeen, name_0);
     return("{" + name_0 + "=}");
 }
Esempio n. 19
0
 /// <summary>
 /// Return the name of the collator for the objectLocale, localized for
 /// the displayLocale. If objectLocale is not visible or not defined by
 /// the factory, return null.
 /// </summary>
 ///
 /// <param name="objectLocale">the locale identifying the collator</param>
 /// <param name="displayLocale">the locale for which the display name of the collatorshould be localized</param>
 /// <returns>the display name</returns>
 /// @stable ICU 3.2
 public String GetDisplayName(ULocale objectLocale, ULocale displayLocale)
 {
     if (Visible())
     {
         ILOG.J2CsMapping.Collections.ISet supported = GetSupportedLocaleIDs();
         String name = objectLocale.GetBaseName();
         if (ILOG.J2CsMapping.Collections.Collections.Contains(name, supported))
         {
             return(objectLocale.GetDisplayName(displayLocale));
         }
     }
     return(null);
 }
Esempio n. 20
0
        /// <summary>
        /// Convenience method for callers using locales. This returns the standard
        /// ULocale list, built from the Set of visible ids.
        /// </summary>
        ///
        public ULocale[] GetAvailableULocales()
        {
            ILOG.J2CsMapping.Collections.ISet visIDs = GetVisibleIDs();
            IIterator iter = new ILOG.J2CsMapping.Collections.IteratorAdapter(visIDs.GetEnumerator());

            ULocale[] locales = new ULocale[visIDs.Count];
            int       n       = 0;

            while (iter.HasNext())
            {
                locales[n++] = new ULocale((String)iter.Next());
            }
            return(locales);
        }
Esempio n. 21
0
        // we have a segment, in NFD. Find all the strings that are canonically
        // equivalent to it.
        private String[] GetEquivalents(String segment)
        {
            ILOG.J2CsMapping.Collections.ISet result       = new HashedSet();
            ILOG.J2CsMapping.Collections.ISet basic        = GetEquivalents2(segment);
            ILOG.J2CsMapping.Collections.ISet permutations = new HashedSet();

            // now get all the permutations
            // add only the ones that are canonically equivalent
            // TODO: optimize by not permuting any class zero.
            IIterator it = new ILOG.J2CsMapping.Collections.IteratorAdapter(basic.GetEnumerator());

            while (it.HasNext())
            {
                String item = (String)it.Next();
                ILOG.J2CsMapping.Collections.Collections.Clear(permutations);
                Permute(item, SKIP_ZEROS, permutations);
                IIterator it2 = new ILOG.J2CsMapping.Collections.IteratorAdapter(permutations.GetEnumerator());
                while (it2.HasNext())
                {
                    String possible = (String)it2.Next();

                    /*
                     * String attempt = Normalizer.normalize(possible,
                     * Normalizer.DECOMP, 0); if (attempt.equals(segment)) {
                     */
                    if (IBM.ICU.Text.Normalizer.Compare(possible, segment, 0) == 0)
                    {
                        if (PROGRESS)
                        {
                            System.Console.Out.WriteLine("Adding Permutation: "
                                                         + IBM.ICU.Impl.Utility.Hex(possible));
                        }
                        ILOG.J2CsMapping.Collections.Generics.Collections.Add(result, possible);
                    }
                    else
                    {
                        if (PROGRESS)
                        {
                            System.Console.Out.WriteLine("-Skipping Permutation: "
                                                         + IBM.ICU.Impl.Utility.Hex(possible));
                        }
                    }
                }
            }

            // convert into a String[] to clean up storage
            String[] finalResult = new String[result.Count];
            ILOG.J2CsMapping.Collections.Generics.Collections.ToArray(result, finalResult);
            return(finalResult);
        }
Esempio n. 22
0
        private void AddReason(Object a, Object b, Object reason)
        {
            IDictionary obj_reasons = (IDictionary)ILOG.J2CsMapping.Collections.Collections.Get(obj_obj_reasons, a);

            if (obj_reasons == null)
            {
                ILOG.J2CsMapping.Collections.Collections.Put(obj_obj_reasons, a, obj_reasons = new Hashtable());
            }
            ILOG.J2CsMapping.Collections.ISet reasons = (ISet)ILOG.J2CsMapping.Collections.Collections.Get(obj_reasons, b);
            if (reasons == null)
            {
                ILOG.J2CsMapping.Collections.Collections.Put(obj_reasons, b, reasons = new HashedSet());
            }
            ILOG.J2CsMapping.Collections.Generics.Collections.Add(reasons, reason);
        }
Esempio n. 23
0
            /*
             * private static final Object BAD = new Object(); private static final
             * Object GOOD = new Object();
             */

            public bool IsFailure(Pick pick_0, int item)
            {
                ArrayList val = (ArrayList)failures[index];

                if (val == null)
                {
                    return(false);
                }
                ILOG.J2CsMapping.Collections.ISet set = (ISet)val[item];
                if (set == null)
                {
                    return(false);
                }
                return(!ILOG.J2CsMapping.Collections.Collections.Contains(pick_0, set));
            }
Esempio n. 24
0
 internal RBBINode(RBBINode other)
 {
     this.fPrecedence = precZero;
     fSerialNum       = ++gLastSerial;
     fType            = other.fType;
     fInputSet        = other.fInputSet;
     fPrecedence      = other.fPrecedence;
     fText            = other.fText;
     fFirstPos        = other.fFirstPos;
     fLastPos         = other.fLastPos;
     fNullable        = other.fNullable;
     fVal             = other.fVal;
     fFirstPosSet     = new HashedSet(other.fFirstPosSet);
     fLastPosSet      = new HashedSet(other.fLastPosSet);
     fFollowPos       = new HashedSet(other.fFollowPos);
 }
Esempio n. 25
0
        public virtual bool Add(Object s)
        {
            ILOG.J2CsMapping.Collections.ISet o = (ISet)ILOG.J2CsMapping.Collections.Collections.Get(m, s);
            if (o == null)
            {
                o = new HashedSet(1);
                ILOG.J2CsMapping.Collections.Collections.Put(m, s, o);
            }
            bool result = ILOG.J2CsMapping.Collections.Generics.Collections.Add(o, s);

            if (result)
            {
                size++;
            }
            return(result);
        }
Esempio n. 26
0
        /// <summary>
        /// Convenience method for callers using locales. This returns the standard
        /// Locale list, built from the Set of visible ids.
        /// </summary>
        ///
        public ILOG.J2CsMapping.Util.Locale[] GetAvailableLocales()
        {
            // TODO make this wrap getAvailableULocales later
            ILOG.J2CsMapping.Collections.ISet visIDs = GetVisibleIDs();
            IIterator iter = new ILOG.J2CsMapping.Collections.IteratorAdapter(visIDs.GetEnumerator());

            ILOG.J2CsMapping.Util.Locale[] locales = new ILOG.J2CsMapping.Util.Locale[visIDs.Count];
            int n = 0;

            while (iter.HasNext())
            {
                ILOG.J2CsMapping.Util.Locale loc = IBM.ICU.Impl.LocaleUtility.GetLocaleFromName((String)iter.Next());
                locales[n++] = loc;
            }
            return(locales);
        }
Esempio n. 27
0
        internal void CheckMap(IDictionary m1, IDictionary m2)
        {
            if (m1.Equals(m2))
            {
                return;
            }
            StringBuilder buffer = new StringBuilder();

            ILOG.J2CsMapping.Collections.ISet m1entries = m1;
            ILOG.J2CsMapping.Collections.ISet m2entries = m2;
            GetEntries("\r\nIn First, and not Second", m1entries, m2entries,
                       buffer, 20);
            GetEntries("\r\nIn Second, and not First", m2entries, m1entries,
                       buffer, 20);
            Errln(buffer.ToString());
        }
Esempio n. 28
0
 public Object GetSample(Object a, XEquivalenceClass.Filter f)
 {
     ILOG.J2CsMapping.Collections.ISet aPartitionSet = (ISet)ILOG.J2CsMapping.Collections.Collections.Get(toPartitionSet, a);
     if (aPartitionSet == null)
     {
         return(a);    // singleton
     }
     for (IIterator it = new ILOG.J2CsMapping.Collections.IteratorAdapter(aPartitionSet.GetEnumerator()); it.HasNext();)
     {
         Object obj = it.Next();
         if (f.Matches(obj))
         {
             return(obj);
         }
     }
     return(a);
 }
Esempio n. 29
0
 /// <summary>
 /// gets the set of all the samples, one from each equivalence class.
 /// </summary>
 ///
 public ILOG.J2CsMapping.Collections.ISet GetSamples()
 {
     ILOG.J2CsMapping.Collections.ISet seenAlready = new HashedSet();
     ILOG.J2CsMapping.Collections.ISet result      = new HashedSet();
     for (IIterator it = new ILOG.J2CsMapping.Collections.IteratorAdapter(new ILOG.J2CsMapping.Collections.ListSet(toPartitionSet.Keys).GetEnumerator()); it.HasNext();)
     {
         Object item = it.Next();
         if (ILOG.J2CsMapping.Collections.Collections.Contains(item, seenAlready))
         {
             continue;
         }
         ILOG.J2CsMapping.Collections.ISet partition = (ISet)ILOG.J2CsMapping.Collections.Collections.Get(toPartitionSet, item);
         ILOG.J2CsMapping.Collections.Generics.Collections.Add(result, new ILOG.J2CsMapping.Collections.IteratorAdapter(partition.GetEnumerator()).Next());
         ILOG.J2CsMapping.Collections.Generics.Collections.AddAll(partition, seenAlready);
     }
     return(result);
 }
Esempio n. 30
0
            public void SetFailure(Pick pick_0, int item)
            {
                ArrayList val = (ArrayList)failures[index];

                if (val == null)
                {
                    val             = new ArrayList();
                    failures[index] = val;
                }
                ILOG.J2CsMapping.Collections.ISet set = (ISet)val[item];
                if (set == null)
                {
                    set       = new HashedSet();
                    val[item] = set;
                }
                ILOG.J2CsMapping.Collections.Generics.Collections.Add(set, pick_0);
            }