Здравствуйте. Есть задача написать переводчик. Собственно есть два массива в одном расположен словарь, в другом сам текст. Надо найти слово из одно массива с текстом в другом с переводом и вывести это в текст бокс. Собственно вот что у мой что у меня получилось. Помогите с поиском пожалуйста.
| Код | using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.IO; using System.Text.RegularExpressions;
namespace ReRA { public partial class Form1 : Form { string[] mas_2 = new string[0]; string[] mas_1 = new string[0]; string[] mas_3 = new string[0]; public Form1() { InitializeComponent(); } private void otkr_Click(object sender, EventArgs e) { string str_j; string[] ob; char[] delimiterChars = { ' ', ',', '.', '!', '?'}; Stream mystream = null; openFileDialog1.ShowDialog(); string filename = openFileDialog1.FileName; mystream = File.Open(filename, FileMode.Open, FileAccess.Read); StreamReader reader = new StreamReader(mystream); if (mystream != null) { richTextBox1.Text = reader.ReadToEnd(); mystream.Close(); str_j= richTextBox1.Text; ob=str_j.Split(delimiterChars); mas_1 = ob;
} }
private void save_Click(object sender, EventArgs e) { saveFileDialog1.ShowDialog(); }
private void Form1_Load(object sender, EventArgs e) { char[] separator = { '=', '\n','\r', ' '}; string str_s; string[] words;
using (StreamReader sr = new StreamReader(@"{0}\slov.txt", Encoding.GetEncoding(1251))) { //считываем данные из файла в строку str_s = sr.ReadToEnd();
//массив считанных из файла слов, разделённых пробелами words = str_s.Split(separator); } mas_2 = words; }
private void izm_Click(object sender, EventArgs e) { for (int i = 0; i < mas_1.Length; i++) { if (mas_2[i].Equals(mas_1[i], StringComparison.OrdinalIgnoreCase)) { int j = i + 1; rez.Text += mas_2[j] + " "; } } } } }
|
|