public void GenerateSymptoms(IList <EventModel> models)
        {
            // initialize dictionary
            var dictionary = getDictionary(models.Select(m => m.Message).ToArray());

            // for each EventModel generate symptom
            foreach (var eventModel in models)
            {
                // initialize vector
                var symptom = new SymptomModel(dictionary.Count);

                // get all words in event message
                var words = eventModel.Message.Split(WORD_SPLIT_PATTERN, StringSplitOptions.RemoveEmptyEntries);

                foreach (var word in words)
                {
                    // find word index in dictionary
                    var index = dictionary.IndexOf(word.ToLower());

                    // increase word count in symptom
                    symptom.Symptom[index]++;
                }

                eventModel.SymptomModel = symptom;
            }
        }
        public void GenerateSymptoms(IList <EventModel> models)
        {
            // initialize dictionary
            var dictionary = getDictionary(models.Select(m => m.Message).ToArray());

            // for each EventModel generate symptom
            foreach (var eventModel in models)
            {
                // initialize vector
                var symptom = new SymptomModel(dictionary.Count);

                // get all words in event message
                var words = eventModel.Message.Split(WORD_SPLIT_PATTERN, StringSplitOptions.RemoveEmptyEntries);

                foreach (var word in words)
                {
                    // find word index in dictionary
                    var index = dictionary.IndexOf(word.ToLower());

                    var termFrequency = words.Count(w => w.CompareTo(word) == 0) / (double)words.Count();

                    var inverseDocumentFrequency = Math.Log(models.Count / models.Count(model => model.Message.Contains(word)));

                    // calculate tf-idf
                    symptom.Symptom[index] = termFrequency * inverseDocumentFrequency;
                }

                eventModel.SymptomModel = symptom;
            }
        }
        public ActionResult Create(SymptomModel symptommodel)
        {
            if (ModelState.IsValid)
            {
                DataContext.Symptoms.Add(symptommodel);
                DataContext.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(symptommodel);
        }
Example #4
0
        public Symptom manageSymptom(SymptomModel model)
        {
            using (var context = IoCContainer.Get <IEntity>())
            {
                var repositorySymptoms = context.GetRepository <IRepository <Symptom> >();

                var newSymptom = new Symptom();
                if (model.id.HasValue)
                {
                    newSymptom      = repositorySymptoms.Find(new Entity.Specifications.POCO.Symptom.ById((int)model.id)).First();
                    newSymptom.name = model.name;
                }
                else
                {
                    newSymptom = new Symptom
                    {
                        name = model.name
                    };

                    repositorySymptoms.Add(newSymptom);

                    context.SaveChanges();

                    var repSymptoms = repositorySymptoms.GetAll().ToList();

                    var repositoryDiagnoses = context.GetRepository <IRepository <Diagnos> >();

                    var repositoryWeights = context.GetRepository <IRepository <Weight> >();

                    var a = repositoryDiagnoses.GetAll(new List <Expression <Func <Diagnos, object> > >
                    {
                        t => t.weights,
                        t => t.weights.Select(q => q.Key)
                    }).ToList();
                    a.ForEach(t => {
                        var diagnos = t;
                        var weight  = new Weight(newSymptom, new Random().Next(0, 10));
                        repositoryWeights.Add(weight);
                        context.SaveChanges();
                        var repWeight = repositoryWeights.GetAll().ToList();
                        diagnos.weights.Add(weight);
                    });
                }

                newSymptom.isMale   = model.isMale;
                newSymptom.isFemale = model.isFemale;

                context.SaveChanges();

                return(newSymptom);
            }
        }
        public void GenerateSymptoms(IList <EventModel> models)
        {
            // initialize dictionary
            var dictionary = getDictionary();

            // for each EventModel generate symptom
            foreach (var eventModel in models)
            {
                // initialize vector
                var symptom = new SymptomModel(dictionary.Values.First().Length);

                // get all words in event message
                var words = eventModel.Message.Split(WORD_SPLIT_PATTERN, StringSplitOptions.RemoveEmptyEntries);

                foreach (var word in words)
                {
                    // find vector associated with this word in dictionary
                    if (dictionary.TryGetValue(word, out var vector))
                    {
                        // sumarize all words vector
                        for (var index = 0; index < vector.Length; index++)
                        {
                            symptom.Symptom[index] += vector[index];
                        }

                        // make average of sum
                        for (var index = 0; index < vector.Length; index++)
                        {
                            symptom.Symptom[index] /= words.Length;
                        }
                    }
                }

                eventModel.SymptomModel = symptom;
            }
        }
Example #6
0
 public async Task InsertPatientSymptom(string patient, int patientDiagnoseId, SymptomModel symptom)
 {
     await _client.PostAsJsonAsync($"/patient/{patient}/diagnose/{patientDiagnoseId}/symptom", symptom);
 }
 public ActionResult Edit(SymptomModel symptommodel)
 {
     if (ModelState.IsValid)
     {
         DataContext.Entry(symptommodel).State = EntityState.Modified;
         DataContext.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(symptommodel);
 }
Example #8
0
        public HttpResponseMessage Symptom(SymptomModel model)
        {
            var symptom = new NeuralLogic().manageSymptom(model).toModel();

            return(Request.CreateResponse(HttpStatusCode.OK, symptom));
        }