/// <summary> /// Deprecated Method for adding a new object to the GreWords EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToGreWords(GreWord greWord) { base.AddObject("GreWords", greWord); }
private void buttonCollect_Click(object sender, EventArgs e) { var entities = new gredbEntities(); long listNameId = -1; if (comboBoxList.Text.Trim().Length > 0) { var list = entities.ListNames.Where(o => o.Name.ToLower().Equals(comboBoxList.Text.Trim().ToLower())).Select(o => o).FirstOrDefault(); if (list == null) { ListName listName = new ListName(); listName.Name = comboBoxList.Text.Trim().ToLower(); entities.AddToListNames(listName); entities.SaveChanges(); listNameId = listName.Id; } else { listNameId = list.Id; } } else { listNameId = Convert.ToInt64(comboBoxList.SelectedValue); } String strWord = textBoxWord.Text.Trim().ToLower(); ListName ln = (from n in entities.ListNames where n.Id == listNameId select n).FirstOrDefault(); try { GreWord word; word = (from w in entities.GreWords where w.Word.ToLower() == strWord select w).FirstOrDefault(); if (word == null) { word = new GreWord() { Word = strWord, }; entities.AddToGreWords(word); entities.SaveChanges(); } ListedWord lw = (from w in entities.ListedWords where w.ListName.Id == ln.Id && w.GreWord.Word == word.Word select w).FirstOrDefault(); if (lw == null) { lw = new ListedWord() { GreWord = word, ListName = ln }; entities.AddToListedWords(lw); entities.SaveChanges(); } } catch (Exception exp) { MessageBox.Show(exp.Message); } ParserHelper parserHelper = new ParserHelper(entities); parserHelper.OnLogMessage += (sender2, person) => this.Invoke((MethodInvoker)(() => textBoxInfo.AppendText(person + "\r\n"))); parserHelper.WordToFetch = strWord; var workerThread = new Thread(parserHelper.FetchAndParseSingleWord) {IsBackground = true}; workerThread.Start(); }
/// <summary> /// Create a new GreWord object. /// </summary> /// <param name="word">Initial value of the Word property.</param> /// <param name="hardness">Initial value of the Hardness property.</param> /// <param name="bookmarked">Initial value of the Bookmarked property.</param> /// <param name="remembered">Initial value of the Remembered property.</param> /// <param name="forgotten">Initial value of the Forgotten property.</param> public static GreWord CreateGreWord(global::System.String word, global::System.Int32 hardness, global::System.Boolean bookmarked, global::System.Int32 remembered, global::System.Int32 forgotten) { GreWord greWord = new GreWord(); greWord.Word = word; greWord.Hardness = hardness; greWord.Bookmarked = bookmarked; greWord.Remembered = remembered; greWord.Forgotten = forgotten; return greWord; }
void UpdateGoogleSynonym(GreWord word, string synonym) { GoogleSynonym gs = (_entities.GoogleSynonyms.Where(w => w.GreWord.Word == word.Word && w.Synonym == synonym)).FirstOrDefault(); if (gs == null) { gs = new GoogleSynonym() { GreWord = word, Synonym = synonym }; _entities.AddToGoogleSynonyms(gs); _entities.SaveChanges(); } }
private void InsertAffineWord(GreWord word, GreWord affine, int affinity) { int count = (from o in _entities.GreWordAffinities where o.GreWord.Word == word.Word && o.RelevantWord.Word == affine.Word select o).Count(); if (count == 0) { GreWordAffinity gwa = new GreWordAffinity() { GreWord = word, RelevantWord = affine, Affinity = affinity }; _entities.AddToGreWordAffinities(gwa); } }
void UpdateGooglePhrase(GreWord word, string en, string bn) { var gs = (_entities.GooglePhrases.Where(w => w.GreWord.Word == word.Word && w.EnglishPhrase == en)).FirstOrDefault(); if (gs == null) { gs = new GooglePhrase() { GreWord = word, EnglishPhrase = en, BengaliPhrase = bn, }; _entities.AddToGooglePhrases(gs); _entities.SaveChanges(); } }
void UpdateGoogleBengaliWord(GreWord word, string definition) { BengaliDefinition gs = (_entities.BengaliDefinitions.Where(w => w.GreWord.Word == word.Word && w.Bengali == definition)).FirstOrDefault(); if (gs == null) { gs = new BengaliDefinition() { GreWord = word, Bengali = definition }; _entities.AddToBengaliDefinitions(gs); _entities.SaveChanges(); } }
private void button1_Click(object sender, EventArgs e) { long listNameId = -1; var entities = new gredbEntities(); var list = entities.ListNames.Where(o => o.Name.ToLower().Equals(comboBoxList.Text.Trim().ToLower())).Select(o => o).FirstOrDefault(); if (list == null) { ListName listName = new ListName { Name = comboBoxList.Text.Trim() }; entities.AddToListNames(listName); entities.SaveChanges(); listNameId = listName.Id; } else { listNameId = list.Id; } String str = Regex.Replace(textBox1.Text, "([0-9\\.]+|<.+?>)", ""); Regex regex = new Regex("([^\\s]+)"); ListName ln = (from n in entities.ListNames where n.Id == listNameId select n).FirstOrDefault(); try { MatchCollection mc = regex.Matches(str); foreach (Match m in mc) { try { GreWord word = (from w in entities.GreWords where w.Word.ToLower() == m.Value.ToLower() select w).FirstOrDefault(); if (word == null) { word = new GreWord() { Word = m.Value.ToLower(), }; entities.AddToGreWords(word); entities.SaveChanges(); } ListedWord lw = (from w in entities.ListedWords where w.ListName.Id == ln.Id && w.GreWord.Word == word.Word select w).FirstOrDefault(); if (lw == null) { lw = new ListedWord() { GreWord = word, ListName = ln }; entities.AddToListedWords(lw); entities.SaveChanges(); } } catch (Exception exp) { MessageBox.Show(exp.Message); } } entities.Connection.Close(); } catch (Exception exp) { } }
String getMnemonics(GreWord gw) { var entities = new gredbEntities(); var parser = new ParserHelper(entities); String mnemonics = ""; List<FeaturedMnemonic> mSelected = (from w in entities.FeaturedMnemonics where w.GreWord.Word == gw.Word select w).ToList(); foreach (FeaturedMnemonic ms in mSelected) mnemonics += "##:" + ms.Mnemonic + ", "; List<BasicMnemonic> mAll = (from w in entities.BasicMnemonics where w.GreWord.Word == gw.Word select w).ToList(); foreach (BasicMnemonic ms in mAll) mnemonics += "#" + ms.Helpful + "," + ms.NotHelpful + ":" + ms.Mnemonic + ", "; mnemonics = Clean(mnemonics, @"\(Tag.+?\)"); mnemonics = Clean(mnemonics); return mnemonics; }
String getGoogleSynonym(GreWord gw) { var entities = new gredbEntities(); var parser = new ParserHelper(entities); String synnonym = ""; List<GoogleSynonym> gSyn = (from w in entities.GoogleSynonyms where w.GreWord.Word == gw.Word select w).ToList(); foreach (GoogleSynonym gs in gSyn) synnonym += gs.Synonym + ", "; return synnonym; }