Пример #1
0
        public static void Identify()
        {
            List <string> comparisonList = new List <string>();

            comparisonList.Add("Gær");
            comparisonList.Add("Vand");
            comparisonList.Add("Salt");
            comparisonList.Add("Olie");
            comparisonList.Add("Fuldkornshvedemel");
            comparisonList.Add("Hvedemel");
            comparisonList.Add("Løg");
            comparisonList.Add("Hakkede tomater, konserves");
            comparisonList.Add("Oregano, tørret");
            comparisonList.Add("Grøn peberfrugt");
            comparisonList.Add("Medisterpølse. røget");
            comparisonList.Add("Oliven. sorte. uden sten. i saltlage");
            comparisonList.Add("Revet ost, mozzarella 45+");
            comparisonList.Add("Parmesanost. revet");
            comparisonList.Add("mini");

            /*
             * foreach (string str in comparisonList) {
             *  Console.WriteLine(str);
             * }
             */

            string longestString = "";
            int    size          = 0;
            string testString    = "Chili Medisterpølse";
            int    curSize       = 0;
            string resultString  = "";

            foreach (string str in comparisonList)
            {
                curSize = LongComSubstring.LongestCommonSubstring(testString, str, out longestString);
                if (curSize > size)
                {
                    size         = curSize;
                    resultString = longestString;
                }
            }

            Console.WriteLine(resultString);



            /*
             * //Jaccard Similarity
             * foreach (string str in comparisonList) {
             *  foreach (Ingredient ing in allIngredients) {
             *
             *      List<char> str1 = str.ToList<char>();
             *      List<char> str2 = ing.GetOrSetName.ToString().ToList<char>();
             *
             *      List<char> intersection = str.Intersect(str2).ToList<char>();
             *      List<char> union = str1.Union(str2).ToList<char>();
             *      double t = Convert.ToDouble(intersection.Count) / Convert.ToDouble(union.Count);
             *      if (t > 0.70) {
             *          Console.WriteLine("A match?: " + str + " and " + ing.GetOrSetName);
             *      }
             *  }
             * }
             * */
        }
Пример #2
0
        static void Main(string[] args)
        {
            string substring = "";
            int    length    = LongComSubstring.LongestCommonSubstring("penislægen", "penis", out substring);

            Console.WriteLine(length);
            Console.WriteLine(substring);
            IngredientIdentifier.Identify();

            Offer        off1   = null;
            List <Offer> offers = getOffers();

            for (int i = 530; i < 531; i++)
            {
                off1 = offers[i];
                Console.WriteLine(off1.heading);
                Console.WriteLine(off1.description);
                Console.WriteLine(off1.pricing.pre_price);
                Console.WriteLine(off1.pricing.price);
            }



            //IngredientIdentifier.nameGuessing(off1.heading, off1.description);

            Console.WriteLine("string: " + off1.heading);
            DBController      dbc            = new DBController();
            List <Ingredient> allIngredients = dbc.GetAllIngredients();

            dbc.Close();



            List <string> badWords = new List <string> {
                "i", "med", "fra", "af"
            };

            if (badWords.Contains("med"))
            {
                Console.WriteLine("indeholder, gem ikke");
            }
            else
            {
                Console.WriteLine("indeholder ikke, gem");
            }


            foreach (Offer off in offers)
            {
                Console.WriteLine(off.heading);
                List <string> words = IngredientIdentifier.importantWordsFromString(off.heading, ref allIngredients);
                foreach (string str in words)
                {
                    Console.WriteLine(str);
                }
                Console.ReadLine();
            }



            /*
             * DBDebug.dbMassInsert();
             * Script.ExcelExtractionScript();
             * UpdateDatabaseWithOffers();
             */



            Console.WriteLine("Starting Service...");
            //startRestService();

            //Script.ExcelExtractionScript();
            Console.WriteLine("Program Ended");
            while (true)
            {
            }

            Console.ReadLine();
        }