private void textBoxWord_TextChanged(object sender, EventArgs e) { String word = textBoxWord.Text.Trim(); if (word == "") { buttonUpdate.Enabled = false; buttonInsert.Enabled = false; buttonDelete.Enabled = false; return; } T_DictStruct selWord = m_DictManage.GetWord(word); if (selWord != null) { buttonUpdate.Enabled = true; buttonInsert.Enabled = false; buttonDelete.Enabled = true; numericUpDownFrequency.Value = (decimal)selWord.Frequency; posCtrl.Pos = selWord.Pos; } else { buttonUpdate.Enabled = false; buttonInsert.Enabled = true; buttonDelete.Enabled = false; numericUpDownFrequency.Value = 0; posCtrl.Pos = 0; } }
/// <summary> /// 获得一个词的权重 /// </summary> public static ulong GetFrequency(string keyword) { T_DictStruct tds = JWordDictManager.GetWord(keyword); if (tds != null) { return(ulong.Parse(tds.Frequency.ToString())); } return(0); }
public static bool IsExist(string keyword) { T_DictStruct tds = JWordDictManager.GetWord(keyword); if (tds != null) { return(true); } return(false); }
public void DeleteWord(String word) { word = word.Trim(); T_DictStruct w = GetWord(word); if (w == null) { return; } m_DictTbl.Remove(w.Word); m_Dict.Dicts.Remove(w); }
public void UpdateWord(String word, double frequency, int pos) { word = word.Trim(); T_DictStruct w = GetWord(word); if (w == null) { return; } w.Frequency = frequency; w.Pos = pos; }
private void BatchInsert(String fileName, String encoder) { String content = CFile.ReadFileToString(fileName, encoder); String[] words = CRegex.Split(content, @"\r\n"); bool allUse = false; T_DictStruct lstWord = null; foreach (String word in words) { if (word == null) { continue; } if (word.Trim() == "") { continue; } FormBatchInsert frmBatchInsert = new FormBatchInsert(); if (!allUse || lstWord == null) { frmBatchInsert.Word.Word = word.Trim(); if (frmBatchInsert.ShowDialog() == DialogResult.OK) { lstWord = frmBatchInsert.Word; allUse = frmBatchInsert.AllUse; m_DictManage.InsertWord(lstWord.Word, lstWord.Frequency, lstWord.Pos); } } else { lstWord.Word = word.Trim(); m_DictManage.InsertWord(lstWord.Word, lstWord.Frequency, lstWord.Pos); } } }
public void InsertWord(String word, double frequency, int pos) { if (word == null) { return; } word = word.Trim(); if (GetWord(word) != null) { return; } T_DictStruct w = new T_DictStruct(); w.Word = word; w.Frequency = frequency; w.Pos = pos; m_Dict.Dicts.Add(w); m_DictTbl[word] = w; }