我想创建一个程序,将英语的语言翻译成另一种语言 [英] i want to create a program that translates a sentance in english to another language

查看:105
本文介绍了我想创建一个程序,将英语的语言翻译成另一种语言的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想帮助密尔沃基的一个少数群体教学,所以我想创建一个字典程序,翻译一个句子(如家庭作业或教师指示),从英语到苗族。


我有一个想法,那就是拥有所有A字的英文文本文件,然后是正确翻译的Hmong文本文件。每个文本文件的行数相同,每行一个英文单词,然后翻译成hmong。是否有可能......


1.用户输入问题,描述大屠杀

2.描述在文本中查找(就像d,搜索d.txt),然后找到这个词。然后它将它与翻译txt(如hmong-d.txt)进行比较,吐出单词。然后它会提示下一个单词翻译,一次一行。


另一种方法是为每个字母添加一个巨大的文本文件。比如查找albino,当它在a-dictionary中找到单词时,它会搜索albino字符串,然后找到逗号,然后在逗号后面吐出单词/单词。这也有可能吗?对于那些几年内没有c ++的人来说哪种方法最简单?


到目前为止我输入了一些无用的代码。我只是想开始简单地让a-words工作,然后从那里变得更加复杂。一旦我有了一个开始,我可以去做它。请帮助我,我很想达到我的esl学生的需求,他们可以在美国大大使用这个。


摘要,我想用一行词,比较每个单词到一个特定的字典,然后一次输出一行,翻译。非常感谢你!


这段代码不正确:


#include< iostream> // I / O

#include< fstream> //文件I / O

#include< iomanip> //格式操作

#include< string>


//这个程序有望使用命名空间将英语翻译成hmong

std;

string english; //声明英语单词翻译

string search; //搜索什么

int main()

{


cout<< 在此输入英文单词,然后按Enter键。确保正确复制单词。如果您需要拼写检查,请使用www.google.com" ;;

cin>>英语;


ifstream myFile;

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

string * search = english; //使用输入搜索

int offset; //找到它的地方(或不是(-1))

if((offset = line.find(search,0))!= string :: npos){

cout<< 找到了' <<搜索<< "'''@ offset" <<偏移<<结束;

}


返回0;

}

解决方案

< blockquote>快速问题....

此代码编译?

如果没有,你会收到什么错误消息?

如果是这样,你怎么知道它不起作用(即它是否崩溃,或者它是否会导致错误输出,如果是的话输出是什么)?



另一种方法是为每个字母分配一个巨大的文本文件。比如查找albino,当它在a-dictionary中找到单词时,它会搜索albino字符串,然后找到逗号,然后在逗号后面吐出单词/单词。这也有可能吗?哪种方法对于几年内没有c ++的人来说最容易?



我认为这是最简单的方法,而不必为每个单词查看两个不同的文件。您希望这些文件有多大?

展开 | 选择 | Wrap | 行号


收回.......

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(search, 0)) != string::npos) {
cout << "found ''" << search << "'' @ offset " << offset << endl;
}

return 0;
}

解决方案

Quick couple of questions....
Is this code compiling?
If not, what error messages do you get?
If so, how do you know it isn''t working (ie does it crash, or does it give bad ouput and if so what is the output)?


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?

I think that that is the easiest way to do it instead of having to look through two different files for each word. How big do you expect these files to get?

Expand|Select|Wrap|Line Numbers


retract that........


这篇关于我想创建一个程序,将英语的语言翻译成另一种语言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆