Help with translator program

A Translator that needs help..

  • (2 Pages)
  • +
  • 1
  • 2

22 Replies - 2238 Views - Last Post: 25 April 2009 - 12:47 PM Rate Topic: -----

#1 Translator   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 25-April 09

Help with translator program

Posted 25 April 2009 - 05:58 AM

]Hello Everyone...

I'm A Translator and i have no idea whatsoever about programing. i downloaded lots and lots of glossaries (small specialized dictionaries) from the internet. however, i want to turn everyone one of them to a small dictionary for my own personal use only. and i need help. i'm using Microsoft Visual C# 2008 Express Edition. and all I've done for now is using the already existing form to add a button (I called "Find") and 4 text boxes. what i want is the following:

1) when i type a word or a phrase in text box1, i want information about this word or phrase to pop up in text box2 and 3 and 4. i'll make the arrangement i just need one example of code so i can do finish the whole thing. to make it even clearer to you i'll give you an example

i'll type the word "confer" in text box 1 and when i click Find i want the literal meaning "compare" to appear in text box 2 and the historical info to appear in text box3 and "whatever" info in text box 4.

i hope i'm making myself clear enough for you. and to be honest i'm desperate to know because it'll help me ALOT with my work.

the second thing i wanna know is how to put a title on top of text boxes number 2 3 and 4. i know its the toolbox i just don't know which one.

thanx alot in advance...
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
	public partial class Form1 : Form
	{
		public Form1()
		{
			InitializeComponent();
		}

		private void button1_Click(object sender, EventArgs e)
		{

		}

		private void flowLayoutPanel3_Paint(object sender, PaintEventArgs e)
		{

		}

		private void label1_Click(object sender, EventArgs e)
		{

		}

		private void Form1_Load(object sender, EventArgs e)
		{

		}

		private void flowLayoutPanel2_Paint(object sender, PaintEventArgs e)
		{

		}

		private void flowLayoutPanel1_Paint(object sender, PaintEventArgs e)
		{

		}
	}
}



EDIT: Title edited to be more descriptive

PsychoCoder :)

Is This A Good Question/Topic? 0
  • +

Replies To: Help with translator program

#2 papuccino1   User is offline

  • His name was Robert Paulson.
  • member icon

Reputation: 63
  • View blog
  • Posts: 1,121
  • Joined: 02-March 08

Re: Help with translator program

Posted 25 April 2009 - 06:45 AM

I'll help you out bro. Give me a sec.

Edit: Here's the Form1 Class:

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            textBox2.Text = "x"; //<-----REPLACE THIS WITH THE MEANING OF THE WORD IN TEXTBOX1.
            textBox3.Text = "y"; //<-----REPLACE THIS WITH THE OTHER INFO OF THE WORD.
        }
    }
}


And the Design of the form:

Posted Image


The letter you wanted on top of the TextBoxes are called Labels. Look for the them in the control toolbox.

Without additional information, it's very hard for us to help you out more. Are you going to pull the definition of the words from Lists, XML Files, The Internet? Let us know. :D

This post has been edited by papuccino1: 25 April 2009 - 06:55 AM

Was This Post Helpful? 0
  • +
  • -

#3 Translator   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 25-April 09

Re: Help with translator program

Posted 25 April 2009 - 06:48 AM

View Postpapuccino1, on 25 Apr, 2009 - 05:45 AM, said:

I'll help you out bro. Give me a sec.


thanx man i'd really appreciate it...
Was This Post Helpful? 0
  • +
  • -

#4 Translator   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 25-April 09

Re: Help with translator program

Posted 25 April 2009 - 07:30 AM

View Postpapuccino1, on 25 Apr, 2009 - 05:45 AM, said:

I'll help you out bro. Give me a sec.

Edit: Here's the Form1 Class:

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            textBox2.Text = "x"; //<-----REPLACE THIS WITH THE MEANING OF THE WORD IN TEXTBOX1.
            textBox3.Text = "y"; //<-----REPLACE THIS WITH THE OTHER INFO OF THE WORD.
        }
    }
}


And the Design of the form:

Posted Image


The letter you wanted on top of the TextBoxes are called Labels. Look for the them in the control toolbox.

Without additional information, it's very hard for us to help you out more. Are you going to pull the definition of the words from Lists, XML Files, The Internet? Let us know. :D


Frankly, i was hoping to insert the words and definitions myself because i have the glossaries in the form of lists in Microsoft Word documents. what you sent me is very helpful. but in the case that I wanna insert the entries and the definitions shouldn't there be a way like. if X in textbox1 then Y should be in Textbox2 and so on? that's what i was hoping for :) but thanx alot i'll see what i can do

This post has been edited by Translator: 25 April 2009 - 07:31 AM

Was This Post Helpful? 0
  • +
  • -

#5 papuccino1   User is offline

  • His name was Robert Paulson.
  • member icon

Reputation: 63
  • View blog
  • Posts: 1,121
  • Joined: 02-March 08

Re: Help with translator program

Posted 25 April 2009 - 08:24 AM

Ok, now we're getting somewhere. Recently I have gambled a bit in Lists<>, so I'll give you some advice using Lists in my example. :P

First we need to know how many words you are going to have available for search. What I mean is, your program will be able to define apple, chair and table, and no other words. Tell me how many words you want to be able to define.

For instance, if you want to be to define only three words:

Chair
Tire
Lion

The way I would do it is create a string List. In the first spot of the list place the meaning and in the second spot the other info.

This is the code to create the list and add the information needed.

List<string> Chair = new List<string>();
Chair.Add("An object in which we sit on.");
Chair.Add("This is the other info.");


And this is the code you would need to program on button_Click event:

textBox2.Text = Chair[0];
textBox3.Text = Chair[1];


Now what you need to do is when the button is clicked change the name of the list being called by checking .Text property of the textBox1 control.

Have fun. :D



A list is similar to an array but has a ton of nifty features that makes it better to use instead of arrays for certain problems.
Was This Post Helpful? 0
  • +
  • -

#6 lesPaul456   User is offline

  • D.I.C Addict
  • member icon

Reputation: 175
  • View blog
  • Posts: 729
  • Joined: 16-April 09

Re: Help with translator program

Posted 25 April 2009 - 08:49 AM

Hello Translator,

papuccino1 has given you some very useful advice. I suggest that you also look into databases. Since you are working with large amounts of data, storing all the data "in-memory" will take alot of code, and a lot of time. It would be easier to store all the words and meanings in a table in a database. Then, use Linq to Sql to query that data.

*EDIT* Also, what are the file types of the gloassaries you downloaded? *EDIT*

Hope this helps!

This post has been edited by lesPaul456: 25 April 2009 - 09:16 AM

Was This Post Helpful? 0
  • +
  • -

#7 papuccino1   User is offline

  • His name was Robert Paulson.
  • member icon

Reputation: 63
  • View blog
  • Posts: 1,121
  • Joined: 02-March 08

Re: Help with translator program

Posted 25 April 2009 - 09:25 AM

Paul, he said his list of words are in a Microsoft Word document, so I think we're looking at a list of words with definitions.

I'm sure there are much more elegant ways to go about this, but I think the KISS method works best when trying to learn something new.

At least for me, I learn it the horrible least effective way, then I try to mold into a sexy 5 star beast. :P
Was This Post Helpful? 0
  • +
  • -

#8 SixOfEleven   User is offline

  • Planeswalker
  • member icon

Reputation: 1055
  • View blog
  • Posts: 6,643
  • Joined: 18-October 08

Re: Help with translator program

Posted 25 April 2009 - 09:27 AM

As well as lists, there are also dictionaries. They are a bit harder to use but they would be perfect for you to use. I will try to create a small demo to see if I can help you.

Will be back soon. :)
Was This Post Helpful? 0
  • +
  • -

#9 lesPaul456   User is offline

  • D.I.C Addict
  • member icon

Reputation: 175
  • View blog
  • Posts: 729
  • Joined: 16-April 09

Re: Help with translator program

Posted 25 April 2009 - 09:39 AM

View Postpapuccino1, on 25 Apr, 2009 - 10:25 AM, said:

Paul, he said his list of words are in a Microsoft Word document, so I think we're looking at a list of words with definitions.

I'm sure there are much more elegant ways to go about this, but I think the KISS method works best when trying to learn something new.

At least for me, I learn it the horrible least effective way, then I try to mold into a sexy 5 star beast. :P


Oops! Missed that on my first reading. :D

Yeah, I understand what you are saying, I would just rather store the data in a database or an xml file. If Translator wants to create a complete dictionary, he will be working with hundreds of words. This means hundreds of lines of code to insert the data into the lists.

Translator, is there any way you can convert the word documents to .txt files, or .rtf files? If so,you could just read directly from the files.
Was This Post Helpful? 0
  • +
  • -

#10 papuccino1   User is offline

  • His name was Robert Paulson.
  • member icon

Reputation: 63
  • View blog
  • Posts: 1,121
  • Joined: 02-March 08

Re: Help with translator program

Posted 25 April 2009 - 09:44 AM

View PostlesPaul456, on 25 Apr, 2009 - 08:39 AM, said:

Oops! Missed that on my first reading. :D

Yeah, I understand what you are saying, I would just rather store the data in a database or an xml file. If Translator wants to create a complete dictionary, he will be working with hundreds of words. This means hundreds of lines of code to insert the data into the lists.

Translator, is there any way you can convert the word documents to .txt files, or .rtf files? If so,you could just read directly from the files.


I like where you're going with this. :pirate:
But if he uses a .txt file and the file has 1000 words, wouldn't a search for the word take a long time? (Curious)

This post has been edited by papuccino1: 25 April 2009 - 09:45 AM

Was This Post Helpful? 0
  • +
  • -

#11 lesPaul456   User is offline

  • D.I.C Addict
  • member icon

Reputation: 175
  • View blog
  • Posts: 729
  • Joined: 16-April 09

Re: Help with translator program

Posted 25 April 2009 - 09:57 AM

Quote

I like where you're going with this.
But if he uses a .txt file and the file has 1000 words, wouldn't a search for the word take a long time? (Curious)


Good point...I'm not sure, but I don't think it would take too long. I've seen programs the read large amounts of data from XML files without any noticeable drop in performance.
Was This Post Helpful? 0
  • +
  • -

#12 SixOfEleven   User is offline

  • Planeswalker
  • member icon

Reputation: 1055
  • View blog
  • Posts: 6,643
  • Joined: 18-October 08

Re: Help with translator program

Posted 25 April 2009 - 09:59 AM

This is a quick sample program of how you could use a dictionary to look up the word. I made it a French to English. You would probably want to convert your Word document to some other format, like .txt or .xml, they would be easier to read in.

*EDIT* You would want to read in the words into the dictionary. *EDIT*

Anyway, this is how you could use a dictionary to see if a word can be translated:

    public partial class Form1 : Form
    {
        Dictionary<string, string> frenchWords = new Dictionary<string, string>();

        public Form1()
        {
            InitializeComponent();
            frenchWords.Add("bon jour".ToLower(), "Good morning.");
            frenchWords.Add("merci".ToLower(), "Thank you");
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string theWord = textBox1.Text.ToLower();
            string inFrench;

            if (frenchWords.TryGetValue(theWord, out inFrench))
            {
                textBox2.Text = inFrench;
            }
            else
            {
                textBox2.Text = "I do not understand " + textBox1.Text;
            }
        }



On the form there are two textboxes and one button. You type the word you want to check in the first textbox, click the button. If the word is known a translation is given. If it is not a message is given.

This post has been edited by SixOfEleven: 25 April 2009 - 10:04 AM

Was This Post Helpful? 0
  • +
  • -

#13 Translator   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 25-April 09

Re: Help with translator program

Posted 25 April 2009 - 10:40 AM

thanx alot for your effort guys... you were REALLY helpful... i'm trying to capture what you are saying... the main point here is that i have no idea about programming so all i'm gonna do is copy and paste the codes you send thats all and use my own logic to try to apply these codes to as many words as i can... one thing worth pointing out here is that i dont know what an XML file is... or how it can be "conceived". now i can easily rewrite the glossaries into .txt files or .rtf files but in what shape? because as far as i know .txt files do not support complex texts like tables and so on... its just plain text. and if i used an .rtf file in what shape should i make it can u give me an example? thanx alot

This post has been edited by Translator: 25 April 2009 - 10:41 AM

Was This Post Helpful? 0
  • +
  • -

#14 papuccino1   User is offline

  • His name was Robert Paulson.
  • member icon

Reputation: 63
  • View blog
  • Posts: 1,121
  • Joined: 02-March 08

Re: Help with translator program

Posted 25 April 2009 - 11:02 AM

Ok Translator, I'll help you out.

Just use lists like I pointed. If you want your Translator to have 100 words, you're going to have to manually make 100 string lists.

Now as for using a .txt file
I would make it so the txt file had this format. One line of text per word.

word.meaning.otherinformation:

Chair.Something you sit on.I have no idea what other information is.
Lion. A ferocious cat. I have no idea what other information is.

I have no experience formatting text. I think you have to set the streamreader separator to be the '.'. But don't worry if you don't understand this last part. I'm probably explaining it wrong.

Let's wait for someone who knows about reading txt files help out here. :P

This post has been edited by papuccino1: 25 April 2009 - 11:11 AM

Was This Post Helpful? 0
  • +
  • -

#15 SixOfEleven   User is offline

  • Planeswalker
  • member icon

Reputation: 1055
  • View blog
  • Posts: 6,643
  • Joined: 18-October 08

Re: Help with translator program

Posted 25 April 2009 - 11:13 AM

View PostTranslator, on 25 Apr, 2009 - 09:40 AM, said:

thanx alot for your effort guys... you were REALLY helpful... i'm trying to capture what you are saying... the main point here is that i have no idea about programming so all i'm gonna do is copy and paste the codes you send thats all and use my own logic to try to apply these codes to as many words as i can... one thing worth pointing out here is that i dont know what an XML file is... or how it can be "conceived". now i can easily rewrite the glossaries into .txt files or .rtf files but in what shape? because as far as i know .txt files do not support complex texts like tables and so on... its just plain text. and if i used an .rtf file in what shape should i make it can u give me an example? thanx alot


Can you show an example of what one of the glossary entries would look like? What format to they take?

Are they:

word in one language = word in another language = notes?

Or are they just:

word in one language = word in another language?

That would be helpful...
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2