Пример #1
0
        public void TestJsonConvertibleMulti()
        {
            using (var vw = new VowpalWabbitExampleValidator <JsonRawAdfString>(new VowpalWabbitSettings("--cb_adf")
            {
                TypeInspector = JsonTypeInspector.Default
            }))
            {
                vw.Validate(new[] {
                    "shared | Bar:5",
                    " | Foo:1 |Value test:1.2",
                    " | Foo:2 |Value test:2.3",
                    " | Foo:3 |Value titleabc\"def",
                },
                            new JsonRawAdfString
                {
                    Bar    = 5,
                    _multi = new[]
                    {
                        new JsonRawString
                        {
                            Foo   = 1,
                            Value = JsonConvert.SerializeObject(new { test = 1.2 })
                        },
                        new JsonRawString
                        {
                            Foo   = 2,
                            Value = JsonConvert.SerializeObject(new { test = 2.3 })
                        },
                        new JsonRawString
                        {
                            Foo   = 3,
                            Value = JsonConvert.SerializeObject(new { title = "abc\"def", _ignoreMe = 1 })
                        },
                    }
                });

                var adf = new JsonRawString
                {
                    Foo    = 1,
                    Value  = JsonConvert.SerializeObject(new { A = new { test = 1.2 }, B = new { bar = 2 } }),
                    Values = new[]
                    {
                        JsonConvert.SerializeObject(new { D = new { d = 1.2 } }),
                        JsonConvert.SerializeObject(new { E = new { e = true } }),
                    }.ToList()
                };

                var ctx = new JsonRawAdfString
                {
                    Bar    = 5,
                    _multi = new[] { adf }
                };

                vw.Validate(new[] {
                    "shared | Bar:5",
                    " | Foo:1 |A test:1.2 |B bar:2 |D d:1.2 |E e"
                }, ctx);
            }
        }
Пример #2
0
        public void TestJsonConvertible()
        {
            using (var vw = new VowpalWabbitExampleValidator <JsonRawString>(new VowpalWabbitSettings("")
            {
                TypeInspector = JsonTypeInspector.Default
            }))
            {
                var adf = new JsonRawString
                {
                    Foo    = 1,
                    Value  = JsonConvert.SerializeObject(new { A = new { test = 1.2 }, B = new { bar = 2 } }),
                    Values = new[]
                    {
                        JsonConvert.SerializeObject(new { D = new { d = 1.2 } }),
                        JsonConvert.SerializeObject(new { E = new { e = true } }),
                        JsonConvert.SerializeObject(new { F = new { title = "abc\"def" } }),
                    }.ToList()
                };

                vw.Validate(" | Foo:1 |A test:1.2 |B bar:2 |D d:1.2 |E e |F titleabc\"def", adf);
            }
        }