コード例 #1
0
        public static IEnumerable <OValRowInt> _spo(this IEnumerable <OValRowInt> rows, short subj, short pred, short obj)
        {
            var query = rows.Where(ovr =>
            {
                OVal[] row = ovr.row;
                // будем "плясать" от субъекта. TODO: наверное можно как-то задействовать и объектную цепочку
                OVal subj_oval = row[subj];
                OVal pred_oval = row[pred];
                OVal obj_oval  = row[obj];
                // Проверим через шкалу
                if (!ovr.StoreAbstract.Scale.ChkInScale(subj_oval.entity, pred_oval.entity, obj_oval.entity))
                {
                    return(false);
                }
                Diapason diap = new Diapason();
                if (subj_oval.spo_number >= 0)
                { // Диапазон определен
                    diap.start = subj_oval.spo_start;
                    diap.numb  = subj_oval.spo_number;
                }
                else
                {
                    Diapason di = ovr.StoreAbstract.GetDiap_spo(subj_oval.entity);
                    diap.start  = subj_oval.spo_start = di.start;
                    diap.numb   = subj_oval.spo_number = di.numb;
                }

                return(ovr.StoreAbstract.CheckPredObjInDiapason(diap, ovr.row[pred].entity, ovr.row[obj].entity));
            });

            return(query);
        }
コード例 #2
0
        // Определение всех данных по заданным s-p
        public static IEnumerable <OValRowInt> _spD(this IEnumerable <OValRowInt> rows, short subj, short pred, short dat)
        {
            var query = rows.SelectMany(ovr =>
            {
                OVal[] row     = ovr.row;
                OVal subj_oval = row[subj];
                OVal pred_oval = row[pred];
                OVal dat_oval  = row[dat];
                Diapason diap  = new Diapason();
                if (subj_oval.spd_number >= 0)
                { // Диапазон определен
                    diap.start = subj_oval.spd_start;
                    diap.numb  = subj_oval.spd_number;
                }
                else
                {
                    Diapason di = ovr.StoreAbstract.GetDiapason_spd(subj_oval.entity);
                    diap.start  = subj_oval.spd_start = di.start;
                    diap.numb   = subj_oval.spd_number = di.numb;
                }
                return(ovr.StoreAbstract.GetDatInDiapason(diap, row[pred].entity)
                       .Select(lit =>
                {
                    row[dat].lit = lit;
                    return new OValRowInt(ovr.StoreAbstract, row);
                }));
            });

            return(query);
        }
コード例 #3
0
        public static IEnumerable <OValRowInt> _Spo(this IEnumerable <OValRowInt> rows, short subj, short pred, short obj)
        {
            // Определены объект и предикат, нужно найти множество субъектов, побочным эффектом будет определение
            // и фиксация диапазона. Если диапазон уже есть, то диапазон не вычисляется, а используется
            var query = rows.SelectMany(rw =>
            {
                var row       = rw.row;
                OVal obj_oval = row[obj];
                Diapason diap = new Diapason();
                if (obj_oval.spo_number >= 0)
                { // Диапазон определен
                    diap.start = obj_oval.spo_start;
                    diap.numb  = obj_oval.spo_number;
                }
                else
                {
                    Diapason di = rw.StoreAbstract.GetDiap_op(obj_oval.entity);
                    diap.start  = obj_oval.spo_start = di.start;
                    diap.numb   = obj_oval.spo_number = di.numb;
                }
                return(rw.StoreAbstract.GetSubjInDiapason(diap, row[pred].entity)
                       .Select(su =>
                {
                    row[subj].entity = su; row[subj].op_number = -1; row[subj].spd_number = -1; row[subj].spo_number = -1;
                    return new OValRowInt(rw.StoreAbstract, row);
                }));
            });

            return(query);
        }
コード例 #4
0
ファイル: BerlinTestsInt.cs プロジェクト: agmarchuk/PolarDemo
        public static IEnumerable <OValRowInt> Berlin6(TripleStoreInt ts)
        {
            short _product = 0, _label = 1;
            short _bsbm_Product = 2;
            short _rdftype = 3, _rdfslabel = 4;

            OVal[] row = new OVal[] {
                new OVal()
                {
                    vid = OValEnumeration.obj
                },                                        // _product
                new OVal()
                {
                    vid = OValEnumeration.val
                },                                        // _label
                new OVal()
                {
                    vid = OValEnumeration.obj, entity = E(bsbm + "Product")
                },
                rdftype,
                rdfslabel,
            };
            System.Text.RegularExpressions.Regex rx = new System.Text.RegularExpressions.Regex("^s");

            OValRowInt ovr  = new OValRowInt(ts, row);
            var        quer = Enumerable.Repeat <OValRowInt>(ovr, 1)
                              ._Spo(_product, _rdftype, _bsbm_Product)
                              ._spD(_product, _rdfslabel, _label)
                              .Where(ovalrow => rx.IsMatch(((Text)ovalrow.row[_label].lit.value).s))
            ;

            return(quer);
        }
コード例 #5
0
        public static IEnumerable <OValRowInt> Berlin1(TripleStoreInt ts)
        {
            _ts = ts;
            short _product = 0, _bsbm_productFeature = 1, _bsbm_inst_ProductFeature19 = 2, _bsbm_inst_ProductFeature8 = 3;
            short _rdftype = 4, _bsbm_inst_ProductType1 = 5, _bsbm_ProductPropertyNumeric1 = 6;
            short _value1 = 7, _label = 8, _rdfslabel = 9;

            OVal[] row = new OVal[] {
                new OVal()
                {
                    vid = OValEnumeration.obj
                },                                        // _product
                new OVal()
                {
                    vid = OValEnumeration.obj, entity = E(bsbm + "productFeature")
                },
                new OVal()
                {
                    vid = OValEnumeration.obj, entity = E(bsbm_inst + "ProductFeature19")
                },
                new OVal()
                {
                    vid = OValEnumeration.obj, entity = E(bsbm_inst + "ProductFeature8")
                },
                rdftype,
                new OVal()
                {
                    vid = OValEnumeration.obj, entity = E(bsbm_inst + "ProductType1")
                },
                new OVal()
                {
                    vid = OValEnumeration.obj, entity = E(bsbm + "productPropertyNumeric1")
                },
                new OVal()
                {
                    vid = OValEnumeration.val
                },                                        // _value1
                new OVal()
                {
                    vid = OValEnumeration.val
                },                                        // _label
                rdfslabel
            };
            OValRowInt ovr  = new OValRowInt(ts, row);
            var        quer = Enumerable.Repeat <OValRowInt>(ovr, 1)
                              ._Spo(_product, _bsbm_productFeature, _bsbm_inst_ProductFeature19)
                              ._spo(_product, _bsbm_productFeature, _bsbm_inst_ProductFeature8)
                              ._spo(_product, _rdftype, _bsbm_inst_ProductType1)
                              ._spD(_product, _bsbm_ProductPropertyNumeric1, _value1)
                              .Where(ovalrow => (int)ovalrow.row[_value1].lit.Value > 1000)
                              ._spD(_product, _rdfslabel, _label)
            ;

            return(quer);
        }
コード例 #6
0
ファイル: OValRowInt.cs プロジェクト: agmarchuk/PolarDemo
 public void Set(short ind, OVal oval)
 {
     row[ind] = oval;
 }
コード例 #7
0
ファイル: BerlinTestsInt.cs プロジェクト: agmarchuk/PolarDemo
        // Концовка теста не доделана
        public static IEnumerable <OValRowInt> Berlin3(TripleStoreInt ts)
        {
            short _product = 0, _label = 1;
            short _p1 = 2, _p3 = 3;
            short _bsbm_productFeature = 4, _bsbm_inst_ProductFeature1 = 5, _bsbm_Product = 6;
            short _rdftype = 7, _bsbm_ProductPropertyNumeric1 = 8, _bsbm_ProductPropertyNumeric3 = 9, _rdfslabel = 10;

            OVal[] row = new OVal[] {
                new OVal()
                {
                    vid = OValEnumeration.obj
                },                                        // _product
                new OVal()
                {
                    vid = OValEnumeration.val
                },                                        // _label
                new OVal()
                {
                    vid = OValEnumeration.val
                },                                        // _p1
                new OVal()
                {
                    vid = OValEnumeration.val
                },                                        // _p2
                new OVal()
                {
                    vid = OValEnumeration.obj, entity = E(bsbm + "productFeature")
                },
                new OVal()
                {
                    vid = OValEnumeration.obj, entity = E(bsbm_inst + "ProductFeature1")
                },
                new OVal()
                {
                    vid = OValEnumeration.obj, entity = E(bsbm + "Product")
                },
                rdftype,
                new OVal()
                {
                    vid = OValEnumeration.obj, entity = E(bsbm + "productPropertyNumeric1")
                },
                new OVal()
                {
                    vid = OValEnumeration.obj, entity = E(bsbm + "productPropertyNumeric3")
                },
                rdfslabel,
            };

            OValRowInt ovr  = new OValRowInt(ts, row);
            var        quer = Enumerable.Repeat <OValRowInt>(ovr, 1)
                              ._Spo(_product, _bsbm_productFeature, _bsbm_inst_ProductFeature1)
                              //._spD(_product, _rdfslabel, _label)
                              //._spo(_product, _rdftype, _bsbm_Product)
                              ._spD(_product, _bsbm_ProductPropertyNumeric1, _p1)
                              //.Where(ovalrow => (int)ovalrow.row[_p1].lit.value > 1)
                              //._spD(_product, _bsbm_ProductPropertyNumeric3, _p3)
                              //.Where(ovalrow => (int)ovalrow.row[_p1].lit.value < 100000)
                              //._spD(_product, _rdfslabel, _label)
            ;

            return(quer);
        }