Esempio n. 1
0
        public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            if (stream.Current.Type == TokenType.Identifier && text.CompareOrdinal(stream.Current.Start, "and"))
            {
                Combinator = Children.AddCurrentAndAdvance(stream, SassClassifierType.Keyword);
            }

            if (stream.Current.Type == TokenType.OpenFunctionBrace)
            {
                OpenBrace = Children.AddCurrentAndAdvance(stream, SassClassifierType.FunctionBrace);
            }

            ParseItem feature;

            if (itemFactory.TryCreateParsedOrDefault(this, text, stream, out feature))
            {
                Feature = feature;
                Children.Add(feature);
            }

            if (stream.Current.Type == TokenType.Colon)
            {
                Colon = Children.AddCurrentAndAdvance(stream, SassClassifierType.Punctuation);
            }

            // dump all values
            while (!IsExpressionTerminator(stream.Current.Type))
            {
                ParseItem value;
                if (itemFactory.TryCreateParsedOrDefault(this, text, stream, out value))
                {
                    FeatureValues.Add(value);
                    Children.Add(value);
                }
                else
                {
                    Children.AddCurrentAndAdvance(stream);
                }
            }

            if (stream.Current.Type == TokenType.CloseFunctionBrace)
            {
                CloseBrace = Children.AddCurrentAndAdvance(stream, SassClassifierType.FunctionBrace);
            }

            return(Children.Count > 0);
        }
Esempio n. 2
0
        private void LoadDataSetFromXML(string Path)
        {
            // int NumberOfRules = 0;
            string line;

            int       CategoryIndex   = 0;
            ArrayList tmpFeaturesList = new ArrayList();

            using (StreamReader reader = new StreamReader(Path))
            {
                while ((line = reader.ReadLine()) != null)
                {
                    if (line != null)
                    {
                        if (line.ToLower().IndexOf("<rule") != -1)
                        {
                            string s = line;
                            s = s.Replace("'", "");
                            if (!Ds.Contains(s))
                            {
                                Ds.Add(s);
                            }
                            CategoryIndex = Ds.IndexOf(s);
                            // NumberOfRules++;
                        }
                        if (line.ToLower().IndexOf("</rule") != -1)
                        {
                            Dataset.Rules.Add((ArrayList)tmpFeaturesList.Clone());
                            Dataset.Categories.Add(CategoryIndex);
                            tmpFeaturesList.Clear();
                        }

                        if (line.ToLower().Contains("<tuple"))
                        {
                            string DecodedVal = StringOperations.GetAttrVal("Val", line);
                            string NewLine    = line.Replace(DecodedVal, System.Web.HttpUtility.HtmlEncode(DecodedVal));

                            if (line.ToLower().Contains("tuple") && !FS.Contains(line))
                            {
                                FS.Add(NewLine);
                            }
                            int fIndex = FS.IndexOf(NewLine);
                            if (!tmpFeaturesList.Contains(fIndex))
                            {
                                tmpFeaturesList.Add(fIndex);
                            }
                        }
                    }
                }
            }

            for (int v = 0; v < FS.Count; v++)
            {
                FeatureValues fv = new FeatureValues();
                for (int i = 0; i < Dataset.Rules.Count; i++)
                {
                    ArrayList tuple = (ArrayList)Dataset.Rules[i];

                    if (tuple.Contains(v))
                    {
                        fv.count++;
                        fv.RowsIndices.Add(i);
                    }
                }
                DsMeta.Add(fv);
            }
        }
Esempio n. 3
0
        public void IsUnique(NotUniqueSet CurrentSetPositions, int threadID)
        {
            if (HasSubsumtions_Traditional(CurrentSetPositions._NotUniqueSet))
            {
                TotalPartialReduct++;
                return;
            }
            ArrayList PassedSetRowIndices = new ArrayList();
            ArrayList allListInterSection = new ArrayList();

            if (CurrentLevel > 1)
            {
                int           NewAddedFeature = (int)CurrentSetPositions._NotUniqueSet[CurrentSetPositions._NotUniqueSet.Count - 1];
                FeatureValues fv = DsMeta[NewAddedFeature];
                PassedSetRowIndices.Add((ArrayList)fv.RowsIndices.Clone());
                PassedSetRowIndices.Add((ArrayList)CurrentSetPositions._NotUniqueSetIndexes.Clone());
                ArrayList OldSetIndices = (ArrayList)CurrentSetPositions._NotUniqueSetIndexes.Clone();
                allListInterSection = fnGetIntersection1(PassedSetRowIndices);
                CurrentSetPositions._NotUniqueSetIndexes = (ArrayList)allListInterSection.Clone();
                if (allListInterSection.Count == OldSetIndices.Count)
                {
                    NrOfNonesenseSets++;
                    TotalNoneSense++;
                    return;
                }
            }
            else
            {
                FeatureValues fv = DsMeta[(int)CurrentSetPositions._NotUniqueSet[0]];
                allListInterSection.AddRange(fv.RowsIndices);
                CurrentSetPositions._NotUniqueSetIndexes = allListInterSection;
            }
            int    c = 1;
            string t = Dataset.Categories[Int32.Parse(allListInterSection[0].ToString())].ToString();

            for (int k = 1; k < allListInterSection.Count; k++)
            {
                if (t != Dataset.Categories[Int32.Parse(allListInterSection[k].ToString())].ToString())
                {
                    c++;
                    break;
                }
            }
            double MaxClassCount = ClassesCounterTmp.Max();

            if (c == 1)
            {
                TotalUnique++;
                FeatureValues fv = new FeatureValues();
                fv.UnkSet      = (ArrayList)CurrentSetPositions._NotUniqueSet.Clone();
                fv.RowsIndices = (ArrayList)allListInterSection.Clone();
                PublicUniq[threadID].Add(fv);
                if (CurrentLevel == 1)
                {
                    SkipperListComplement.Remove(CurrentSetPositions._NotUniqueSet[0]);
                    if (SkipperListComplement.Count > 0)
                    {
                        LastFeature = (int)SkipperListComplement[SkipperListComplement.Count - 1];
                    }
                }
                return;
            }

            // not unique Handling
            TotalNotUnique++;
            if (!CurrentSetPositions._NotUniqueSet.Contains(LastFeature))
            {
                NotUniqueSet nus = new NotUniqueSet();
                nus._NotUniqueSet        = (ArrayList)CurrentSetPositions._NotUniqueSet.Clone();
                nus._NotUniqueSetIndexes = (ArrayList)allListInterSection.Clone();
                PublicNotUniq[threadID].Add(nus);
                NrOfNotUniqueThatWillBeChecked++;
            }
            //end
        }