public static void InitIndex()
        {
            lock (MapInitLock)
            {
                index      = new AlphaTree <NumericNode>();
                synonymMap = new Dictionary <string, NumericNode>();

                //Basic numbers, we can add more if needed
                string[] numbers = { "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen", "twenty" };
                for (var i = 0; i < numbers.Length; i++)
                {
                    IndexString(numbers[i], new NumericNode(numbers[i], i + 1));
                }

                //Other numeric tokens
                NumericNode[] tokens =
                {
                    new NumericNode("a",              1),
                    new NumericNode("an",             1),
                    new NumericNode("half a",      0.5f),
                    new NumericNode("half of a",   0.5f),
                    new NumericNode("half an",     0.5f),
                    new NumericNode("half of an",  0.5f),
                    new NumericNode("a dozen",       12),
                    new NumericNode("one dozen",     12),
                    new NumericNode("a couple",       2),
                    new NumericNode("a couple of", 2)
                };

                foreach (var t in tokens)
                {
                    IndexString(t.Token, t);
                }
            }
        }
Beispiel #2
0
        public static void InitIndex(ISynonymLoader <AnomalousNode> loader)
        {
            lock (MapInitLock)
            {
                index      = new AlphaTree <AnomalousNode>();
                synonymMap = new Dictionary <string, AnomalousNode>();
                var anomalies = loader.LoadSynonyms();

                foreach (var anom in anomalies)
                {
                    IndexString(anom.Name, anom);
                }
            }
        }
Beispiel #3
0
        public static void InitIndex(ISynonymLoader <PrepNode> loader)
        {
            lock (MapInitLock)
            {
                index      = new AlphaTree <PrepNode>();
                synonymMap = new Dictionary <string, PrepNode>();
                var preps = loader.LoadSynonyms();

                foreach (var prep in preps)
                {
                    IndexString(prep.Prep, prep);
                }
            }
        }
        public static void InitIndex(ISynonymLoader <IngredientNode> loader)
        {
            lock (MapInitLock)
            {
                index      = new AlphaTree <IngredientNode>();
                synonymMap = new Dictionary <string, IngredientNode>();
                var ings = loader.LoadSynonyms();

                foreach (var ing in ings)
                {
                    IndexString(ing.IngredientName, ing);
                }
            }
        }
        public static void InitIndex(ISynonymLoader <FormNode> loader)
        {
            lock (MapInitLock)
            {
                index      = new AlphaTree <FormNode>();
                synonymMap = new Dictionary <string, FormNode>();

                foreach (var form in loader.LoadSynonyms())
                {
                    IndexString(form.FormName, form);
                }

                pairings = loader.LoadFormPairings();
            }
        }
Beispiel #6
0
        public static void InitIndex(ISynonymLoader <UnitNode> loader)
        {
            lock (MapInitLock)
            {
                index      = new AlphaTree <UnitNode>();
                synonymMap = new Dictionary <string, UnitNode>();

                //Hard code intrinsic unit types
                UnitNode[] units =
                {
                    new UnitNode("tsp",   Units.Teaspoon),   new UnitNode("t.",          Units.Teaspoon),   new UnitNode("t",            Units.Teaspoon),   new UnitNode("teaspoon",    Units.Teaspoon),   new UnitNode("teaspoons", Units.Teaspoon),
                    new UnitNode("tbl",   Units.Tablespoon), new UnitNode("tbsp",        Units.Tablespoon), new UnitNode("tablespoon",   Units.Tablespoon), new UnitNode("tablespoons", Units.Tablespoon),
                    new UnitNode("fl oz", Units.FluidOunce), new UnitNode("fluid ounce", Units.FluidOunce), new UnitNode("fluid ounces", Units.FluidOunce),
                    new UnitNode("cup",   Units.Cup),        new UnitNode("cups",        Units.Cup),        new UnitNode("c.",           Units.Cup),        new UnitNode("c",           Units.Cup),
                    new UnitNode("pt",    Units.Pint),       new UnitNode("pint",        Units.Pint),       new UnitNode("pints",        Units.Pint),
                    new UnitNode("qt",    Units.Quart),      new UnitNode("qts",         Units.Quart),      new UnitNode("quart",        Units.Quart),      new UnitNode("quarts",      Units.Quart),
                    new UnitNode("gal",   Units.Gallon),     new UnitNode("gallon",      Units.Gallon),     new UnitNode("gallons",      Units.Gallon),
                    new UnitNode("gram",  Units.Gram),       new UnitNode("g.",          Units.Gram),       new UnitNode("g",            Units.Gram),       new UnitNode("grams",       Units.Gram),
                    new UnitNode("oz",    Units.Ounce),      new UnitNode("ounce",       Units.Ounce),      new UnitNode("ounces",       Units.Ounce),
                    new UnitNode("lb",    Units.Pound),      new UnitNode("lbs",         Units.Pound),      new UnitNode("pound",        Units.Pound),      new UnitNode("pounds",      Units.Pound)
                };

                foreach (var unit in units)
                {
                    IndexString(unit.Name, unit);
                }

                //Load custom unit types through the loader
                foreach (var unit in loader.LoadSynonyms())
                {
                    IndexString(unit.Name.Trim(), unit);
                }

                //Load default pair data to map unit names to certain ingredient forms
                pairings = loader.LoadFormPairings();
            }
        }