⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 formunknownwords.cs

📁 KTDictSeg 简介: KTDictSeg 是由KaiToo搜索开发的一款基于字典的简单中英文分词算法 * 主要功能: 中英文分词
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using KTDictSeg;

namespace DictManage
{
    public partial class FormUnknownWords : Form
    {
        private String m_NameTableName;
        private DictManage.DictMgr m_DictManage = new DictMgr();
        private DictManage.DictMgr m_DictMgr = new DictMgr();
        private T_DictFile m_DictFile;

        public String NameTableName
        {
            get
            {
                return m_NameTableName;
            }
        }

        public void ShowDialog(String fileName, DictManage.DictMgr dictMgr)
        {
            m_NameTableName = fileName;

            m_DictMgr = dictMgr;

            try
            {
                m_DictFile = Dict.LoadFromBinFileEx(fileName);
            }
            catch (Exception e1)
            {
                MessageBox.Show(String.Format("Can not open dictionary, errmsg:{0}", e1.Message));
                return;
            }

            m_DictManage.Dict = m_DictFile;
            this.ShowDialog();

        }

        public FormUnknownWords()
        {
            InitializeComponent();
        }

        private void DisplayThreshold()
        {
            listBoxWords.Items.Clear();

            foreach (T_DictStruct word in m_DictManage.Dict.Dicts)
            {
                if (word.Frequency >= (double)numericUpDown.Value)
                {
                    bool display = false;

                    if (checkBoxDisable.Checked)
                    {
                        if (word.Pos == 0)
                        {
                            display = true;
                        }
                    }

                    if (checkBoxName.Checked)
                    {
                        if ((word.Pos & (int)T_POS.POS_A_NR) != 0)
                        {
                            display = true;
                        }
                    }

                    if (checkBoxOther.Checked)
                    {
                        if ((word.Pos & (int)T_POS.POS_A_NZ) != 0)
                        {
                            display = true;
                        }
                    }


                    if (display)
                    {
                        listBoxWords.Items.Add(word);
                    }
                }
            }
        }

        private void FormUnknownWords_Load(object sender, EventArgs e)
        {
            DisplayThreshold();
        }

        private void numericUpDown_ValueChanged(object sender, EventArgs e)
        {
            DisplayThreshold();
        }

        private void checkBoxDisable_CheckedChanged(object sender, EventArgs e)
        {
            DisplayThreshold();
        }

        private void checkBoxOther_CheckedChanged(object sender, EventArgs e)
        {
            DisplayThreshold();
        }

        private void checkBoxName_CheckedChanged(object sender, EventArgs e)
        {
            DisplayThreshold();
        }

        private void buttonDisable_Click(object sender, EventArgs e)
        {
            foreach (T_DictStruct word in listBoxWords.SelectedItems)
            {
                word.Pos = 0;
            }

            Dict.SaveToBinFileEx(NameTableName, m_DictManage.Dict);
            DisplayThreshold();
        }

        private void buttonEnable_Click(object sender, EventArgs e)
        {
            foreach (T_DictStruct word in listBoxWords.SelectedItems)
            {
                word.Pos = (int)T_POS.POS_A_NZ;
            }

            Dict.SaveToBinFileEx(NameTableName, m_DictManage.Dict);
            DisplayThreshold();
        }

        private void buttonBatchInsert_Click(object sender, EventArgs e)
        {
            foreach (T_DictStruct word in listBoxWords.SelectedItems)
            {
                m_DictMgr.InsertWord(word.Word, word.Frequency, word.Pos);
                word.Frequency = 0;
                word.Pos = 0;
            }

            Dict.SaveToBinFileEx(NameTableName, m_DictManage.Dict);
            MessageBox.Show("加入成功!", "信息", MessageBoxButtons.OK);
            DisplayThreshold();
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -