Ejemplo n.º 1
0
        public static void Process(
            double[] InputOutput,
            Span <double> Output,
            double[] State,
            double[,] StateGateW,
            double[] StateGateOffset,
            double[,] UpdateStateW,
            double[] UpdateStateOffset,
            double[,] UpdateStateGateW,
            double[] UpdateStateGateOffset,
            double[,] OutputGateW,
            double[] OutputGateOffset,
            double[] OutputGateState,
            double[,] UpdateOutputW,
            double[] UpdateOutputOffset)
        {
            var state_length        = State.Length;
            var input_output_length = InputOutput.Length;
            var output_length       = Output.Length;

            // Расчёт состояния
            for (var i = 0; i < state_length; i++)
            {
                // Инициализация аккумуляторов значениями смещений слоёв
                var forget_state_gate = StateGateOffset[i];         // Аккумулятор вентиля сброса состояния
                var update_state_gate = UpdateStateGateOffset[i];   // Аккумулятор вентиля обновления состояния
                var update_state      = UpdateStateOffset[i];       // Аккумулятор обновления состояния

                // Расчёт выходов слоёв для обновления состояния
                for (var j = 0; j < input_output_length; j++)
                {
                    forget_state_gate += StateGateW[i, j] * InputOutput[j];
                    update_state_gate += UpdateStateGateW[i, j] * InputOutput[j];
                    update_state      += UpdateStateW[i, j] * InputOutput[j];
                }

                State[i] =
                    State[i] * Sigmoid.Activation(forget_state_gate)                        // Затухание состояния
                    + Th.Activation(update_state) * Sigmoid.Activation(update_state_gate);  // Обновление состояния
            }

            // Расчёт коэффициентов выходного вентиля
            for (var i = 0; i < output_length; i++)
            {
                // Инициализация выходного вентиля значением смещения слоя
                var s = OutputGateOffset[i];                        // Аккумулятор выходного вентиля

                // Расчёт выхода вентиля
                for (var j = 0; j < input_output_length; j++)
                {
                    s += OutputGateW[i, j] * InputOutput[j];
                }

                OutputGateState[i] = Sigmoid.Activation(s);
            }

            // Расчёт выхода на основе состояния
            for (var i = 0; i < output_length; i++)
            {
                // Инициализация аккумулятора выхода значением смещения слоя
                var s = UpdateOutputOffset[i];                      // Аккумулятор выхода

                // Расчёт выхода
                for (var j = 0; j < state_length; j++)
                {
                    s += UpdateOutputW[i, j] * State[j];
                }

                // Выход определяется как произведение аккумулятора и выходного вентиля
                Output[i] = Th.Activation(s) * OutputGateState[i];
            }
        }
Ejemplo n.º 2
0
        public JsonResult GetDbData()
        {
            /* Linq to SQL: effettuo la query */

            /*DataContext Db = new DataContext("Data Source=idea-dev\\IDEA;Initial Catalog=ZZZDEV001;Integrated Security=False;User Id=sa;Password=master2k5*;");
             * Table<WWWStatistiche> stat = Db.GetTable<WWWStatistiche>();
             * IQueryable<object> query = from c in stat
             *                        where 1 == 1
             *                        select c;
             * foreach(object record in query)
             * {
             * record.
             * }
             * Db.Dispose();*/
            AngularDEVContainer   context = new AngularDEVContainer();
            List <WWWStatistiche> stat    = (from c in context.WWWStatistiche
                                             where 1 == 1
                                             select c).ToList <WWWStatistiche>();


            /* creo gli oggetti JSON */
            JsonRS json_ret = new JsonRS();
            Th     Header   = new Th();
            Tr     Riga     = new Tr();

            PropertyInfo[] fields;
            dynamic        expObj = new ExpandoObject();

            for (var i = 0; i < stat.Count; i++)
            {
                fields = stat[i].GetType().GetProperties();
                if (i == 0) /* definizione intestazioni */
                {
                    for (var j = 0; j < fields.Length; j++)
                    {
                        Header         = new Th();
                        Header.nome    = fields[j].Name;
                        Header.caption = fields[j].Name;
                        Header.tipo    = fields[j].GetType().ToString();
                        Header.width   = "";
                        switch (fields[j].GetType().ToString().ToLower())
                        {
                        case "string": Header.align = "left"; break;

                        default: Header.align = "left"; break;
                        }
                        Header.format = "";
                        json_ret.head.Add(Header);
                    }
                }

                /* aggiungo le varie righe */
                Riga   = new Tr();
                expObj = new ExpandoObject();
                for (var j = 0; j < fields.Length; j++)
                {
                    AddProperty(expObj, fields[j].Name, stat[i].GetType().GetProperty(fields[j].Name).GetValue(stat[i]).ToString());
                }
                json_ret.body.Add(expObj);
            }

            /* restituisco l'output come JSON serializzato */
            JsonConvert.SerializeObject(json_ret);
            return(Json(json_ret));

            /* creo l'oggetto radice */
            JsonRS json_retz = new JsonRS();

            /* aggiungo i vari headers */
            Th Headerz = new Th();

            Header.nome    = "Colonna1";
            Header.caption = "Col 1";
            Header.tipo    = "string";
            Header.width   = "250px";
            Header.align   = "left";
            Header.format  = "";
            json_ret.head.Add(Header);
            Header         = new Th();
            Header.nome    = "Colonna2";
            Header.caption = "Col 2";
            Header.tipo    = "string";
            Header.width   = "";
            Header.align   = "left";
            Header.format  = "";
            json_ret.head.Add(Header);
            Header         = new Th();
            Header.nome    = "Colonna3";
            Header.caption = "Col 3";
            Header.tipo    = "string";
            Header.width   = "";
            Header.align   = "left";
            Header.format  = "";
            json_ret.head.Add(Header);
            Header         = new Th();
            Header.nome    = "Colonna4";
            Header.caption = "Col 4";
            Header.tipo    = "number";
            Header.width   = "100px";
            Header.align   = "right";
            Header.format  = "";
            json_ret.head.Add(Header);
            Header         = new Th();
            Header.nome    = "Colonna5";
            Header.caption = "Col 5";
            Header.tipo    = "datetime";
            Header.width   = "100px";
            Header.align   = "center";
            Header.format  = "";
            json_ret.head.Add(Header);

            /* aggiungo le varie righe */
            Tr      Rigaz   = new Tr();
            dynamic expObjz = new ExpandoObject();

            AddProperty(expObj, "Colonna1", "uallabalooza");
            AddProperty(expObj, "Colonna2", "in the");
            AddProperty(expObj, "Colonna3", "sky");
            AddProperty(expObj, "Colonna4", 245.1);
            AddProperty(expObj, "Colonna5", "01/01/9999");
            //json_ret.body.Add(new { Colonna1 = "uallabalooza", Colonna2 = "in the", Colonna3 = "sky", Colonna4 = 245.1, Colonna5 = "01/01/9999" });
            json_ret.body.Add(expObj);
            expObj = new ExpandoObject();
            AddProperty(expObj, "Colonna1", "rasti");
            AddProperty(expObj, "Colonna2", "blasti");
            AddProperty(expObj, "Colonna3", "lasagne");
            AddProperty(expObj, "Colonna4", -14000);
            AddProperty(expObj, "Colonna5", "01/01/9999");
            //json_ret.body.Add(new { Colonna1 = "rasti", Colonna2 = "blasti", Colonna3 = "lasagne", Colonna4 = -14000, Colonna5 = "01/01/9999" });
            json_ret.body.Add(expObj);
            expObj = new ExpandoObject();
            AddProperty(expObj, "Colonna1", "similili");
            AddProperty(expObj, "Colonna2", "la formica");
            AddProperty(expObj, "Colonna3", "brombagliumbal");
            AddProperty(expObj, "Colonna4", 15);
            AddProperty(expObj, "Colonna5", "01/01/9999");
            //json_ret.body.Add(new { Colonna1 = "similili", Colonna2 = "la formica", Colonna3 = "brombagliumbal", Colonna4 = 245.1, Colonna5 = "01/01/9999" });
            json_ret.body.Add(expObj);

            /* restituisco l'output come JSON serializzato */
            JsonConvert.SerializeObject(json_ret);
            return(Json(json_ret));
        }
Ejemplo n.º 3
0
        public JsonResult GetData()
        {
            return(GetDbData());

            /* creo l'oggetto radice */
            JsonRS json_ret = new JsonRS();

            /* aggiungo i vari headers */
            Th Header = new Th();

            Header.nome    = "Colonna1";
            Header.caption = "Col 1";
            Header.tipo    = "string";
            Header.width   = "250px";
            Header.align   = "left";
            Header.format  = "";
            json_ret.head.Add(Header);
            Header         = new Th();
            Header.nome    = "Colonna2";
            Header.caption = "Col 2";
            Header.tipo    = "string";
            Header.width   = "";
            Header.align   = "left";
            Header.format  = "";
            json_ret.head.Add(Header);
            Header         = new Th();
            Header.nome    = "Colonna3";
            Header.caption = "Col 3";
            Header.tipo    = "string";
            Header.width   = "";
            Header.align   = "left";
            Header.format  = "";
            json_ret.head.Add(Header);
            Header         = new Th();
            Header.nome    = "Colonna4";
            Header.caption = "Col 4";
            Header.tipo    = "number";
            Header.width   = "100px";
            Header.align   = "right";
            Header.format  = "";
            json_ret.head.Add(Header);
            Header         = new Th();
            Header.nome    = "Colonna5";
            Header.caption = "Col 5";
            Header.tipo    = "datetime";
            Header.width   = "100px";
            Header.align   = "center";
            Header.format  = "";
            json_ret.head.Add(Header);

            /* aggiungo le varie righe */
            Tr      Riga   = new Tr();
            dynamic expObj = new ExpandoObject();

            AddProperty(expObj, "Colonna1", "uallabalooza");
            AddProperty(expObj, "Colonna2", "in the");
            AddProperty(expObj, "Colonna3", "sky");
            AddProperty(expObj, "Colonna4", 245.1);
            AddProperty(expObj, "Colonna5", "01/01/9999");
            //json_ret.body.Add(new { Colonna1 = "uallabalooza", Colonna2 = "in the", Colonna3 = "sky", Colonna4 = 245.1, Colonna5 = "01/01/9999" });
            json_ret.body.Add(expObj);
            expObj = new ExpandoObject();
            AddProperty(expObj, "Colonna1", "rasti");
            AddProperty(expObj, "Colonna2", "blasti");
            AddProperty(expObj, "Colonna3", "lasagne");
            AddProperty(expObj, "Colonna4", -14000);
            AddProperty(expObj, "Colonna5", "01/01/9999");
            //json_ret.body.Add(new { Colonna1 = "rasti", Colonna2 = "blasti", Colonna3 = "lasagne", Colonna4 = -14000, Colonna5 = "01/01/9999" });
            json_ret.body.Add(expObj);
            expObj = new ExpandoObject();
            AddProperty(expObj, "Colonna1", "similili");
            AddProperty(expObj, "Colonna2", "la formica");
            AddProperty(expObj, "Colonna3", "brombagliumbal");
            AddProperty(expObj, "Colonna4", 15);
            AddProperty(expObj, "Colonna5", "01/01/9999");
            //json_ret.body.Add(new { Colonna1 = "similili", Colonna2 = "la formica", Colonna3 = "brombagliumbal", Colonna4 = 245.1, Colonna5 = "01/01/9999" });
            json_ret.body.Add(expObj);

            /* restituisco l'output come JSON serializzato */
            JsonConvert.SerializeObject(json_ret);
            return(Json(json_ret));
        }
Ejemplo n.º 4
0
        public List <double> puanHesapla(List <string> url_list)
        {
            #region tanımlamalar
            Title      title    = new Title();
            ahref      a        = new ahref();
            List <int> list     = new List <int>();
            UrlPuan    url_puan = new UrlPuan();

            List <double> title_Puan  = new List <double>();
            List <double> ahref_Puan  = new List <double>();
            List <double> h1_Puan     = new List <double>();
            List <double> h2_Puan     = new List <double>();
            List <double> h3_Puan     = new List <double>();
            List <double> h4_Puan     = new List <double>();
            List <double> h5_Puan     = new List <double>();
            List <double> h6_Puan     = new List <double>();
            List <double> big_Puan    = new List <double>();
            List <double> bold_Puan   = new List <double>();
            List <double> em_Puan     = new List <double>();
            List <double> head_Puan   = new List <double>();
            List <double> label_Puan  = new List <double>();
            List <double> li_Puan     = new List <double>();
            List <double> link_Puan   = new List <double>();
            List <double> option_Puan = new List <double>();
            List <double> p_Puan      = new List <double>();
            List <double> span_Puan   = new List <double>();
            List <double> strong_Puan = new List <double>();
            List <double> th_Puan     = new List <double>();
            //     List<double> toplamPuan = new List<double>();
            double[]  toplamPuan = new double[kelime_list.Count];
            ahref     ahref      = new ahref();
            h1        h1         = new h1();
            h2        h2         = new h2();
            h3        h3         = new h3();
            h4        h4         = new h4();
            h5        h5         = new h5();
            h6        h6         = new h6();
            Head      head       = new Head();
            LabelHtml labelHtml  = new LabelHtml();
            Link      link       = new Link();
            Span      span       = new Span();
            Strong    strong     = new Strong();
            Bold      bold       = new Bold();
            Em        em         = new Em();
            Li        li         = new Li();
            Option    option     = new Option();
            Th        th         = new Th();
            LabelHtml labelhtml  = new LabelHtml();


            Htmlİslemleri Cek_veri = new Htmlİslemleri();
            string        htmlstring;
            List <int>    kelimeSayilari       = new List <int>();
            int           KeyCount             = 0;
            List <double> standartSapmaListesi = new List <double>();
            double        standartSapma;
            List <double> URLpuan    = new List <double>();
            double        tekUrlPuan = 0;


            #endregion

            for (int j = 0; j < url_list.Count; j++)
            {
                htmlstring = Cek_veri.GetVeri(url_list[j]);
                HtmlAgilityPack.HtmlDocument htmldoc = new HtmlAgilityPack.HtmlDocument();
                htmldoc.LoadHtml(htmlstring);
                #region etiketPuanlama
                title_Puan  = title.sıralamaPuan(url_list, kelime_list, Cek_veri, title.etiket, title.puan, htmldoc);
                ahref_Puan  = ahref.sıralamaPuan(url_list, kelime_list, Cek_veri, ahref.etiket, ahref.puan, htmldoc);
                h1_Puan     = h1.sıralamaPuan(url_list, kelime_list, Cek_veri, h1.etiket, h1.puan, htmldoc);
                h2_Puan     = h2.sıralamaPuan(url_list, kelime_list, Cek_veri, h2.etiket, h2.puan, htmldoc);
                h3_Puan     = h3.sıralamaPuan(url_list, kelime_list, Cek_veri, h3.etiket, h3.puan, htmldoc);
                h4_Puan     = h4.sıralamaPuan(url_list, kelime_list, Cek_veri, h4.etiket, h4.puan, htmldoc);
                h5_Puan     = h5.sıralamaPuan(url_list, kelime_list, Cek_veri, h5.etiket, h5.puan, htmldoc);
                h6_Puan     = h6.sıralamaPuan(url_list, kelime_list, Cek_veri, h6.etiket, h6.puan, htmldoc);
                strong_Puan = strong.sıralamaPuan(url_list, kelime_list, Cek_veri, strong.etiket, strong.puan, htmldoc);
                bold_Puan   = bold.sıralamaPuan(url_list, kelime_list, Cek_veri, bold.etiket, bold.puan, htmldoc);
                em_Puan     = em.sıralamaPuan(url_list, kelime_list, Cek_veri, em.etiket, em.puan, htmldoc);
                head_Puan   = head.sıralamaPuan(url_list, kelime_list, Cek_veri, head.etiket, head.puan, htmldoc);
                label_Puan  = labelhtml.sıralamaPuan(url_list, kelime_list, Cek_veri, labelhtml.etiket, labelhtml.puan, htmldoc);
                li_Puan     = li.sıralamaPuan(url_list, kelime_list, Cek_veri, li.etiket, li.puan, htmldoc);
                link_Puan   = link.sıralamaPuan(url_list, kelime_list, Cek_veri, link.etiket, link.puan, htmldoc);
                option_Puan = option.sıralamaPuan(url_list, kelime_list, Cek_veri, option.etiket, option.puan, htmldoc);
                span_Puan   = span.sıralamaPuan(url_list, kelime_list, Cek_veri, span.etiket, span.puan, htmldoc);
                th_Puan     = th.sıralamaPuan(url_list, kelime_list, Cek_veri, th.etiket, th.puan, htmldoc);
                #endregion
                tekUrlPuan = 0;

                for (int i = 0; i < kelime_list.Count; i++)
                {
                    KeyCount = Cek_veri.FindWord(htmlstring, kelime_list[i]);
                    if (kelimeSayilari.Count == kelime_list.Count)
                    {
                        kelimeSayilari.Clear();
                    }
                    kelimeSayilari.Add(KeyCount);
                    if (i == kelime_list.Count - 1)
                    {
                        standartSapma = 0;
                        standartSapma = standart(kelimeSayilari);
                        standartSapmaListesi.Add(standartSapma);
                    }
                    #region uzunifkontrolu
                    toplamPuan[i] = 0;
                    if (ahref_Puan.Count != 0)
                    {
                        toplamPuan[i] = toplamPuan[i] + ahref_Puan[i];
                    }
                    if (title_Puan.Count != 0)
                    {
                        toplamPuan[i] = toplamPuan[i] + title_Puan[i];
                    }
                    if (h1_Puan.Count != 0)
                    {
                        toplamPuan[i] = toplamPuan[i] + h1_Puan[i];
                    }
                    if (h2_Puan.Count != 0)
                    {
                        toplamPuan[i] = toplamPuan[i] + h2_Puan[i];
                    }
                    if (h3_Puan.Count != 0)
                    {
                        toplamPuan[i] = toplamPuan[i] + h3_Puan[i];
                    }
                    if (h4_Puan.Count != 0)
                    {
                        toplamPuan[i] = toplamPuan[i] + h4_Puan[i];
                    }
                    if (h5_Puan.Count != 0)
                    {
                        toplamPuan[i] = toplamPuan[i] + h5_Puan[i];
                    }
                    if (h6_Puan.Count != 0)
                    {
                        toplamPuan[i] = toplamPuan[i] + h6_Puan[i];
                    }
                    if (strong_Puan.Count != 0)
                    {
                        toplamPuan[i] = toplamPuan[i] + strong_Puan[i];
                    }
                    if (bold_Puan.Count != 0)
                    {
                        toplamPuan[i] = toplamPuan[i] + bold_Puan[i];
                    }
                    if (head_Puan.Count != 0)
                    {
                        toplamPuan[i] = toplamPuan[i] + head_Puan[i];
                    }
                    if (label_Puan.Count != 0)
                    {
                        toplamPuan[i] = toplamPuan[i] + label_Puan[i];
                    }
                    if (li_Puan.Count != 0)
                    {
                        toplamPuan[i] = toplamPuan[i] + li_Puan[i];
                    }
                    if (link_Puan.Count != 0)
                    {
                        toplamPuan[i] = toplamPuan[i] + link_Puan[i];
                    }
                    if (option_Puan.Count != 0)
                    {
                        toplamPuan[i] = toplamPuan[i] + option_Puan[i];
                    }
                    if (span_Puan.Count != 0)
                    {
                        toplamPuan[i] = toplamPuan[i] + span_Puan[i];
                    }
                    if (th_Puan.Count != 0)
                    {
                        toplamPuan[i] = toplamPuan[i] + th_Puan[i];
                    }
                    #endregion
                    //2 kelime için puanı toplanıcak
                    tekUrlPuan = tekUrlPuan + toplamPuan[i];
                }
                if (kelime_list.Count == 1)
                {
                    URLpuan.Add(tekUrlPuan);
                }
                else
                {
                    URLpuan.Add(tekUrlPuan / standartSapmaListesi[j]);
                }
            }
            return(URLpuan);
        }
Ejemplo n.º 5
0
 public void WhenAssertingSomethingTrue()
 {
     Giv.n(ATruthyCondition);
     Wh.n(() => IExpressionThePreconditionWithMessage("A message"));
     Th.n(AnExceptionIsNotThrown);
 }
Ejemplo n.º 6
0
 public void WhenOneOfMultipleValuesIsNull()
 {
     Giv.n(() => Values("", 1, null));
     Th.n(() => Assert.Throws <DbcException>(() => Dbc.NotNull(_vls, "message")));
 }
Ejemplo n.º 7
0
 public void WhenAValueIsNull()
 {
     Giv.n(() => AValue(null));
     Th.n(() => Assert.Throws <DbcException>(() => Dbc.NotNull(_value)));
 }
Ejemplo n.º 8
0
 public void WhenAssertingSomethingWithMultipleConditions()
 {
     Giv.n(ATruthyCondition);
     Wh.n(() => IExpressionThePreconditionWithMessage("A message"));
     Th.n(ARequiresWithMultipleConditionsThrowsAnExceptionIfAnyConditionIsFalsey);
 }