public Word(int id, string word, WordCategory category, int level) { this.id = id; this.stringword = word; Category = category; Level = level; }
public void Test_Decrement_Category_Method_When_Exist_In_Dict_But_Count_Is_1(WordCategory testCategory) { var analysisResult = LearnerState.Empty; var testResult = analysisResult.IncrementCategory(testCategory).DecrementCategory(testCategory); testResult.CategoryPerQuantity.ContainsKey(testCategory).Should().BeFalse(); }
public void Test_Increment_Category_Method_When_Exist_In_Dict(WordCategory testCategory) { var analysisResult = LearnerState.Empty; var testResult = analysisResult.IncrementCategory(testCategory).IncrementCategory(testCategory); testResult.CategoryPerQuantity.GetValueOrDefault(testCategory).Should().Be(2); }
public void ctor_default_values() { var wordCategory = new WordCategory(); Assert.That(wordCategory.Word == ""); Assert.That(wordCategory.Category == -1); Assert.That(wordCategory.Probability == 0); }
public void Test_Decrement_Feature_Method_When_Category_No_Exist_In_Dict(WordCategory testCategory, string feature) { var analysisResult = LearnerState.Empty; var testResult = analysisResult.DecrementFeature(testCategory, feature); testResult.WordPerQuantity.ContainsKey(feature).Should().BeFalse(); testResult.CategoryPerWords.ContainsKey(testCategory).Should().BeFalse(); }
public void Test_Decrement_Category_Method_When_Exist_In_Dict_And_Count_Is_2(WordCategory testCategory) { var analysisResult = LearnerState.Empty; var testResult = analysisResult.IncrementCategory(testCategory).IncrementCategory(testCategory).DecrementCategory(testCategory); testResult.CategoryPerQuantity.ContainsKey(testCategory).Should().BeTrue(); testResult.CategoryPerQuantity.GetValueOrDefault(testCategory).Should().Be(1); }
public void Category_ValueSetProperly() { var category = TestCommon.RandomInt(); var wordCategory = new WordCategory(); wordCategory.Category = category; Assert.That(wordCategory.Word == ""); Assert.That(wordCategory.Category == category); Assert.That(wordCategory.Probability == 0); }
public void Word_ValueSetProperly() { var word = TestCommon.RandomString(10); var wordCategory = new WordCategory(); wordCategory.Word = word; Assert.That(wordCategory.Word == word); Assert.That(wordCategory.Category == -1); Assert.That(wordCategory.Probability == 0); }
public void Rule_ValueSetProperly() { var probability = TestCommon.RandomDouble(); var wordCategory = new WordCategory(); wordCategory.Probability = probability; Assert.That(wordCategory.Word == ""); Assert.That(wordCategory.Category == -1); Assert.That(wordCategory.Probability == probability); }
public IActionResult Edit(WordCategory wordCategory) { if (ModelState.IsValid) { db.WordCategories.Update(wordCategory); db.SaveChanges(); return(RedirectToAction(nameof(Index))); } return(View(wordCategory)); }
public async Task <Unit> Handle(CreateWordCategoryCommand request, CancellationToken cancellationToken) { var entity = new WordCategory(request.LanguageId, request.Name); _context.WordCategories.Add(entity); await _context.SaveChangesAsync(cancellationToken); return(Unit.Value); }
public ActionResult <string> Put([FromBody] WordCategory wordCategory) { if (ModelState.IsValid) { db.WordCategories.Update(wordCategory); db.SaveChanges(); return("OK"); } return("BAD"); }
public TweetBuilder(Tweet tweet) { Id = tweet.Id; TweetIdentifier = tweet.TweetIdentifier; Text = tweet.Text; Language = tweet.Language; Key = tweet.Key; Date = tweet.Date; Latitude = tweet.Latitude; Longitude = tweet.Longitude; Sentiment = tweet.Sentiment; }
public void Probability_ValueSetProperly_inConstructor() { var probability = TestCommon.RandomDouble(); var wordCategory = new WordCategory { Probability = probability }; Assert.That(wordCategory.Word == ""); Assert.That(wordCategory.Category == -1); Assert.That(wordCategory.Probability == probability); }
public ActionResult Delete(string Id) { WordCategory wordToDelete = wordCategoriesContext.Find(Id); if (wordToDelete == null) { return(HttpNotFound()); } else { return(View(wordToDelete)); } }
public ActionResult Edit(string Id) { WordCategory wordCategory = wordCategoriesContext.Find(Id); if (wordCategory == null) { return(HttpNotFound()); } else { return(View(wordCategory)); } }
private void SeedCategoriesWithWords(ApplicationDbContext context) { if (context.WordCategories.Any()) { return; } var animalsCategory = new WordCategory { Name = "Животни" }; animalsCategory.Words.Add(new Word { Value = "Сурикат", Clue = "Малко. Стои изправено и живее в дупки в пустинята." }); animalsCategory.Words.Add(new Word { Value = "Мечка", Clue = "Дебело и тромаво. Спи зимен сън и обича мед." }); animalsCategory.Words.Add(new Word { Value = "Миеща мечка", Clue = "Другото име на Енот." }); context.WordCategories.Add(animalsCategory); var carsCategory = new WordCategory { Name = "Атомобили" }; carsCategory.Words.Add(new Word { Value = "Тойота", Clue = "Един от моделите на марката е най - продаваният в света." }); carsCategory.Words.Add(new Word { Value = "Фолксваген", Clue = "Народният автомобил на Германия." }); carsCategory.Words.Add(new Word { Value = "Алфа Ромео", Clue = "Емблематичен италиански автомобил." }); context.WordCategories.Add(carsCategory); var moviesCategory = new WordCategory { Name = "Филми" }; moviesCategory.Words.Add(new Word { Value = "Мъже в черно", Clue = "Известен филм с Уил Смит" }); moviesCategory.Words.Add(new Word { Value = "Оркестър без име", Clue = "Известен български филм с Георги Мамалев" }); context.WordCategories.Add(moviesCategory); context.SaveChanges(); }
public ActionResult Create(WordCategory wordCategory) { if (!ModelState.IsValid) { return(View(wordCategory)); } else { wordCategoriesContext.Insert(wordCategory); wordCategoriesContext.Commit(); return(RedirectToAction("Index")); } }
public IActionResult Create(WordCategory wordCategory) { if (ModelState.IsValid) { var find_verb = db.WordCategories.FirstOrDefault(w => w.Name == wordCategory.Name); if (find_verb == null) { db.WordCategories.Add(wordCategory); db.SaveChanges(); } return(RedirectToAction(nameof(Index))); } return(View(wordCategory)); }
public ActionResult <string> Post([FromBody] WordCategory wordCategory) { if (ModelState.IsValid) { var find_verb = db.WordCategories.FirstOrDefault(w => w.Name == wordCategory.Name); if (find_verb == null) { db.WordCategories.Add(wordCategory); db.SaveChanges(); } return("OK"); } return("BAD"); }
public LearnerState IncrementCategory(WordCategory category) { var totalCategory = CategoryPerQuantity; int count; if (totalCategory.TryGetValue(category, out count)) { totalCategory = totalCategory.SetItem(category, count + 1); } else { totalCategory = totalCategory.Add(category, 1); } return(new LearnerState(totalCategory, WordPerQuantity, CategoryPerWords)); }
public void Test_Learn_Method_When_Analysis_Result_Is_Empty(WordCategory category, string feature) { var analysisResult = LearnerState.Empty; var classification = new Sentence(feature, category); var teacher = new TweetLearner(); var testResult = teacher.Learn(analysisResult, classification); int count; if (testResult.CategoryPerQuantity.TryGetValue(category, out count)) { count.Should().Be(feature.Tokenize().Count()); } testResult.WordPerQuantity.Count.Should().Be(classification.Text.Tokenize().Count()); }
public ActionResult ConfirmDelete(string Id) { WordCategory wordCategoryToDelete = wordCategoriesContext.Find(Id); if (wordCategoryToDelete == null) { return(HttpNotFound()); } else { wordCategoriesContext.Delete(Id); wordCategoriesContext.Commit(); return(RedirectToAction("Index")); } }
public LearnerState DecrementFeature(WordCategory category, string feature) { var wordPerQuantity = WordPerQuantity; var categoryPerWords = CategoryPerWords; ImmutableDictionary <string, int> features; if (categoryPerWords.TryGetValue(category, out features)) { int count; if (features.TryGetValue(feature, out count)) { categoryPerWords = categoryPerWords.SetItem(category, count == 1 ? features.Remove(feature) : features.SetItem(feature, count - 1)); } else { return(this); } } else { return(this); } if (categoryPerWords.TryGetValue(category, out features)) { if (features.IsEmpty) { categoryPerWords = categoryPerWords.Remove(category); } } int totalCount; if (wordPerQuantity.TryGetValue(feature, out totalCount)) { wordPerQuantity = totalCount == 1 ? wordPerQuantity.Remove(feature) : wordPerQuantity.SetItem(feature, totalCount - 1); } else { return(this); } return(new LearnerState(CategoryPerQuantity, wordPerQuantity, categoryPerWords)); }
public void Test_Increment_Feature_Method_When_Category_No_Exist_In_Dict(WordCategory testCategory, string feature) { var analysisResult = LearnerState.Empty; var testResult = analysisResult.IncrementFeature(testCategory, feature); testResult.WordPerQuantity.GetValueOrDefault(feature).Should().Be(1); ImmutableDictionary <string, int> features; if (testResult.CategoryPerWords.TryGetValue(testCategory, out features)) { int featuresQuantity; if (features.TryGetValue(feature, out featuresQuantity)) { featuresQuantity.Should().Be(1); } } }
public LearnerState IncrementFeature(WordCategory category, string feature) { var wordPerQuantity = WordPerQuantity; var categoryPerWords = CategoryPerWords; ImmutableDictionary <string, int> features; if (categoryPerWords.TryGetValue(category, out features)) { int count; if (features.TryGetValue(feature, out count)) { features = features.SetItem(feature, count + 1); } else { features = features.Add(feature, 1); } categoryPerWords = categoryPerWords.SetItem(category, features); } else { categoryPerWords = categoryPerWords.Add(category, new Dictionary <string, int>() { { feature, 1 } }.ToImmutableDictionary()); } int totalCount; if (wordPerQuantity.TryGetValue(feature, out totalCount)) { wordPerQuantity = wordPerQuantity.SetItem(feature, totalCount + 1); } else { wordPerQuantity = wordPerQuantity.Add(feature, 1); } return(new LearnerState(CategoryPerQuantity, wordPerQuantity, categoryPerWords)); }
public ActionResult Edit(WordCategory wordCategory, string Id, HttpPostedFileBase file) { WordCategory wordCategoryToEdit = wordCategoriesContext.Find(Id); if (wordCategoryToEdit == null) { return(HttpNotFound()); } else { if (!ModelState.IsValid) { return(View(wordCategory)); } wordCategoryToEdit.Category = wordCategory.Category; wordCategoriesContext.Commit(); return(RedirectToAction("Index")); } }
public LearnerState DecrementCategory(WordCategory category) { var totalCategory = CategoryPerQuantity; int count; if (totalCategory.TryGetValue(category, out count)) { if (count == 1) { totalCategory = totalCategory.Remove(category); } else { totalCategory = totalCategory.SetItem(category, count - 1); } } else { return(this); } return(new LearnerState(totalCategory, WordPerQuantity, CategoryPerWords)); }
public IEnumerable <int> GetWordsWithImages(int cat, ServerData type) { switch (type) { case ServerData.Group: WordsGroup group = _context.Groups.Where(g => g.Id == cat).FirstOrDefault(); if (group == null) { return(null); } return(group.Words.Where(w => w.ImgPath != null).Select(w => w.Id).ToList()); case ServerData.WordCategory: WordCategory category = _context.WordCategories.Where(g => g.Id == cat).FirstOrDefault(); if (category == null) { return(null); } return(category.Words.Where(w => w.ImgPath != null).Select(w => w.Id).ToList()); default: return(null); } }
public Sentence(string text, WordCategory category) { Text = text; Category = category; }