473,756 Members | 3,390 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

i want to create a program that translates a sentance in english to another language

77 New Member
I want to help teach to a minority group in Milwaukee, so I want to create a dictionary program that translates a sentence (like a homework problem or teacher instructions), from English into Hmong.

I have one Idea, and that is to have an English text file of all the A-words, then a Hmong text file of the proper translations. Each text file would have the same amount of lines, with one english word per line, then translated to hmong. Would it be even possible to..

1. user inputs question, "Describe the holocaust"
2. describe is looked in the d text (like if d, search d.txt), then the word is found. then it either compares it to a translation txt (like hmong-d.txt), spitting out the word. then it would prompt to the next word to translate, one line at a time.

A different way was to have 1 giant text file for each letter. like look up "albino", when it finds the word in the a a-dictionary, it searches for the albino string, then finds the comma, then spits out the word/words after the comma. would this be possible as well? which method is easiest for someone that hasn't c++ in a few years?

so far I have a useless code typed up. i just want to start simple getting a-words to work, then get more complex from there. once i have a start i can go with it. please help me, i would love to reach the needs of my esl students who could use this greatly in the US.

summary,i want to take a line of words, compare each word to a specific dictionary, then output one line at a time, the translation. thank you so much!

this code is not correct:

#include <iostream> // I/O
#include <fstream> // file I/O
#include <iomanip> // format manipulation
#include <string>

//This program will hopefully translate english to hmong
using namespace std;
string english; //declare english word to translate
string search; //what to search

int main()
{

cout << "Type the english words here, then press enter. Make sure to copy the words correctly. If you need to spell check use www.google.com" ;
cin >> english;

ifstream myFile;
myFile.open ("c:\\eAh.txt") ;

string* search = english; //search using input
int offset; // where it was found (or not (-1))
if ((offset = line.find(searc h, 0)) != string::npos) {
cout << "found '" << search << "' @ offset " << offset << endl;
}

return 0;
}
May 22 '07
91 7792
weaknessforcats
9,208 Recognized Expert Moderator Expert
I presume you would load/store your map from/to a disc file. 5000 inserts is nothing. It's just a loop.

Your overhead woul be maintaining the disc file.

If course, you could improve beyond what I did but I was just demonstrating one technique.

A fancy engine may be as large as the one Google uses.

You might want to read up on localization techniques that software companies use to provide the screen displays in different languages depending upon the locale where the product is bought. I know of onwe company that does this using an Access database.

An speaking of databases: Have you considered a SQL database??

You could spend your time design tables rather than writing C++ code.
May 23 '07 #61
jerger
77 New Member
well thats over my head, so that isn't really a possibility right now lol. i am familiar with c++ and manipulating code to work...

my goal now is to find a way to repeat one of my two working programs, so it takes a sentance, pulls out a word, translates it, then moves onto the next sentance. maybe i need to find a way to change the location of the string... where its pointing to with my sub string...

like first word up to space... then translate

then start at space, go to next space....

i'm not sure
May 23 '07 #62
weaknessforcats
9,208 Recognized Expert Moderator Expert
If you decide to go that way and tokensize your strings by pulling out words, seriously look at the design pattern called State.

I can provide a word parsing example, if necessary, using this pattern and the C++ STL.
May 24 '07 #63
jerger
77 New Member
i'll have to learn that first.

my first goal is to find some way to make either of the two programs above, translate a second or third word... rather then simply crash

anyone have a suggestion? i need a loop of some sort but mine crash or only print one word... what needs to be done is the strong needs to be like this

"a b c"

then "b c"
then "c"
then stop when find pause or end line (is it posible to find endl? as a reason to sotp a loop?)
May 24 '07 #64
jerger
77 New Member
my subtract code was not working...

any ideas on how to input a string (sentance), then make a tempstring that holds the word... then translates... then goes back and moves onto the next word?

i was thinking to subtract the string to a temp location, then store that location, then go through and analyze temp... then start over again at the pointer. but when i do this it only analyzes the first word (see my above 2 examples)

any help would greatly be appreciated. the other database examples are good ideas but i am clueless, so i would not be able to program it myself. thanks !
May 24 '07 #65
ahammad
79 New Member
I haven't read through the whole thread, so I don't know how far you are.

Anyway, I just finished writing code for a parsing/storing program. It reads in lines from a file, and separates the string into two parts at a specified character (an equals sign in my case). The program then stores the two parts into a CMapStringToStr ing object, which works just like an array, except you use strings instead of integers as the index.

That way, you can type the index (or key), in your case the word, and retrieve the data at the location of the index, in your case the definition.

The program itself is short (>100 lines), but you really need to research various aspects of C++.

Just one way of implementing your translation program. IMO it's a clean way to do it with not a lot of coding.
May 25 '07 #66
jerger
77 New Member
could you post any helpful code here? i am trying various stuff... the thing is, how could i get it to store more then a few words?

could i brake it into arrays based on the dashes? i'm not sure, maybe i could find all the pointers (spacers and periods/question marks) then store each part into a different variable, by storing the certain parts of the array into it? like from array0-first space, then first space - next space,

not sure.
May 28 '07 #67
ahammad
79 New Member
could you post any helpful code here? i am trying various stuff... the thing is, how could i get it to store more then a few words?

could i brake it into arrays based on the dashes? i'm not sure, maybe i could find all the pointers (spacers and periods/question marks) then store each part into a different variable, by storing the certain parts of the array into it? like from array0-first space, then first space - next space,

not sure.
Just so I know what snippets to post here, do you have an algorithm that can read in lines, and separate the line into two parts (the word and the definition)?

Also, which compiler are you currently using?
May 28 '07 #68
rcmatt4321
25 New Member
Doesent Google Have An API for this? If so you could have it interface with that in someway or another and not even have to do all the tranlation work.

Just Wondering,
Matt
May 28 '07 #69
jerger
77 New Member
i have my code posted above (2 different ways, one using a textfile for words and translations, and another that has the words in the code), using dev c++

what i have is... read in a line, look in the dictionary and it works. FOR ONE WORD. what does not work is multiple words that are not in order. one program will find the first word, then crash on the second. the other, find the first word, then prints the words that follow the definition in the dictionary. so if you type in "house rules" it would spit out house = ma, houses= ma (rather then house = ma, rules = blah blah)

idealy i would like to store the string, and pull out the words one at a time using the spaces as pointers. is it possible to find all the spaces, store them somewhere, then search each round through using my code, based off the pointers for each word? then end when a period or nothing is found?



hmm... is the google code open source? where can i find the actual code?
May 29 '07 #70

Sign in to post your reply or Sign up for a free account.

Similar topics

4
1769
by: Derek Fountain | last post by:
I'm just starting another PHP project and can see a familiar task not far on the horizon. I have several database record tuples that I need to manipulate - person, department, client, job, etc. - and each one needs a form where the user can enter new details to create a new tuple in the DB, another form where the user can enter a name/id/whatever to query the DB and display the results, another form where the user can modify the existing...
8
1794
by: Aziz McTang | last post by:
Hi Group, I am not an experienced programmer at all. I've learned html and css well enough to hand-write simple websites. I'm now looking to move to the next step. Initially, I'd like to do 3 things: 1) Generate web pages This one's fairly obvious maybe. 2) Create a simplified translation package specific to my line of work:
52
9668
by: piaseckiac | last post by:
I am producing a website on air and need a link to change the entire website from standard to metric for temperature, pressure, miles-kilometers, and volume. Thank you.
46
12548
by: vvk4 | last post by:
I have an excel spreadsheet that I need to parse. I was thinking of saving this as a CSV file. And then reading the file using C. The actual in EXCEL looks like: a,b a"b a","b a,",b In CSV format looks like: "a,b","a""b","a"",""b","a,"",b" Does anybody have suggestions or have C program based code to parse CSV. Please reply to the message board itself. I do not wish to get spam.
39
2116
by: Quick Fox | last post by:
Hi All, Please help for following case: How to Load a Assembly from DLL file and create instance of the class in the loaded file. I want make a function that get 2 string parameters (Assembly file Name and Class Name) and create a instance. Thanks
182
7542
by: Jim Hubbard | last post by:
http://www.eweek.com/article2/0,1759,1774642,00.asp
4
2133
by: Chris F Clark | last post by:
Please excuse the length of this post, I am unfortunately long-winded, and don't know how to make my postings more brief. I have a C++ class library (and application generator, called Yacc++(r) and the Language Objects Library) that I have converted over to C#. It works okay. However, in the C# version, one has to build the class library into the generated application, because I haven't structured this one thing right. I would like to...
13
3048
by: jerger | last post by:
my program takes users input (words/sentance) and translates it from english to hmong. I have to main variables, but cannot post my entire code. char In; CString in; basically the user cin >> In; then later in = In, then computes using the dictionary. is there anyway i can remove ! commas and periods from the input before translating in my dictionary? i keep getting error codes. if i do this (first idea) if (strcmp(In, "!") == 0)...
0
1709
by: bvdb | last post by:
Hi Everyone, One of my customers lives in Taiwan and can only make my program work if he changes his Regional and Language Options to English from the Simplifies Chinese that his computer is normally set to use. Switching back and forth is very inconvenient for him. Is there a way that I can compile my program so that it works with the Regional Options set to Simplified Chinese? I set my PC Regional Options to Simplified Chinese,...
0
9455
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9271
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10031
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9708
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8709
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7242
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6534
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3805
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3354
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.