예제 #1
0
        public IEnumerable <AnomalousNode> LoadSynonyms()
        {
            using (var session = adapter.GetStatelessSession())
            {
                var anomalies = session.QueryOver <NlpAnomalousIngredients>()
                                .Fetch(prop => prop.Ingredient).Eager()
                                .Fetch(prop => prop.WeightForm).Eager()
                                .Fetch(prop => prop.VolumeForm).Eager()
                                .Fetch(prop => prop.UnitForm).Eager()
                                .List();

                var ret = new List <AnomalousNode>();

                foreach (var anon in anomalies)
                {
                    var name    = anon.Name;
                    var ing     = anon.Ingredient.IngredientId;
                    var ingName = anon.Ingredient.DisplayName;

                    IngredientForm weightForm = null, volumeForm = null, unitForm = null;
                    if (anon.WeightForm != null)
                    {
                        weightForm = new IngredientForm(
                            anon.WeightForm.IngredientFormId,
                            ing,
                            anon.WeightForm.UnitType,
                            anon.WeightForm.FormDisplayName,
                            anon.WeightForm.UnitName,
                            anon.WeightForm.ConvMultiplier,
                            new Amount(anon.WeightForm.FormAmount, anon.WeightForm.FormUnit));
                    }

                    if (anon.VolumeForm != null)
                    {
                        volumeForm = new IngredientForm(
                            anon.VolumeForm.IngredientFormId,
                            ing,
                            anon.VolumeForm.UnitType,
                            anon.VolumeForm.FormDisplayName,
                            anon.VolumeForm.UnitName,
                            anon.VolumeForm.ConvMultiplier,
                            new Amount(anon.VolumeForm.FormAmount, anon.VolumeForm.FormUnit));
                    }

                    if (anon.UnitForm != null)
                    {
                        unitForm = new IngredientForm(
                            anon.UnitForm.IngredientFormId,
                            ing,
                            anon.UnitForm.UnitType,
                            anon.UnitForm.FormDisplayName,
                            anon.UnitForm.UnitName,
                            anon.UnitForm.ConvMultiplier,
                            new Amount(anon.UnitForm.FormAmount, anon.UnitForm.FormUnit));
                    }

                    var pairings = new DefaultPairings()
                    {
                        Weight = weightForm, Volume = volumeForm, Unit = unitForm
                    };
                    var ingNode = new AnomalousIngredientNode(ing, ingName, UnitType.Unit, 0, pairings); //TODO: Must load conv type and unit weight
                    ret.Add(new AnomalousNode(name, ingNode));
                }

                return(ret);
            }
        }
예제 #2
0
 public AnomalousNode(string name, AnomalousIngredientNode ing)
 {
     Name       = name;
     Ingredient = ing;
 }
예제 #3
0
        public IEnumerable <AnomalousNode> LoadSynonyms()
        {
            var forms       = store.GetIndexedIngredientForms();
            var ingredients = store.GetIndexedIngredients();
            var anomalies   = store.NlpAnomalousIngredients;

            var ret = new List <AnomalousNode>();

            foreach (var anon in anomalies)
            {
                var ingredient = ingredients[anon.IngredientId];

                var name    = anon.Name;
                var ing     = anon.IngredientId;
                var ingName = ingredient.DisplayName;

                IngredientForm weightForm = null, volumeForm = null, unitForm = null;
                if (anon.WeightFormId.HasValue)
                {
                    var wf = forms[anon.WeightFormId.Value];

                    weightForm = new IngredientForm(
                        wf.IngredientFormId,
                        ing,
                        wf.UnitType,
                        wf.FormDisplayName,
                        wf.UnitName,
                        wf.ConvMultiplier,
                        new Amount(wf.FormAmount, wf.FormUnit));
                }

                if (anon.VolumeFormId.HasValue)
                {
                    var vf = forms[anon.VolumeFormId.Value];

                    volumeForm = new IngredientForm(
                        vf.IngredientFormId,
                        ing,
                        vf.UnitType,
                        vf.FormDisplayName,
                        vf.UnitName,
                        vf.ConvMultiplier,
                        new Amount(vf.FormAmount, vf.FormUnit));
                }

                if (anon.UnitFormId.HasValue)
                {
                    var uf = forms[anon.UnitFormId.Value];

                    unitForm = new IngredientForm(
                        uf.IngredientFormId,
                        ing,
                        uf.UnitType,
                        uf.FormDisplayName,
                        uf.UnitName,
                        uf.ConvMultiplier,
                        new Amount(uf.FormAmount, uf.FormUnit));
                }

                var pairings = new DefaultPairings()
                {
                    Weight = weightForm, Volume = volumeForm, Unit = unitForm
                };
                var ingNode = new AnomalousIngredientNode(ing, ingName, UnitType.Unit, 0, pairings); //TODO: Must load conv type and unit weight
                ret.Add(new AnomalousNode(name, ingNode));
            }

            return(ret);
        }
예제 #4
0
 public AnomalousNode(string name, AnomalousIngredientNode ing)
 {
     Name = name;
      Ingredient = ing;
 }
예제 #5
0
 public AnomalousNode(string name, AnomalousIngredientNode ingredient)
 {
     this.Name = name;
     this.Ingredient = ingredient;
 }