private void List_words_ItemTapped(object sender, ItemTappedEventArgs e) { //showing an alert with the definition var clickedItem = e.Item as WordDefinition; var wordDef = app.getDefinitionsByName(clickedItem.Name); //in case of more than one definition, a text format will be made if (wordDef.Count > 1) { string defText = textFormat(wordDef); DisplayAlert(wordDef.First().Name, defText, "OK"); } else { WordDefinition def = wordDef.First(); DisplayAlert(def.Name, def.Definition, "OK"); } //unmarking item ((ListView)sender).SelectedItem = null; //add the clicked item to history list if it's not duplicated if (!UserProperties.HistoryList.Contains(clickedItem.Name)) { UserProperties.HistoryList.Push(clickedItem.Name); } //Send a message to HistoryPage to refresh their screen with this new word MessagingCenter.Send <SearchPage>(this, "newWordHistory"); }
private void SeedDefinitions(ApplicationDbContext context) { //if (context.Definitions.Any()) //{ // return; //} //if (System.Diagnostics.Debugger.IsAttached == false) //{ // System.Diagnostics.Debugger.Launch(); //} for (int j = 0; j < words.Count; j++) { WordDefinition def = new WordDefinition(); def.Word = words.ElementAt(j); def.addDefinitions(definitionLists.ElementAt(j)); context.Definitions.AddOrUpdate(def); } context.SaveChanges(); }
/// <summary> /// Get the word definition from a web service, internet connection is /// needed /// </summary> public void GetMeaning() { DictServiceSoapClient dictionary = new DictServiceSoapClient("DictServiceSoap"); WordDefinition wordDefinition = dictionary.Define(this.Value); this.Meaning = wordDefinition.Definitions; }
public ActionResult EditPartial(DefinitionEditViewModel definition) { WordDefinition model = definition.ToModel(); _wordDefinitionService.Edit(ref model); return(PartialView("_ListItem", new DefinitionViewModel(model))); }
public object AddCustomWord(string customizationId, string wordname, WordDefinition body) { if (string.IsNullOrEmpty(customizationId)) { throw new ArgumentNullException($"{nameof(customizationId)}"); } if (string.IsNullOrEmpty(wordname)) { throw new ArgumentNullException($"{nameof(wordname)}"); } if (body == null) { throw new ArgumentNullException($"{nameof(body)}"); } object result = null; try { result = this.Client.WithAuthentication(this.UserName, this.Password) .PutAsync($"{this.Endpoint}{PATH_CUSTOM_MODEL}/{customizationId}/words/{wordname}") .WithBody <WordDefinition>(body) .AsString() .Result; } catch (AggregateException ae) { throw ae.InnerException as ServiceResponseException; } return(result); }
public object AddCustomWord(string customizationId, string wordname, WordDefinition body) { if (string.IsNullOrEmpty(customizationId)) { throw new ArgumentNullException($"{nameof(customizationId)}"); } if (string.IsNullOrEmpty(wordname)) { throw new ArgumentNullException($"{nameof(wordname)}"); } if (body == null) { throw new ArgumentNullException($"{nameof(body)}"); } try { var result = RepositoryClient.WithAuthentication(ApiKeys.SpeechToTextUsername, ApiKeys.SpeechToTextPassword) .PutAsync($"{ApiKeys.SpeechToTextEndpoint}{customizationsUrl}/{customizationId}/words/{wordname}") .WithBody <WordDefinition>(body) .AsString() .Result; return(result); } catch (AggregateException ae) { throw ae.InnerException as ServiceResponseException; } }
public static List <Item> PlayRussianAudios(this List <Item> items, WordDefinition word) { for (int i = 0; i < word.Word.AudioSources.Count; i++) { items.PlayRussianAudio(word, i); } return(items); }
public DefinitionViewModel(WordDefinition wordDefinition) { this.Id = wordDefinition.Id; this.Definition = wordDefinition.Definition; this.Example = wordDefinition.Example; this.Public = wordDefinition.Public; this.WordType = wordDefinition.Type.Name; }
public void getNonExisitingWordEntry([Values("sdfsd")] string word) { WordAPIClient myManager = new WordAPIClient(); WordDefinition myWord = myManager.getWordEntry(word); Assert.Null(myWord); }
public static List <Item> ReadEnglishTranslation(this List <Item> items, WordDefinition word) { items.Add(new Item { Read = word.Translations[0] }); return(items); }
public GroupDefinition(string description, WordDefinition[] words) { _description = description; _words = words; foreach (WordDefinition wordDefinition in words) { wordDefinition.Group = this; } }
public DictionaryEntryPage(string word, bool fromOutside) { InitializeComponent(); this.word = word; this.fromOutside = fromOutside; wordDefinition = App.WordDatatbase.GetWordAsync(word).GetAwaiter().GetResult().FirstOrDefault(); MakeLabels(); BindingContext = wordDefinition; }
/// <summary> /// /// </summary> /// <param name="model"></param> /// <returns>returns original record from db</returns> WordDefinition CheckUserOwning(int wordDefinition_Id) { WordDefinition origin = this.Repository.GetByKey <WordDefinition>(wordDefinition_Id, d => d.UserProfile); if (origin.UserProfile.ApplicationUserId != _workContext.UserAppId) { throw new Exception("Оперделение не пренадлежит пользователю."); } return(origin); }
public ListOfDefinitions(WordDefinition definition, Range callPlace, string sourceFile) { _callPlace = callPlace; _definition = definition; _sourceFile = sourceFile; InitializeComponent(); FormClosing += ListOfDefinitions_FormClosing; }
public static List <Item> AddWordIntro(this List <Item> items, WordDefinition word, WordForm wordForm) { items.Add(new Item { Text = $"<h1>{wordForm.StressedWord}</h1><h2>{string.Join(", ", word.Translations)}</h2>", Word = word.Word.Word, Id = wordForm.Key }); return(items); }
public void Edit(ref WordDefinition model) { WordDefinition origin = CheckUserOwning(model.Id); origin.Definition = model.Definition; origin.Example = model.Example; origin.Public = model.Public; origin.Type_Id = model.Type_Id; Repository.Update(origin, true); }
// // GET: /Home/ public ActionResult Index() { char letter = GetRandomLetter(); int pageCount = Kriu.GetPageCount(letter); List <string> keyWords = Kriu.GetKeyWords(letter, Random.Next(1, pageCount)).ToList(); int randomKeyWordIndex = Random.Next(0, keyWords.Count - 1); WordDefinition result = Kriu.GetDefinition(keyWords[randomKeyWordIndex]); return(View(result)); }
public ActionResult EditPartial(int id) { WordDefinition wordDefinition = _wordDefinitionService.GetWordDefinition(id); var vm = new DefinitionEditViewModel(/*wordDefinition */) { Definition = "asd" }; //todo vm.WordTypes = GetWordTypes(wordDefinition.Id); return(PartialView("_Edit")); }
private async void GetDefinition(string inputWord) { FindDefinitionQuery query = new FindDefinitionQuery(inputWord); WordDefinition wordDefinition = await dispatcher.Execute(query); Definition[] definitions = wordDefinition.Definitions; btnGetDefinition.IsEnabled = true; timer.Stop(); timer.Enabled = false; pbLoading.Visibility = Visibility.Collapsed; txtDefinition.Text = GetFormatedDefinition(definitions); }
public MichtavaResult Update(WordDefinition WordDefinition) { if (this.GetByWord(WordDefinition.Word) == null) { return(new MichtavaFailure("המילה לא נמצאה במערכת")); } this.WordDefinitionRepository.Update(WordDefinition); this.WordDefinitionRepository.SaveChanges(); return(new MichtavaSuccess("מילה עודכנה בהצלחה")); }
// To call NextWord: http://localhost/KeenAPI/api/Word/NextWord?WordCount=12 // http://localhost:14743/api/Word/NextWord?WordCount=12 //public WordDefinition NextWord(int? id = 1) public WordDefinition NextWord(string WordCount) { int iWordCount = Convert.ToInt32(WordCount); WordDefinition wd = new WordDefinition(); string strLive = WebConfigurationManager.AppSettings["live"]; string strSchema = WebConfigurationManager.AppSettings["schema"]; // Get word from database and fill WordDefinition using (SqlConnection conn = new SqlConnection(DatabaseAccess.DBConnection())) { string strNextWord = "SELECT words.*, themes.WordThemeName FROM ["; strNextWord += strSchema + "].[TestWordsmithWords] as words "; strNextWord += "JOIN [" + strSchema + "].[TestWordsmithThemes] AS themes "; strNextWord += "ON words.WordsmithThemeID = themes.ID "; strNextWord += " WHERE words.ID = @id"; using (SqlCommand cmd = new SqlCommand(strSchema, conn)) { try { conn.Open(); cmd.CommandText = strNextWord; cmd.Parameters.AddWithValue("@id", iWordCount); SqlDataReader read = cmd.ExecuteReader(); while (read.Read()) { wd.Id = Convert.ToInt32(read["id"].ToString()); wd.WordsmithThemeId = Convert.ToInt32(read["WordsmithThemeId"].ToString()); wd.DailyWord = read["DailyWord"].ToString(); wd.WordThemeName = read["WordThemeName"].ToString(); wd.Pronunciation = read["Pronunciation"].ToString(); wd.Meaning = read["Meaning"].ToString(); wd.Etymology = read["Etymology"].ToString(); wd.Usage = read["Usage"].ToString(); wd.ThoughtADay = read["ThoughtADay"].ToString(); wd.Notes = read["Notes"].ToString(); wd.InputDate = Convert.ToDateTime(read["InputDate"].ToString()); wd.UpdateDate = Convert.ToDateTime(read["UpdateDate"].ToString()); } } catch (Exception ex) { } } } return(wd); }
public MichtavaResult Add(WordDefinition WordDefinition) { if (WordDefinitionRepository.GetByWord(WordDefinition.Word) != null) { return(new MichtavaFailure("כבר קיימת מילה כזאת במערכת")); } this.WordDefinitionRepository.Add(WordDefinition); this.WordDefinitionRepository.SaveChanges(); return(new MichtavaSuccess()); }
public void testAddExistingIdWordDefinition() { Assert.Null(serv.GetByWord(word)); // Arrange int count = serv.All().Count(); WordDefinition existing = serv.All().FirstOrDefault(); // Act MichtavaResult res = serv.Add(existing); // Assert Assert.True(res is MichtavaFailure); }
public void testGetWordDefinitionByIdFalse() { Assert.Null(serv.GetByWord(word)); // Arrange int count = serv.All().Count(); // Act WordDefinition actual = serv.GetByWord(Guid.NewGuid().ToString()); // Assert Assert.Null(actual); }
public void getExisitingWordEntry([Values("unhinged", "power", "zephyr", "uncanny")] string word) { WordAPIClient myManager = new WordAPIClient(); WordDefinition myWord = myManager.getWordEntry(word); Assert.NotNull(myWord); //format the result string formatedResult = buildEntry(myWord); Assert.Pass(formatedResult); }
public void testGetWordDefinitionByDetailsFalse() { Assert.Null(serv.GetByWord(word)); // Arrange int count = serv.All().Count(); // Act WordDefinition actual = serv.GetByWord("14"); // Assert Assert.Null(actual); }
public object AddCustomWord(string customizationId, string wordname, WordDefinition body) { try { var result = SpeechToTextRepository.AddCustomWord(customizationId, wordname, body); return(result); } catch (Exception ex) { Logger.Error("SpeechToTextService.AddCustomWord failed", this, ex); } return(null); }
public MichtavaResult HardDelete(WordDefinition WordDefinition) { WordDefinition existing = this.WordDefinitionRepository.AllWithDeleted().Where(y => y.Word == WordDefinition.Word).FirstOrDefault(); if (existing == null) { return(new MichtavaFailure("המילה לא נמצאה במערכת")); } this.WordDefinitionRepository.HardDelete(WordDefinition); this.WordDefinitionRepository.SaveChanges(); return(new MichtavaSuccess("המילה נמחקה בהצלחה")); }
public void testAddExistingWordDefinitionDetails() { Assert.Null(serv.GetByWord(word)); // Arrange int count = serv.All().Count(); WordDefinition existing = serv.All().FirstOrDefault(); WordDefinition c = new WordDefinition(existing.Word, "some definition"); // Act MichtavaResult res = serv.Add(c); // Assert Assert.True(res is MichtavaFailure); }
public void Add(WordDefinition model) { UserProfile userProfile = this.Repository.GetUserProfile(_workContext.UserAppId); WordDefinition newWordDefinition = new WordDefinition() { Definition = model.Definition, Public = model.Public, Example = model.Example, UserProfile_Id = userProfile.Id, Type_Id = model.Type_Id, Word_Id = model.Word_Id, }; Repository.Add(newWordDefinition, true); }
public static List <Item> PlayRussianAudio(this List <Item> items, WordDefinition word, int index = 0) { var formDescription = word.Word.FormDescription ?? ""; items.Add(new Item { Text = $@" <h5><span class='text-muted small'>{word.WordType} {formDescription} - {string.Join(", ", word.Tags)}</span></h5> <h1>{word.Word.StressedWord}</h1> <footer class='text-center'>{string.Join(", ", word.Translations)}</footer> ", Audio = word.Word.AudioSources[index].Uri.AbsoluteUri, Word = word.Word.Word, Id = word.Word.AudioSources[index].Key }); return(items); }
/// <summary> /// Returns null in case of notfound anything or what ever /// </summary> /// <param name="containsWords"></param> /// <param name="fullMatchWords"></param> /// <param name="containsMinimalLength"></param> /// <returns></returns> SortedDictionary<string, WordDefinition> GetWordsDefinitionFromText(string containsWords, string fullMatchWords, int containsMinimalLength) { SortedDictionary<string, WordDefinition> wordsCounter = new SortedDictionary<string, WordDefinition>(); try { if (String.IsNullOrEmpty(containsWords) && String.IsNullOrEmpty(fullMatchWords)) return wordsCounter; if (containsMinimalLength < 3) containsMinimalLength = 3; StringBuilder sb = new StringBuilder(); string word = ""; WordDefinition wordDefinition = null; //Non splittable words foreach (var nswrd in fullMatchWords.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Where(r => r.Length >= containsMinimalLength)) { word = nswrd.ToLower(); wordDefinition = new WordDefinition() { CountInDocu = 1 }; wordsCounter[word] = wordDefinition; } if (String.IsNullOrEmpty(containsWords)) return wordsCounter; Action processWord = () => { //We take all words, so we can later find even by email address [email protected] ... we will need jj and gmx.net if (sb.Length > 0 && sb.Length >= containsMinimalLength) { word = sb.ToString().ToLower(); List<string> wrds = new List<string>(); wrds.Add(word); int i = 1; while (word.Length - i >= containsMinimalLength) { wrds.Add(word.Substring(i)); i++; } // System.Diagnostics.Debug.WriteLine("--------------"); foreach (var w in wrds) { //System.Diagnostics.Debug.WriteLine(w); if (wordsCounter.TryGetValue(w, out wordDefinition)) { wordDefinition.CountInDocu++; } else { wordDefinition = new WordDefinition() { CountInDocu = 1 }; wordsCounter[w] = wordDefinition; } } } if (sb.Length > 0) sb.Remove(0, sb.Length); //sb.Clear(); }; int wordLen = 0; int maximalWordLengthBeforeSplit = 50; foreach (var c in containsWords) { //No words reviews (must be checked in outer systems) if (c != ' ') { sb.Append(c); wordLen++; if (wordLen >= maximalWordLengthBeforeSplit) { //Processing ready word processWord(); wordLen = 0; } } else { //Processing ready word processWord(); wordLen = 0; } } //Processing last word processWord(); //if (wordsCounter.Count() > 0) // return wordsCounter; } catch (System.Exception ex) { } return wordsCounter; }
/// <summary> /// Returns null in case of notfound anything or what ever /// </summary> /// <param name="text"></param> /// <returns></returns> Dictionary<string, WordDefinition> GetWordsDefinitionFromText(string text) { try { if (String.IsNullOrEmpty(text)) return null; StringBuilder sb = new StringBuilder(); string word = ""; WordDefinition wordDefinition = null; Dictionary<string, WordDefinition> wordsCounter = new Dictionary<string, WordDefinition>(); Action processWord = () => { //We take all words, so we can later find even by email address [email protected] ... we will need jj and gmx.net if (sb.Length > 0) { word = sb.ToString().ToLower(); List<string> wrds = new List<string>(); wrds.Add(word); int i=1; if (this.SearchWordMinimalLength > 0) //If equals to 0, we store only words for full text search { while (word.Length - i >= this.SearchWordMinimalLength) { wrds.Add(word.Substring(i)); i++; } } foreach (var w in wrds) { if (wordsCounter.TryGetValue(w, out wordDefinition)) { wordDefinition.CountInDocu++; } else { wordDefinition = new WordDefinition() { CountInDocu = 1 }; wordsCounter[w] = wordDefinition; } } } if(sb.Length>0) sb.Remove(0, sb.Length); //sb.Clear(); }; int wordLen = 0; int maximalWordLengthBeforeSplit = 50; foreach (var c in text) { if (Char.IsLetterOrDigit(c) || Char.IsSymbol(c)) { sb.Append(c); wordLen++; if (wordLen >= maximalWordLengthBeforeSplit) { //Processing ready word processWord(); wordLen = 0; } } else { //Processing ready word processWord(); wordLen = 0; } } //Processing last word processWord(); if (wordsCounter.Count() > 0) return wordsCounter; } catch (System.Exception ex) { } return null; }
/** * */ private static WordDefinition parseDefinition(String word, HtmlAgilityPack.HtmlDocument htmldoc) { List<List<string>> definitions = new List<List<string>>(); foreach (HtmlAgilityPack.HtmlNode node in htmldoc.DocumentNode.Descendants("ul").Where(x => x.Attributes.Contains("class") && x.Attributes["class"].Value.Contains("sense-entry"))) { List<string> l = new List<string>(); foreach (HtmlAgilityPack.HtmlNode n in node.Descendants("span").Where(x => x.Attributes.Contains("class") && x.Attributes["class"].Value.Contains("definition"))) { l.Add(Regex.Replace(n.InnerHtml, "<!.*?>", string.Empty)); } definitions.Add(l); } WordDefinition wd = new WordDefinition(word, definitions); return wd; }