public async Task <List <AiGroup> > ParseGroups(WordDbContext wordDbContext, Variant variant, List <Word> words, AiSentence aiSentence) { List <AiGroup> result = new List <AiGroup>(); var gropups = variant.Groups.ToList(); int i = 0; foreach (var item in gropups) { AiGroup aiGroup = new AiGroup(); aiGroup.AiDescription = await FindOrAddAiDescription(wordDbContext, item.Descr); aiGroup.Last = (int)item.Last; aiGroup.Start = (int)item.Start; aiGroup.IsSubj = item.IsSubj; aiGroup.IsGoup = item.IsGroup; item.AiGroup = aiGroup; SetParent(gropups, item, i == 0 ? -1 : i); result.Add(aiGroup); aiGroup.AiSentence = aiSentence; wordDbContext.Add(aiGroup); CreateAiWordsGroup(words, aiGroup, wordDbContext); i++; } //SetParentIdGroups(result); return(result); }
public BaseEfTest() { var mock = new Mock <IDataBaseMain>(); mock.Setup(main => main.ConntectionString).Returns( "Server=localhost;Port=3306;Database=monicacrm;User Id=RassvetAis;Password=RassvetLine6642965;TreatTinyAsBoolean=true;"); _crmDbContext = new WordDbContext(mock.Object); }
public LoaderFile(WordDbContext wordDbContext, IParserAdapter parserAdapter, IAiParser aiParser, IDataBaseMain dataBaseMain) { _wordDbContext = wordDbContext; _parserAdapter = parserAdapter; _aiParser = aiParser; _dataBaseMain = dataBaseMain; _pathDoc = Path.Combine(GlobalSettingsApp.CurrentAppDirectory, "Documents"); }
private void CreateAiWordsGroup(List <Word> words, AiGroup aiGroup, WordDbContext wordDbContext) { var cols = words.Skip(aiGroup.Start).Take(aiGroup.Last + 1); foreach (var word in cols) { var aiGroupWord = new AiGroupWord(); aiGroupWord.AiWord = word.AiWord; aiGroupWord.AiGroup = aiGroup; wordDbContext.Add(aiGroupWord); } }
protected async Task <AiDescription> FindOrAddAiDescription(WordDbContext wordDbContext, string name) { AiDescription description = await wordDbContext.AiDescription.FirstOrDefaultAsync(f => f.Name == name); if (description == null) { description = new AiDescription() { Name = name }; wordDbContext.AiDescription.Add(description); wordDbContext.Add(description); } return(description); }
public ClassficatorCategory(WordDbContext wordDbContext, IVocalabry vocalabry) { _wordDbContext = wordDbContext; _vocalabry = vocalabry; _categoryClassification = new MulticlassSupportVectorLearning <Linear>() { Learner = (p) => new LinearDualCoordinateDescent() { Loss = Loss.L2 } }; _messages = InitLearnData(); EngineParser = new EngineParser(_vocalabry.GetNonPersistentVocalabry()); InitLearningMachine(); }
public AiSentenceEngine(IAiGroup aiGroup, WordDbContext wordDbContext) { _aiGroup = aiGroup; _wordDbContext = wordDbContext; }
public UserAdapter(WordDbContext wordDbContext) { _wordDbContext = wordDbContext; }
public ActionResult PostComment(string msg, RatingViewModel model, int?id) { ViewBag.ansId = id; var v = _db.Answers.FirstOrDefault(m => m.AnswerId.Equals(id.Value)); if (v != null) { ViewBag.quesTionid = v.QuestionId; } ViewBag.id = id; TempData["HPostController"] = 7; var strList = new List <SensitiveWordsViewModel>(); var wdb = new WordDbContext(); if (Request.IsAuthenticated) { var u = _db.ForumUser.SingleOrDefault(m => m.UserName.Equals(User.Identity.Name)); if (u != null) { var userId = u.UserId; if (true) { var authUserId = u.UserId; var w = _db.Answers.SingleOrDefault(m => m.AnswerId.Equals(id.Value)); if (w != null) { var thisAnsUserId = w.UserId; if (authUserId == thisAnsUserId) { ViewData["EnableEdit"] = 1; } } if (msg != "") { var ms = ""; var sensitiveWods = wdb.Words.Select(m => m.SensitiveWord); var convt = msg.ToLower(); foreach (var str in sensitiveWods) { if (!convt.Contains(str.ToLower())) { continue; } var sensitive = new SensitiveWordsViewModel { SensitiveWords = str }; strList.Add(sensitive); ViewBag.senWordsMsg = 11; ms = str; } IEnumerable <SensitiveWordsViewModel> s = strList; ViewData["s"] = s; ViewData["op"] = 1; if (ms == "") { _comment.CommentMsg = msg; _comment.UserId = userId; if (id != null) { _comment.AnswerId = id.Value; _comment.PostedDateTime = DateTime.Now; _db.Comment.Add(_comment); _db.SaveChanges(); var t = _db.PostInformation.SingleOrDefault(m => m.UserId.Equals(userId)); if (t != null) { var posId = t.PostId; var totalCommentPost = _db.PostInformation.Find(posId).TotalCommentPost; if (totalCommentPost != null) { var prevPosts = totalCommentPost.Value; var pi = _db.PostInformation.Find(posId); pi.TotalCommentPost = prevPosts + 1; _db.Entry(pi).State = EntityState.Modified; } } _db.SaveChanges(); ViewBag.emptyBox = 1; UpdateTotalComments(id.Value); DisplayAnswerAndPostedUserInfo(id.Value); DisplayComments(id.Value); } } if (id != null) { DisplayAnswerAndPostedUserInfo(id.Value); DisplayComments(id.Value); } } else { if (id != null) { DisplayAnswerAndPostedUserInfo(id.Value); DisplayComments(id.Value); } ViewData["op"] = 1; ViewData["ReqMsg"] = 1; ViewBag.errormsg = "* You must Write Something! to Post comment"; //return View("Comments"); } } } } else { if (id != null) { DisplayAnswerAndPostedUserInfo(id.Value); DisplayComments(id.Value); } ViewData["op"] = 1; ViewData["ReqMsg"] = 1; ViewData["c"] = 5; //return View("Comments"); } try { var totalScore = _db.Rating.Where(m => m.AnswerId.Equals(id.Value)).Sum(m => m.RateScore); var totalRater = _db.Rating.Count(m => m.AnswerId.Equals(id.Value)); var avgScore = (double)totalScore / totalRater; ViewData["raiting"] = avgScore; } catch (Exception e) { } return(View("Comments", model)); }
public ActionResult PostAnswer(int?id, string msg) { if (id != null) { ViewBag.id = id.Value; if (Request.IsAuthenticated) { var authuserId = _db.ForumUser.Single(m => m.UserName.Equals(User.Identity.Name)).UserId; if (msg != "") { if (msg.Length >= 10) { var ms = ""; var wdb = new WordDbContext(); var sensitiveWods = wdb.Words.Select(m => m.SensitiveWord); var strList = new List <SensitiveWordsViewModel>(); var convt = msg.ToLower(); foreach (var str in sensitiveWods) { if (!convt.Contains(str.ToLower())) { continue; } var sensitive = new SensitiveWordsViewModel { SensitiveWords = str }; strList.Add(sensitive); ViewBag.senWordsMsg = 11; ms = str; } if (ms == "") { var checKIsReplyExist = _db.Answers.Any(m => m.UserId.Equals(authuserId) && m.QuestionId.Equals(id.Value)); if (!checKIsReplyExist) { var ans = new Answers { UserId = authuserId, AnsweredTimeDate = DateTime.Now, QuestionId = id.Value, Answer = msg, Rating = 0 }; _db.Answers.Add(ans); _db.SaveChanges(); var u = _db.PostInformation.SingleOrDefault(m => m.UserId.Equals(authuserId)); if (u != null) { var posId = u.PostId; var v = _db.PostInformation.Find(posId).TotalAnsPost; if (v != null) { var prevPosts = v.Value; var pi = _db.PostInformation.Find(posId); pi.TotalAnsPost = prevPosts + 1; _db.Entry(pi).State = EntityState.Modified; } } _db.SaveChanges(); ViewData["c"] = 4; ViewBag.operation = 2; ViewBag.checkCrontroller = 2; UpdateAns(id.Value); DisplayQuesAnsComments(id.Value); } else { ViewData["PostNotAllowedId"] = 1; } } TempData["QiComm"] = id; DisplayQuesAnsComments(id.Value); ViewBag.operation = 2; ViewBag.checkCrontroller = 2; IEnumerable <SensitiveWordsViewModel> s = strList; ViewData["s"] = s; } else { TempData["QiComm"] = id; DisplayQuesAnsComments(id.Value); ViewBag.operation = 2; ViewBag.checkCrontroller = 2; ViewData["ReqMsg"] = 3; ViewData["Mess"] = "* Answers should not contain less than 10 chracters"; } } else { TempData["AnsId"] = id.Value; DisplayQuesAnsComments(id.Value); ViewBag.operation = 2; ViewBag.checkCrontroller = 2; ViewData["ReqMsg"] = 3; ViewData["Mess"] = "* Empty Field not allowed!.Please Write Your Answer"; } return(View("_PostAnswer")); } else { DisplayQuesAnsComments(id.Value); ViewData["c"] = 5; ViewBag.operation = 2; ViewBag.checkCrontroller = 2; TempData["HomeAnsPostController"] = 2; } TempData["QiComm"] = id; TempData["AnsId"] = id; DisplayQuesAnsComments(id.Value); } ViewBag.operation = 2; ViewBag.checkCrontroller = 2; return(View("_PostAnswer")); }
public AiWordAdapter(IDataBaseMain dataBaseMain, WordDbContext wordDbContext) { _dataBaseMain = dataBaseMain; _wordDbContext = wordDbContext; }
public ActionResult PostAnswerForAnsweredQuestion(int?id, string msg) { int tempId = db.TemQuesIdModels.SingleOrDefault(m => m.Id.Equals(1)).TempQuesId; if (Request.IsAuthenticated) { if (id == null) { if (msg != "") { if (msg.Length >= 10) { string ms = ""; WordDbContext wdb = new WordDbContext(); var sensitiveWods = wdb.Words.Select(m => m.SensitiveWord); List <SensitiveWordsViewModel> strList = new List <SensitiveWordsViewModel>(); ViewBag.fc = 2; string convt = msg.ToLower(); foreach (string str in sensitiveWods) { if (convt.Contains(str)) { SensitiveWordsViewModel sensitive = new SensitiveWordsViewModel(); sensitive.SensitiveWords = str; strList.Add(sensitive); ViewBag.senWordsMsg = 11; ms = str; } } IEnumerable <SensitiveWordsViewModel> s = strList; ViewData["s"] = s; if (ms == "") { Answers ans = new Answers(); int authuserId = _db.ForumUser.Single(m => m.UserName.Equals(User.Identity.Name)).UserId; ans.UserId = authuserId; ans.AnsweredTimeDate = DateTime.Now; ans.QuestionId = tempId; ans.Answer = msg; ans.Rating = 0; _db.Answers.Add(ans); _db.SaveChanges(); ViewData["c"] = 4; ViewBag.operation = 2; ViewBag.checkCrontroller = 2; UpdateAns(tempId); DisplayQuesAnsComments(tempId); } } else { TempData["AnsId"] = tempId; DisplayQuesAnsComments(tempId); ViewBag.operation = 1; ViewBag.checkCrontroller = 1; ViewData["ReqMsg"] = 3; ViewData["Mess"] = "* Answers should not contain less than 10 chracters"; } } else { TempData["AnsId"] = tempId; DisplayQuesAnsComments(tempId); ViewBag.operation = 1; ViewBag.checkCrontroller = 1; ViewData["ReqMsg"] = 3; ViewData["Mess"] = "* Empty Field not allowed!.Please Write Your Answer"; return(View("_PostAnswer")); } } else { if (msg != "") { if (msg.Length >= 10) { string ms = ""; WordDbContext wdb = new WordDbContext(); var sensitiveWods = wdb.Words.Select(m => m.SensitiveWord); List <SensitiveWordsViewModel> strList = new List <SensitiveWordsViewModel>(); string convt = msg.ToLower(); foreach (string str in sensitiveWods) { if (convt.Contains(str)) { SensitiveWordsViewModel sensitive = new SensitiveWordsViewModel(); sensitive.SensitiveWords = str; strList.Add(sensitive); ViewBag.senWordsMsg = 11; ms = str; } } IEnumerable <SensitiveWordsViewModel> s = strList; ViewData["s"] = s; if (ms == "") { Answers ans = new Answers(); int authuserId = _db.ForumUser.Single(m => m.UserName.Equals(User.Identity.Name)).UserId; ans.UserId = authuserId; ans.AnsweredTimeDate = DateTime.Now; ans.QuestionId = id.Value; ans.Answer = msg; ans.Rating = 0; _db.Answers.Add(ans); _db.SaveChanges(); ViewData["c"] = 4; ViewBag.operation = 1; ViewBag.checkCrontroller = 1; UpdateAns(id.Value); DisplayQuesAnsComments(id.Value); } } else { TempData["AnsId"] = id.Value; DisplayQuesAnsComments(id.Value); ViewBag.operation = 1; ViewBag.checkCrontroller = 1; ViewData["ReqMsg"] = 3; ViewData["Mess"] = "* Answers should not contain less than 10 chracters"; } } else { TempData["AnsId"] = id.Value; DisplayQuesAnsComments(id.Value); ViewBag.operation = 1; ViewBag.checkCrontroller = 1; ViewData["ReqMsg"] = 3; ViewData["Mess"] = "* Empty Field not allowed!.Please Write Your Answer"; } UpdateTempQuesId(id.Value); TempData["QiComm"] = id; TempData["AnsId"] = id; DisplayQuesAnsComments(id.Value); ViewBag.operation = 1; ViewBag.checkCrontroller = 1; return(View("_PostAnswer")); } } else { if (id == null) { ViewData["c"] = 5; UpdateTempQuesId(tempId); DisplayQuesAnsComments(tempId); ViewBag.operation = 1; ViewBag.checkCrontroller = 1; } ViewData["c"] = 5; UpdateTempQuesId(id.Value); DisplayQuesAnsComments(id.Value); ViewBag.operation = 1; ViewBag.checkCrontroller = 1; TempData["AreaFQAnsPostController"] = 1; return(View("_PostAnswer")); } return(View("_PostAnswer")); }
// protected IEnumerable<EncodingWord> _encodingWords; public InputLayer() { _wordDbContext = AutoFac.Resolve <WordDbContext>(); // _outputCodeWordsArray = outputCodeWords; }
public EngineParser(List <WordNotPersistent> wordNotPersistents) { _wordDbContext = AutoFac.Resolve <WordDbContext>(); VocalabryFirstBigramm = wordNotPersistents?.Where(f => f.IsFirst); VocalabryEndBigramm = wordNotPersistents?.Where(f => !f.IsFirst); }
public AiParser(ILoaderInfoAotRu loaderInfoAotRu, WordDbContext wordDbContext, IAiSentence iAiSentence) { _loaderInfoAotRu = loaderInfoAotRu; _wordDbContext = wordDbContext; _iAiSentence = iAiSentence; }
public Vocalabry(WordDbContext wordDbContext) { _wordDbContext = wordDbContext; }