public void TestProbabilisticSqlInsert()
        {
            string sentences = "INSERT INTO socialData VALUES (351,PROBABLY 785 25% ,Smith,Single) probably 50%";

            SqlInsertQuery query = new SqlInsertQuery(sentences);

            query.ProcessAndPopulateEachField();

            Assert.IsTrue(query.TupleP == 50.0);
            Assert.IsTrue(query.TableName == "socialData");
            Assert.IsTrue(query.Attributes.Count == 4);

            ProbabilisticSingleAttribute p = (ProbabilisticSingleAttribute)query.Attributes[1];

            Assert.IsTrue(p.Values[0] == "785");
            Assert.IsTrue(p.Probs[0] == 25.0);
        }
        public static ProbabilisticAttribute processProbabilisticValueClause(string probabilisticValues)
        {
            // pattern here is: Word DecimalNumber% / Word DecimalNumber% / ... (repeats)
            string          sPattern = @"\s*((?<value>[\w\s\.]+)|(?<values>\[.+?\]))\s+(?<prob>\d+)%\s*";
            MatchCollection matchs   = Regex.Matches(probabilisticValues, sPattern, RegexOptions.IgnoreCase);

            if (matchs.Count == 0)
            {
                throw new Exception("no matching on Probabilistic Value Clause");
            }

            List <String>         values         = new List <String>();
            List <Double>         pValues        = new List <Double>();
            List <List <string> > multiAttrbutes = new List <List <string> >();

            for (int i = 0; i < matchs.Count; i++)
            {
                String value         = matchs[i].Groups["value"].Value;
                String valuesCapture = matchs[i].Groups["values"].Value;

                String probability = matchs[i].Groups["prob"].Value;
                double attributeP  = 0;
                bool   isSuccess   = Double.TryParse(probability, out attributeP);
                if (!isSuccess)
                {
                    throw new Exception("probability value invalid");
                }
                pValues.Add(attributeP);

                if (!string.IsNullOrEmpty(valuesCapture))
                {
                    List <String> ListOfValue = ProcessListOfValues(valuesCapture);
                    multiAttrbutes.Add(ListOfValue);
                }
                else if (!string.IsNullOrEmpty(value))
                {
                    values.Add(value);
                }
                else
                {
                    throw new Exception("both value and values are empty !");
                }
            }

            if (values.Count > 0 && multiAttrbutes.Count == 0)
            {
                var pSingleAttribute = new ProbabilisticSingleAttribute(values, pValues);
                return(pSingleAttribute);
            }

            if (multiAttrbutes.Count > 0 && values.Count == 0)
            {
                bool consistency         = true;
                int  multiAttributesSize = multiAttrbutes[0].Count;
                foreach (var multiAttrbute in multiAttrbutes)
                {
                    if (multiAttributesSize != multiAttrbute.Count)
                    {
                        // multi attributes sould be of the same size.
                        consistency = false;
                    }
                }

                if (consistency)
                {
                    var multiAttribute = new ProbabilisticMultiAttribute(multiAttrbutes, pValues);
                    return(multiAttribute);
                }
            }
            throw new Exception("fail to parse probabilistic multi attributes");
        }