public bool CreateTraningInDB(string jsonSource)
        {
            int index = 0;

            try
            {
                IVocalabry               iVocalabry         = new Vocalabry(_wordDbContext);
                IEngineParser            engineParser       = new EngineParser(iVocalabry.GetNonPersistentVocalabry());
                List <ClassificatorItem> oMycustomclassname = Newtonsoft.Json.JsonConvert.DeserializeObject <List <ClassificatorItem> >(jsonSource);
                foreach (var item in oMycustomclassname)
                {
                    index++;
                    if (index < 204)
                    {
                        continue;
                    }
                    h_message newMessage = new h_message();
                    newMessage.TextType     = item.type_name;
                    newMessage.TextCategory = item.cat_name;
                    newMessage.TextKind     = item.kind_name;
                    var    array     = engineParser.GetOuptputVectors(item.type_name);
                    string tmpVector = string.Empty;
                    foreach (var vector in GetTrainSet(array))
                    {
                        tmpVector += (vector.ToString()).Replace(',', '.') + ",";
                    }

                    tmpVector         = tmpVector.Remove(tmpVector.Length - 1);
                    newMessage.Vector = tmpVector;
                    _wordDbContext.Add(newMessage);
                    _wordDbContext.SaveChanges();
                }
                _wordDbContext.SaveChanges();
                Console.WriteLine(oMycustomclassname.Count);

                return(true);
            }
            catch (Exception ex)
            {
                try
                {
                    _wordDbContext.SaveChanges();
                    return(false);
                }
                catch
                {
                    return(false);
                }
            }
        }
Example #2
0
        public virtual List <OutputCodeWord> GetOuptputVectors(string message)
        {
            string inputMeessage = message;

            string[] words = inputMeessage.Split(new[] { '/', ' ', '(', ')', ',', '*', ':', '.', ';', '-' });

            IVocalabry            iVocalabry   = new Vocalabry(_wordDbContext);
            IEngineParser         engineParser = new EngineParser(iVocalabry.GetNonPersistentVocalabry());
            List <OutputCodeWord> result       = new List <OutputCodeWord>();
            int debugIndex = 0;

            foreach (var item in words)
            {
                if (string.IsNullOrWhiteSpace(item))
                {
                    continue;
                }
                debugIndex++;
                result.Add(engineParser.CodeOneWord(item));
            }
            return(result);
        }