Hi,
I am still new to C# and am working on an annotator:
1. Input some Chinese Text.
2. Click Button.
3. Output some Chinese Text - each word that's found in the dictionary get's a span-html-class around for later implementing it in a website.
Here it the code for clicking the button:
private void annobutton_Click(object sender, EventArgs e)
{
while (pos < inputBox.TextLength)
{
if (inputBox.Text.Substring(pos).Length < len)
{
textpart = inputBox.Text.Substring(pos, inputBox.Text.Substring(pos).Length);
}
else
{
textpart = inputBox.Text.Substring(pos, len);
}
if (!dict.ContainsKey(textpart) && len >= 1)
{
len--;
}
else if (dict.ContainsKey(textpart) && len >= 1)
{
str = str + "<span class=\"tttword\">" + textpart + "<span class=\"ttt\">" + textpart + " - " + dict[textpart]["py"] + "<br>" + dict[textpart]["de"] + "</span></span>";
pos = pos + len;
len = 5;
}
else if (len <= 0)
{
textpart = inputBox.Text.Substring(pos, 1);
str = str + textpart;
pos++;
len = 5;
}
}
outputBox.Text = str;
}
And here's my problem - the dictionary file is too big (about 300000 lines) - how to properly include it and make the programm work (just needs to work on my computer, as I am generating the output for my website which I will manually upload.)
public partial class Form1 : Form
{
private string str = "";
private string textpart = "";
private int pos = 0;
private int len = 5;
private Dictionary<string, Dictionary<string, string>> dict = new Dictionary<string, Dictionary<string, string>>();
public Form1()
{
InitializeComponent();
dict["我"] = new Dictionary<string, string>();
dict["我"]["py"] = "wo";
dict["我"]["de"] = "wo";
dict["你"] = new Dictionary<string, string>();
dict["你"]["py"] = "ni";
dict["你"]["de"] = "ni";
/* And a lot more of these lines - is there a better way of including the dictionary file? */
}
Can you help me make that work? What is the best way of including such a large dictionary file? (Here I get the dictionary file: http://www.handedict.de/chinesisch_deutsch.php?mode=dl )
Do you have any further question that'll help you help me - ask me ;-)